vvysotskyi commented on a change in pull request #2072:
URL: https://github.com/apache/drill/pull/2072#discussion_r419244221
##########
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:
I use IntelliJ IDEA, the warning was the following: `'for' loop may be
replaced with 'while' loop`.
Its description is
```
Reports for loops which contain neither initialization or update components,
and can thus be replaced by simpler while statements. Example:
for(; exitCondition(); ) {
process();
}
This loop can be replaced with
while(exitCondition()) {
process();
}
A fix action is also available for other for loops, so you can replace any
for loop with while.
Use the checkbox below if you wish this inspection to ignore for loops with
trivial or non-existent conditions.
```
----------------------------------------------------------------
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]