You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "JingsongLi (via GitHub)" <gi...@apache.org> on 2023/07/03 09:46:45 UTC

[GitHub] [incubator-paimon] JingsongLi commented on a diff in pull request #1470: [core] Introduce incremental-between read by timestamp

JingsongLi commented on code in PR #1470:
URL: https://github.com/apache/incubator-paimon/pull/1470#discussion_r1250579330


##########
paimon-core/src/main/java/org/apache/paimon/table/source/snapshot/IncrementalStartingScanner.java:
##########
@@ -46,6 +46,9 @@ public IncrementalStartingScanner(long start, long end) {
 
     @Override
     public Result scan(SnapshotManager manager, SnapshotReader reader) {
+        start = (start < manager.earliestSnapshotId()) ? manager.earliestSnapshotId() - 1 : start;

Review Comment:
   reuse earliestSnapshotId and latestSnapshotId



##########
paimon-core/src/main/java/org/apache/paimon/table/source/snapshot/IncrementalTimeStampStartingScanner.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.paimon.table.source.snapshot;
+
+import org.apache.paimon.Snapshot;
+import org.apache.paimon.utils.SnapshotManager;
+
+/** {@link StartingScanner} for incremental changes by timestamp. */
+public class IncrementalTimeStampStartingScanner implements StartingScanner {
+
+    private final long startTimestamp;
+    private final long endTimestamp;
+
+    public IncrementalTimeStampStartingScanner(long startTimestamp, long endTimestamp) {
+        this.startTimestamp = startTimestamp;
+        this.endTimestamp = endTimestamp;
+    }
+
+    @Override
+    public Result scan(SnapshotManager manager, SnapshotReader reader) {
+        Snapshot earliestSnapshot = manager.snapshot(manager.earliestSnapshotId());
+        Snapshot latestSnapshot = manager.latestSnapshot();
+        if (startTimestamp > latestSnapshot.timeMillis()
+                || endTimestamp < earliestSnapshot.timeMillis()) {
+            return new NoSnapshot();
+        }
+        Snapshot startSnapshot = manager.earlierOrEqualTimeMills(startTimestamp);
+        Long startSnapshotId =
+                (startSnapshot == null)
+                        ? manager.snapshot(manager.earliestSnapshotId()).id() - 1

Review Comment:
   reuse earliestSnapshotId



-- 
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@paimon.apache.org

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