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 2019/07/30 23:29:34 UTC

[GitHub] [incubator-iceberg] shardulm94 commented on a change in pull request #315: [WIP] Incremental processing prototype

shardulm94 commented on a change in pull request #315: [WIP] Incremental processing prototype
URL: https://github.com/apache/incubator-iceberg/pull/315#discussion_r308985345
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/IncrDataTableScan.java
 ##########
 @@ -0,0 +1,127 @@
+/*
+ * 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 com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Set;
+import org.apache.iceberg.exceptions.RuntimeIOException;
+import org.apache.iceberg.expressions.Expression;
+import org.apache.iceberg.io.CloseableIterable;
+
+class IncrDataTableScan extends DataTableScan implements IncrTableScan {
+  private final TableOperations ops;
+  private final Table table;
+
+  private Long snapshotId;
+  private boolean colStats;
+  private Collection<String> selectedColumns;
+
+  private long startSnapshotId;
+  private long endSnapshotId;
+
+  IncrDataTableScan(TableOperations ops, Table table) {
+    super(ops, table);
+    this.ops = ops;
+    this.table = table;
+  }
+
+  IncrDataTableScan(TableOperations ops, Table table, Long snapshotId, Schema schema,
+                    Expression rowFilter, boolean caseSensitive, boolean colStats,
+                    Collection<String> selectedColumns,
+                    long startSnapshotId, long endSnapshotId) {
+    super(ops, table, snapshotId, schema, rowFilter, caseSensitive, colStats, selectedColumns);
+
+    this.ops = ops;
+    this.table = table;
+    this.snapshotId = snapshotId;
+    this.colStats = colStats;
+    this.selectedColumns = selectedColumns;
+
+    this.startSnapshotId = startSnapshotId;
+    this.endSnapshotId = endSnapshotId;
+  }
+
+  @Override
+  public IncrTableScan readRange(long newStartSnapshotId, long newEndSnapshotId) {
+    return new IncrDataTableScan(ops, table, snapshotId, schema(), filter(), isCaseSensitive(),
+            colStats, selectedColumns, newStartSnapshotId, newEndSnapshotId);
+  }
+
+  @Override
+  public CloseableIterable<FileScanTask> planFiles() {
+    Snapshot s1 = snapshot(startSnapshotId);
+    Snapshot s2 = snapshot(endSnapshotId);
+
+    Set<DataFile> s1Files = files(s1);
+    Set<DataFile> s2Files = files(s2);
+    // Remove all those files which were already in s1
+    Set<DataFile> files = Sets.difference(s2Files, s1Files);
 
 Review comment:
   One more way can be to get a set of snapshot IDs between start and end, and parse only the end snapshot accumulating files relating to set of snaphot IDs. This way you only have to read the end snapshot and does not need the set difference between all files of 2 snapshots.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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