-
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
Changes from 1 commit
79699fc
895f08b
0786c1e
9d7a79b
3e7f6dd
f393393
1cf1caf
75e4589
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * 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.Collection; | ||
| 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 BaseInputSplit<T extends ScanTask> implements InputSplit<T> { | ||
| private final List<T> tasks; | ||
|
|
||
| public BaseInputSplit(List<T> tasks) { | ||
| Preconditions.checkNotNull(tasks, "tasks cannot be null"); | ||
| this.tasks = Collections.unmodifiableList(Lists.newArrayList(tasks)); | ||
| } | ||
|
|
||
| @Override | ||
| public Collection<T> files() { | ||
| return tasks; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| 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 from the scan's filter, inclusive | ||
|
aokolnychyi marked this conversation as resolved.
Outdated
|
||
| * any predicates that are true or false for the entire file removed, based on the file's | ||
| * partition data. | ||
| * | ||
| * @return a residual expression to apply to rows from this scan | ||
| */ | ||
| Expression residual(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * 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.Collection; | ||
|
|
||
| /** | ||
| * A scan task that may include partial input files, multiple input files or both. | ||
| * | ||
| * @param <T> the type of scan tasks | ||
| */ | ||
| public interface InputSplit<T extends ScanTask> extends ScanTask { | ||
|
aokolnychyi marked this conversation as resolved.
Outdated
|
||
| Collection<T> files(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ | |
| * Scan objects are immutable and can be shared between threads. Refinement methods, like | ||
| * {@link #select(Collection)} and {@link #filter(Expression)}, create new TableScan instances. | ||
| */ | ||
| public interface Scan<T extends Scan<T>> { | ||
| public interface Scan<ThisT, T extends ScanTask, S extends InputSplit<T>> { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am debating whether we need to attach a boundary to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still open. |
||
| /** | ||
| * Create a new scan from this scan's configuration that will override the {@link Table}'s behavior based | ||
| * on the incoming pair. Unknown properties will be ignored. | ||
|
|
@@ -38,15 +38,15 @@ public interface Scan<T extends Scan<T>> { | |
| * @param value value to override with | ||
| * @return a new scan based on this with overridden behavior | ||
| */ | ||
| T option(String property, String value); | ||
| ThisT option(String property, String value); | ||
|
|
||
| /** | ||
| * Create a new scan from this with the schema as its projection. | ||
| * | ||
| * @param schema a projection schema | ||
| * @return a new scan based on this with the given projection | ||
| */ | ||
| T project(Schema schema); | ||
| ThisT project(Schema schema); | ||
|
|
||
| /** | ||
| * Create a new scan from this that, if data columns where selected | ||
|
|
@@ -55,7 +55,7 @@ public interface Scan<T extends Scan<T>> { | |
| * | ||
| * @return a new scan based on this with case sensitivity as stated | ||
| */ | ||
| T caseSensitive(boolean caseSensitive); | ||
| ThisT caseSensitive(boolean caseSensitive); | ||
|
|
||
| /** | ||
| * Create a new scan from this that loads the column stats with each data file. | ||
|
|
@@ -64,7 +64,7 @@ public interface Scan<T extends Scan<T>> { | |
| * | ||
| * @return a new scan based on this that loads column stats. | ||
| */ | ||
| T includeColumnStats(); | ||
| ThisT includeColumnStats(); | ||
|
|
||
| /** | ||
| * Create a new scan from this that will read the given data columns. This produces | ||
|
|
@@ -74,22 +74,22 @@ public interface Scan<T extends Scan<T>> { | |
| * @param columns column names from the table's schema | ||
| * @return a new scan based on this with the given projection columns | ||
| */ | ||
| T select(Collection<String> columns); | ||
| ThisT select(Collection<String> columns); | ||
|
|
||
| /** | ||
| * Create a new scan from the results of this filtered by the {@link Expression}. | ||
| * | ||
| * @param expr a filter expression | ||
| * @return a new scan based on this with results filtered by the expression | ||
| */ | ||
| T filter(Expression expr); | ||
| ThisT filter(Expression expr); | ||
|
|
||
| /** | ||
| * Create a new scan from this that applies data filtering to files but not to rows in those files. | ||
| * | ||
| * @return a new scan based on this that does not filter rows in files. | ||
| */ | ||
| T ignoreResiduals(); | ||
| ThisT ignoreResiduals(); | ||
|
|
||
| /** | ||
| * Create a new scan to use a particular executor to plan. The default worker pool will be | ||
|
|
@@ -98,7 +98,7 @@ public interface Scan<T extends Scan<T>> { | |
| * @param executorService the provided executor | ||
| * @return a table scan that uses the provided executor to access manifests | ||
| */ | ||
| T planWith(ExecutorService executorService); | ||
| ThisT planWith(ExecutorService executorService); | ||
|
|
||
| /** | ||
| * Returns this scan's projection {@link Schema}. | ||
|
|
@@ -113,26 +113,23 @@ public interface Scan<T extends Scan<T>> { | |
| Schema schema(); | ||
|
|
||
| /** | ||
| * Plan the {@link FileScanTask files} that will be read by this scan. | ||
| * Plan tasks for this scan without trying to balance the work. | ||
|
aokolnychyi marked this conversation as resolved.
Outdated
|
||
| * <p> | ||
| * Each file has a residual expression that should be applied to filter the file's rows. | ||
| * <p> | ||
| * This simple plan returns file scans for each file from position 0 to the file's length. For | ||
| * planning that will combine small files, split large files, and attempt to balance work, use | ||
| * {@link #planTasks()} instead. | ||
| * Use {@link #planTasks()} for planning that will attempt to balance the work | ||
| * by combining small or splitting large files. | ||
|
aokolnychyi marked this conversation as resolved.
Outdated
|
||
| * | ||
| * @return an Iterable of file tasks that are required by this scan | ||
| * @return an Iterable of tasks required by this scan | ||
| */ | ||
| CloseableIterable<FileScanTask> planFiles(); | ||
| CloseableIterable<T> planFiles(); | ||
|
|
||
| /** | ||
| * Plan the {@link CombinedScanTask tasks} for this scan. | ||
| * Plan input split tasks for this scan and balance the work. | ||
| * <p> | ||
| * Tasks created by this method may read partial input files, multiple input files, or both. | ||
| * Tasks created by this method may read partial input files, multiple input files or both. | ||
| * | ||
| * @return an Iterable of tasks for this scan | ||
| * @return an Iterable of input splits required by this scan | ||
| */ | ||
| CloseableIterable<CombinedScanTask> planTasks(); | ||
| CloseableIterable<S> planTasks(); | ||
|
aokolnychyi marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * Returns the target split size for this scan. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.