swapneshgandhi commented on a change in pull request #8272: Support incremental 
load in Druid lookups
URL: https://github.com/apache/incubator-druid/pull/8272#discussion_r319316228
 
 

 ##########
 File path: 
extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/JdbcCacheGenerator.java
 ##########
 @@ -101,23 +109,41 @@
         }
     );
     final String newVersion;
-    if (lastDBUpdate != null) {
-      newVersion = lastDBUpdate.toString();
-    } else {
-      newVersion = StringUtils.format("%d", dbQueryStart);
-    }
-    final CacheScheduler.VersionedCache versionedCache = 
scheduler.createVersionedCache(entryId, newVersion);
+    CacheScheduler.VersionedCache versionedCache = null;
     try {
-      final Map<String, String> cache = versionedCache.getCache();
-      for (Pair<String, String> pair : pairs) {
-        cache.put(pair.lhs, pair.rhs);
+      if (doIncrementalLoad) {
+        newVersion = StringUtils.format("%d", lastDBUpdate);
+        ConcurrentMap<String, String> newCachedEntries = new 
ConcurrentHashMap<>();
+        LOG.info(" found %s new incremental entries for %s", pairs.size(), 
entryId);
+        for (Pair<String, String> pair : pairs) {
+          newCachedEntries.put(pair.lhs, pair.rhs);
+        }
+        versionedCache = entryId.createFromExisitngCache(entryId, newVersion, 
newCachedEntries);
+        return versionedCache;
+      } else {
+        LOG.info("Not doing incremental load since lastDBUpdate: %s, 
namespace.getTsColumn() %s, lastVersion %s," +
+              " lastCheck %s", lastDBUpdate, namespace.getTsColumn(), 
lastVersion, lastCheck);
+        if (lastDBUpdate != null) {
+          // for incremental lookups this will set the new version to last db 
update,
+          // so that during next load we will read all keys that were added 
after the db update.
 
 Review comment:
   done

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to