Guosmilesmile commented on code in PR #19115:
URL: https://github.com/apache/iceberg/pull/19115#discussion_r4704233167
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/source/lookup/IcebergFullCachingLookupFunction.java:
##########
@@ -270,11 +290,53 @@ private synchronized void loadCache() throws IOException {
LOG.info(
"IcebergFullCachingLookupFunction loading finished, snapshot={},
rows={}, cost={} ms",
- snapshot == null ? "none" : snapshotId,
+ snapshotId,
rowCnt,
loadTimeMs);
}
+ private void loadDelta(long fromExclusive, long toInclusive) throws
IOException {
+ InMemoryLookupCache delta = new InMemoryLookupCache();
+ long start = System.currentTimeMillis();
+ long rowCnt;
+ try (CloseableIterable<RowData> rows = reader.readDelta(fromExclusive,
toInclusive)) {
+ rowCnt = fillCache(rows, delta);
+ }
+
+ long loadTimeMs = System.currentTimeMillis() - start;
+
+ if (closed) {
+ return;
+ }
+
+ this.cache = cache.mergedWith(delta);
+ this.currentSnapshotId = toInclusive;
+ this.cachedRecords = cachedRecords + rowCnt;
+ this.latestLoadTimeMs = loadTimeMs;
+ loadCounter.inc();
Review Comment:
Agreed that monitoring rollbacks is important. This PR will add a counter
first, and we can address the rest in follow-up work.
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/source/lookup/IcebergFullCachingLookupFunction.java:
##########
@@ -270,11 +290,53 @@ private synchronized void loadCache() throws IOException {
LOG.info(
"IcebergFullCachingLookupFunction loading finished, snapshot={},
rows={}, cost={} ms",
- snapshot == null ? "none" : snapshotId,
+ snapshotId,
rowCnt,
loadTimeMs);
}
+ private void loadDelta(long fromExclusive, long toInclusive) throws
IOException {
+ InMemoryLookupCache delta = new InMemoryLookupCache();
+ long start = System.currentTimeMillis();
+ long rowCnt;
+ try (CloseableIterable<RowData> rows = reader.readDelta(fromExclusive,
toInclusive)) {
+ rowCnt = fillCache(rows, delta);
+ }
+
+ long loadTimeMs = System.currentTimeMillis() - start;
+
+ if (closed) {
+ return;
+ }
+
+ this.cache = cache.mergedWith(delta);
Review Comment:
Good point, add a check before merge can reduce a copy of map.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]