paul-rogers commented on a change in pull request #2072:
URL: https://github.com/apache/drill/pull/2072#discussion_r418754627



##########
File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataControllerBatch.java
##########
@@ -127,113 +126,93 @@ protected MetadataControllerBatch(MetadataControllerPOP 
popConfig,
         ? null
         : popConfig.getContext().metadataToHandle().stream()
             .collect(Collectors.toMap(MetadataInfo::identifier, 
Function.identity()));
-    this.metadataUnits = new ArrayList<>();
-    this.statisticsCollector = new StatisticsCollectorImpl();
     this.columnNamesOptions = new ColumnNamesOptions(context.getOptions());
   }
 
-  protected boolean setupNewSchema() {
-    container.clear();
-    container.addOrGet(MetastoreAnalyzeConstants.OK_FIELD_NAME, 
Types.required(TypeProtos.MinorType.BIT), null);
-    container.addOrGet(MetastoreAnalyzeConstants.SUMMARY_FIELD_NAME, 
Types.required(TypeProtos.MinorType.VARCHAR), null);
-    container.buildSchema(BatchSchema.SelectionVectorMode.NONE);
-    container.setEmpty();
-    return true;
-  }
-
   @Override
   public IterOutcome innerNext() {
-    IterOutcome outcome;
-    boolean finishedLeft;
-    if (finished) {
-      return IterOutcome.NONE;
-    }
+    while (state != State.FINISHED) {
+      switch (state) {
+        case RIGHT: {
 
-    if (!finishedRight) {
-      outcome = handleRightIncoming();
-      if (outcome != null) {
-        return outcome;
+          // Can only return NOT_YET
+          IterOutcome outcome = handleRightIncoming();
+          if (outcome != null) {
+            return outcome;
+          }
+          break;
+        }
+        case LEFT: {
+
+          // Can only return NOT_YET
+          IterOutcome outcome = handleLeftIncoming();
+          if (outcome != null) {
+            return outcome;
+          }
+          break;
+        }
+        case WRITE:
+          writeToMetastore();
+          createSummary();
+          state = State.FINISHED;
+          return IterOutcome.OK_NEW_SCHEMA;
+
+        case FINISHED:
+          break;
+
+        default:
+          throw new IllegalStateException(state.name());
       }
     }
+    return IterOutcome.NONE;
+  }
 
+  private IterOutcome handleRightIncoming() {
     outer:
-    while (true) {
-      outcome = next(0, left);
+    for (;;) {

Review comment:
       @vvysotskyi, thanks for the review. The `for (;;)` is a bit more terse; 
happy to put it back if doing so is clearer.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to