Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
Align ListenerResult params with AnalyzerContext params
  • Loading branch information
astefan committed Nov 26, 2024
1 parent 74185d4 commit 8d55211
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public void analyzedPlan(
.collect(Collectors.toSet());
// get the field names from the parsed plan combined with the ENRICH match fields from the ENRICH policy
var fieldNames = fieldNames(parsed, enrichMatchFields);
ListenerResult listenerResult = new ListenerResult(enrichResolution, fieldNames, null, null);
ListenerResult listenerResult = new ListenerResult(null, null, enrichResolution, fieldNames);

// first resolve the lookup indices, then the main indices
preAnalyzeLookupIndices(preAnalysis.lookupIndices, listenerResult, l);
Expand Down Expand Up @@ -377,17 +377,17 @@ private void preAnalyzeLookupIndices(List<TableInfo> indices, ListenerResult lis
table.index(),
listenerResult.fieldNames(),
null,
new ListenerResultWrappingListener<>(listener, listenerResult, listenerResult::withIndexResolution)
new ListenerResultWrappingListener<>(listener, listenerResult, listenerResult::withLookupIndexResolution)
);
} else {
try {
// No lookup indices specified
listener.onResponse(
new ListenerResult(
listenerResult.enrichResolution,
listenerResult.fieldNames,
listenerResult.indices,
IndexResolution.invalid("[none specified]"),
listenerResult.indices
listenerResult.enrichResolution,
listenerResult.fieldNames
)
);
} catch (Exception ex) {
Expand Down Expand Up @@ -444,10 +444,10 @@ private void preAnalyzeIndices(
// if this was a pure remote CCS request (no local indices) and all remotes are offline, return an empty IndexResolution
listener.onResponse(
new ListenerResult(
listenerResult.enrichResolution,
listenerResult.fieldNames,
IndexResolution.valid(new EsIndex(table.index(), Map.of(), Map.of())),
listenerResult.lookupIndices,
IndexResolution.valid(new EsIndex(table.index(), Map.of(), Map.of()))
listenerResult.enrichResolution,
listenerResult.fieldNames
)
);
} else {
Expand All @@ -464,10 +464,10 @@ private void preAnalyzeIndices(
// occurs when dealing with local relations (row a = 1)
listener.onResponse(
new ListenerResult(
listenerResult.enrichResolution,
listenerResult.fieldNames,
IndexResolution.invalid("[none specified]"),
listenerResult.lookupIndices,
IndexResolution.invalid("[none specified]")
listenerResult.enrichResolution,
listenerResult.fieldNames
)
);
} catch (Exception ex) {
Expand Down Expand Up @@ -730,17 +730,21 @@ public void onFailure(Exception e) {
}

private record ListenerResult(
EnrichResolution enrichResolution,
Set<String> fieldNames,
IndexResolution indices,
IndexResolution lookupIndices,
IndexResolution indices
EnrichResolution enrichResolution,
Set<String> fieldNames
) {
ListenerResult withEnrichResolution(EnrichResolution newEnrichResolution) {
return new ListenerResult(newEnrichResolution, fieldNames(), lookupIndices(), indices());
return new ListenerResult(indices(), lookupIndices(), newEnrichResolution, fieldNames() );
}

ListenerResult withIndexResolution(IndexResolution newIndexResolution) {
return new ListenerResult(enrichResolution(), fieldNames(), lookupIndices(), newIndexResolution);
return new ListenerResult(newIndexResolution, lookupIndices(), enrichResolution(), fieldNames());
}

ListenerResult withLookupIndexResolution(IndexResolution newIndexResolution) {
return new ListenerResult(indices(), newIndexResolution, enrichResolution(), fieldNames());
}
};
}

0 comments on commit 8d55211

Please sign in to comment.