-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] Allow customization of conversion to relative paths #324
Draft
ashvina
wants to merge
6
commits into
main
Choose a base branch
from
323-conversion-to-relative-paths
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6dd2878
Optimize new snapshot in delta client
ashvina e2c31c9
Fix unit tests
ashvina 5b85fe9
Add configurable filter to control relative paths
ashvina f8dcea2
Declare filter as a service
ashvina f08a672
Restore previous file path mapping logic
ashvina 8d6dc0c
TEMP: disable relative path filter
ashvina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
api/src/main/java/io/onetable/spi/filter/FilterInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.onetable.spi.filter; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* A {@link FilterInterceptor} is the filter component of the Intercepting Filter design pattern. It | ||
* is used to apply a transformation or to instrument a given input. Concrete implementations of | ||
* this interface are injected (intercept) in the table format translation workflow to customize the | ||
* behavior of the default translation workflow, or to generate logs or metrics. | ||
* | ||
* <p>E.g. of filters 1) a filter to convert absolute paths of data files to relative paths 2) a | ||
* filter to emit metrics for the number of data files in a snapshot 3) validate the table metadata | ||
* and throw an exception if certain conditions are not met | ||
* | ||
* <p>A filter to generate relative paths may be needed by certain query planners. In such a case | ||
* the user would inject such a filter before data files are written in the target format. Different | ||
* users may need to integrate with different metric collectors. A user can inject a specific filter | ||
* and limit the number of dependencies in the core code. | ||
* | ||
* <p>As such, the filter is a tool to customize the behavior of the table format translation | ||
* workflow. | ||
*/ | ||
public interface FilterInterceptor<T> { | ||
/** | ||
* Each filter is identifiable by a name. This name can be used in config files to specify which | ||
* filters to apply at runtime. | ||
* | ||
* @return the identifier of this filter. | ||
*/ | ||
String getIdentifier(); | ||
|
||
/** | ||
* Initialize the filter with the given properties. | ||
* | ||
* @param properties the properties map to initialize the filter. | ||
*/ | ||
void init(Map<String, String> properties); | ||
|
||
/** | ||
* Apply the filter to the given input. Note that this method may alter the input. | ||
* | ||
* @param input the input to apply the filter to. | ||
* @return the transformed input. | ||
*/ | ||
T apply(T input); | ||
|
||
/** Close the filter and release any resources. */ | ||
default void close() {} | ||
} |
32 changes: 32 additions & 0 deletions
32
api/src/main/java/io/onetable/spi/filter/SnapshotFilesFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.onetable.spi.filter; | ||
|
||
import java.util.List; | ||
|
||
import io.onetable.model.storage.OneDataFile; | ||
import io.onetable.spi.sync.TargetClient; | ||
|
||
/** | ||
* This extension of the {@link FilterInterceptor} interface is used to apply a filter or | ||
* transformation on a list of {@link OneDataFile}s. Concrete implementation of this interface would | ||
* typically be applied by a {@link TargetClient} before writing a list of {@link OneDataFile}s | ||
* related to a specific snapshot. | ||
*/ | ||
public interface SnapshotFilesFilter extends FilterInterceptor<List<OneDataFile>> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Add test to validate customization