You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/09/12 13:32:28 UTC

[GitHub] [incubator-druid] leventov commented on a change in pull request #8281: Add realization for updating version of derived segments in Materiali…

leventov commented on a change in pull request #8281: Add realization for updating version of derived segments in Materiali…
URL: https://github.com/apache/incubator-druid/pull/8281#discussion_r323741492
 
 

 ##########
 File path: extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisor.java
 ##########
 @@ -369,6 +369,19 @@ void checkSegmentsAndSubmitTasks()
     MapDifference<Interval, String> difference = Maps.difference(maxCreatedDate, derivativeVersion);
     Map<Interval, String> toBuildInterval = new HashMap<>(difference.entriesOnlyOnLeft());
     Map<Interval, String> toDropInterval = new HashMap<>(difference.entriesOnlyOnRight());
+    // update version of derived segments if isn't the max (created_date) of all base segments
+    // prevent user supplied segments list did not match with segments list obtained from db
+    Map<Interval, MapDifference.ValueDifference<String>> checkIfNewestVersion =
+            new HashMap<>(difference.entriesDiffering());
+    for (Map.Entry<Interval, MapDifference.ValueDifference<String>> entry : checkIfNewestVersion.entrySet()) {
+      String versionOfBase = maxCreatedDate.get(entry.getKey());
+      String versionOfDerivative = derivativeVersion.get(entry.getKey());
+      if (versionOfBase.compareTo(versionOfDerivative) > 0 &&
 
 Review comment:
   I think the suggested version is not idiomatic Java. I came to this PR exactly to find out why an `IntSupplier` was created and called immediately. If the second get may be null, this should have been just two-level nested if:
   ```java
   if (versionOfBase.compareTo(versionOfDerivative) > 0) {
     final int baseCount = baseSegments.get(entry.getKey()).size();
     final int usedCount = metadataStorageCoordinator.getUsedSegmentsForInterval(spec.getBaseDataSource(), entry.getKey()).size();
     if (baseCount == usedCount) {
       ..
     }
   }
   ```

----------------------------------------------------------------
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: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org