Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

added or node for other source time agnostic #69

Draft
wants to merge 2 commits into
base: optimize+metric+aggregation+order+by
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public QueryNode build() {
entitiesRequest.getOffset(),
entitiesRequest.getOrderByList());
executionContext.setSortAndPaginationNodeAdded(true);
} else {
// TODO: Add an or node on other sources, if there is order by on other sources
rootNode =
new OrNode(
List.of(rootNode, new DataFetcherNode(QS.name(), Filter.getDefaultInstance())));
}

rootNode.acceptVisitor(new ExecutionContextBuilderVisitor(executionContext));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public ExecutionContextBuilderVisitor(ExecutionContext executionContext) {
public Void visit(DataFetcherNode dataFetcherNode) {
String source = dataFetcherNode.getSource();

executionContext.removePendingSelectionSource(source);
if (!source.equals("EDS")) {
executionContext.removePendingSelectionSource(source);
}
// TODO: Currently, assumes that the order by attribute is also present in the selection set
executionContext.removePendingSelectionSourceForOrderBy(source);
// TODO: Remove redundant attributes for metric aggregation source for order by
Expand All @@ -73,14 +75,14 @@ public Void visit(DataFetcherNode dataFetcherNode) {
Set<String> fetchedAttributes =
sourceToSelectionAttributeMap.getOrDefault(source, Collections.emptySet());

if (!executionContext.getPendingSelectionSources().isEmpty()) {
Set<String> redundantPendingSelectionSources =
getRedundantPendingSelectionSources(
fetchedAttributes,
executionContext.getPendingSelectionSources(),
executionContext.getSourceToSelectionAttributeMap());
redundantPendingSelectionSources.forEach(executionContext::removePendingSelectionSource);
}
// if (!executionContext.getPendingSelectionSources().isEmpty()) {
// Set<String> redundantPendingSelectionSources =
// getRedundantPendingSelectionSources(
// fetchedAttributes,
// executionContext.getPendingSelectionSources(),
// executionContext.getSourceToSelectionAttributeMap());
// redundantPendingSelectionSources.forEach(executionContext::removePendingSelectionSource);
// }

if (!executionContext.getPendingSelectionSourcesForOrderBy().isEmpty()) {
Set<String> redundantPendingSelectionSourcesForOrderBy =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,16 @@ public EntityResponse visit(DataFetcherNode dataFetcherNode) {

// fetching both attribute selections and metric order by selections for
// optimized pagination
List<Expression> attributeSelections =
executionContext
.getSourceToSelectionExpressionMap()
.getOrDefault(source, executionContext.getEntityIdExpressions());
List<Expression> attributeSelections = new ArrayList<>();
if (!source.equals("EDS")) {
attributeSelections =
executionContext
.getSourceToSelectionExpressionMap()
.getOrDefault(source, executionContext.getEntityIdExpressions());
} else {
attributeSelections = executionContext.getEntityIdExpressions();
}

List<Expression> metricOrderBySelections =
executionContext
.getSourceToMetricOrderByExpressionMap()
Expand Down