-
Notifications
You must be signed in to change notification settings - Fork 3.4k
API: Refactor FileScanTask #5077
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
Merged
aokolnychyi
merged 8 commits into
apache:master
from
aokolnychyi:refactor-file-scan-task
Jun 28, 2022
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
79699fc
API: Refactor FileScanTask
aokolnychyi 895f08b
Review feedback, round 1
aokolnychyi 0786c1e
Fix typo
aokolnychyi 9d7a79b
Rename method
aokolnychyi 3e7f6dd
Feedback
aokolnychyi f393393
More changes
aokolnychyi 1cf1caf
Use Collection
aokolnychyi 75e4589
Clean up
aokolnychyi 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
39 changes: 39 additions & 0 deletions
39
api/src/main/java/org/apache/iceberg/BaseScanTaskGroup.java
This file contains hidden or 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,39 @@ | ||
| /* | ||
| * 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 org.apache.iceberg; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Lists; | ||
|
|
||
| public class BaseScanTaskGroup<T extends ScanTask> implements ScanTaskGroup<T> { | ||
| private final List<T> tasks; | ||
|
|
||
| public BaseScanTaskGroup(Iterable<T> tasks) { | ||
| Preconditions.checkNotNull(tasks, "tasks cannot be null"); | ||
| this.tasks = Lists.newArrayList(tasks); | ||
| } | ||
|
|
||
| @Override | ||
| public Iterable<T> tasks() { | ||
| return Collections.unmodifiableList(tasks); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 org.apache.iceberg; | ||
|
|
||
| import org.apache.iceberg.expressions.Expression; | ||
|
|
||
| /** | ||
| * A scan task over a range of bytes in a content file. | ||
| * | ||
| * @param <F> the Java class of the content file | ||
| */ | ||
| public interface ContentScanTask<F extends ContentFile<F>> extends ScanTask { | ||
|
aokolnychyi marked this conversation as resolved.
|
||
| /** | ||
| * The {@link ContentFile file} to scan. | ||
| * | ||
| * @return the file to scan | ||
| */ | ||
| F file(); | ||
|
|
||
| /** | ||
| * The {@link PartitionSpec spec} used to store this file. | ||
| * | ||
| * @return the partition spec from this file's manifest | ||
| */ | ||
| PartitionSpec spec(); | ||
|
|
||
| /** | ||
| * The starting position of this scan range in the file. | ||
| * | ||
| * @return the start position of this scan range | ||
| */ | ||
| long start(); | ||
|
|
||
| /** | ||
| * The number of bytes to scan from the {@link #start()} position in the file. | ||
| * | ||
| * @return the length of this scan range in bytes | ||
| */ | ||
| long length(); | ||
|
|
||
| /** | ||
| * Returns the residual expression that should be applied to rows in this file scan. | ||
| * <p> | ||
| * The residual expression for a file is a filter expression created by partially evaluating the scan's filter | ||
| * using the file's partition data. | ||
| * | ||
| * @return a residual expression to apply to rows from this scan | ||
| */ | ||
| Expression residual(); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 org.apache.iceberg; | ||
|
|
||
| /** | ||
| * A scan task that may include partial input files, multiple input files or both. | ||
| * | ||
| * @param <T> the type of scan tasks | ||
| */ | ||
| public interface ScanTaskGroup<T extends ScanTask> extends ScanTask { | ||
| /** | ||
| * Returns scan tasks in this group. | ||
| */ | ||
| Iterable<T> tasks(); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Just use ImmutableList.of() and then return it directly in tasks()?
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.
This is on purpose to avoid Kryo serialization issues. We usually rely on arrays but generics complicate things. I'll need to pass around
Class<T>to make it work with arrays. I added tests to make sure Kryo works with mutable lists. I think that's also true for Flink but I can switch to arrays if mutable lists are a problem.Uh oh!
There was an error while loading. Please reload this page.
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.
What about using this?
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.
@rdblue, I am not sure this will be safe, unfortunately. If we are to support lists with multiple task types, we can't assume the rest of the list has the same type as the first element. We may end up with an array store exception at runtime.
Suppose we have
List<ParentTask>with two elements of typeChildTask1andChildTask2. If we create an array of typeChildTask1, we won't be able to storeChildTask2in it (even if we cast the array to the parent interface). It will compile but probably fail at runtime.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.
We could just use
Object[]then?Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah, we can use an object array. I also added a transient list to avoid building a list on each call.