You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/07/25 17:40:43 UTC

[GitHub] [iceberg] aokolnychyi commented on a diff in pull request #5300: Core: Add base implementations for changelog tasks

aokolnychyi commented on code in PR #5300:
URL: https://github.com/apache/iceberg/pull/5300#discussion_r929139734


##########
core/src/main/java/org/apache/iceberg/BaseAddedRowsScanTask.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.List;
+import org.apache.iceberg.expressions.ResidualEvaluator;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+
+class BaseAddedRowsScanTask
+    extends BaseChangelogContentScanTask<AddedRowsScanTask, DataFile>
+    implements AddedRowsScanTask {
+
+  private final DeleteFile[] deletes;
+
+  BaseAddedRowsScanTask(int changeOrdinal, long commitSnapshotId, DataFile file, DeleteFile[] deletes,
+                        String schemaString, String specString, ResidualEvaluator residuals) {
+    super(changeOrdinal, commitSnapshotId, file, schemaString, specString, residuals);
+    this.deletes = deletes != null ? deletes : new DeleteFile[0];
+  }
+
+  @Override
+  protected AddedRowsScanTask self() {
+    return this;
+  }
+
+  @Override
+  public List<DeleteFile> deletes() {
+    return ImmutableList.copyOf(deletes);
+  }
+
+  @Override
+  protected Iterable<AddedRowsScanTask> splitUsingOffsets(List<Long> offsets) {
+    return () -> new OffsetsAwareSplitScanTaskIteratorImpl(this, offsets);
+  }
+
+  @Override
+  protected Iterable<AddedRowsScanTask> splitUsingFixedSize(long targetSplitSize) {
+    return () -> new FixedSizeSplitScanTaskIteratorImpl(this, targetSplitSize);
+  }
+
+  private static class SplitScanTaskImpl
+      extends SplitScanTask<SplitScanTaskImpl, AddedRowsScanTask, DataFile>
+      implements AddedRowsScanTask {
+
+    SplitScanTaskImpl(AddedRowsScanTask parentTask, long offset, long length) {
+      super(parentTask, offset, length);
+    }
+
+    @Override
+    public List<DeleteFile> deletes() {
+      return parentTask().deletes();
+    }
+
+    @Override
+    public SplitScanTaskImpl merge(ScanTask other) {
+      SplitScanTaskImpl that = (SplitScanTaskImpl) other;
+      return new SplitScanTaskImpl(parentTask(), start(), length() + that.length());

Review Comment:
   @szehon-ho, I am not sure that will be any cleaner as the only purpose of `merge` would be to directly call that new abstract method. I feel like it would pretty much the same.
   
   @stevenzwu, that's the existing logic from `FileScanTask`. If two tasks are adjacent after split planning, we merge them together into one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org