From ed6a98366cd413465c686f806477ab0578e8dc6d Mon Sep 17 00:00:00 2001 From: SJ Date: Sun, 17 Jan 2021 22:02:21 +0530 Subject: [PATCH 1/2] added or node for other source time agnostic --- .../gateway/service/entity/query/ExecutionTreeBuilder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/ExecutionTreeBuilder.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/ExecutionTreeBuilder.java index af8a1820..c1e3a442 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/ExecutionTreeBuilder.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/ExecutionTreeBuilder.java @@ -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)); From 78bf1e2363f454fc022291dfdbfb9d51bb10b76e Mon Sep 17 00:00:00 2001 From: SJ Date: Mon, 18 Jan 2021 13:14:50 +0530 Subject: [PATCH 2/2] fetch ids from eds first, and then attributes later --- .../ExecutionContextBuilderVisitor.java | 20 ++++++++++--------- .../query/visitor/ExecutionVisitor.java | 14 +++++++++---- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionContextBuilderVisitor.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionContextBuilderVisitor.java index f6307b1b..f8cc3d24 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionContextBuilderVisitor.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionContextBuilderVisitor.java @@ -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 @@ -73,14 +75,14 @@ public Void visit(DataFetcherNode dataFetcherNode) { Set fetchedAttributes = sourceToSelectionAttributeMap.getOrDefault(source, Collections.emptySet()); - if (!executionContext.getPendingSelectionSources().isEmpty()) { - Set redundantPendingSelectionSources = - getRedundantPendingSelectionSources( - fetchedAttributes, - executionContext.getPendingSelectionSources(), - executionContext.getSourceToSelectionAttributeMap()); - redundantPendingSelectionSources.forEach(executionContext::removePendingSelectionSource); - } +// if (!executionContext.getPendingSelectionSources().isEmpty()) { +// Set redundantPendingSelectionSources = +// getRedundantPendingSelectionSources( +// fetchedAttributes, +// executionContext.getPendingSelectionSources(), +// executionContext.getSourceToSelectionAttributeMap()); +// redundantPendingSelectionSources.forEach(executionContext::removePendingSelectionSource); +// } if (!executionContext.getPendingSelectionSourcesForOrderBy().isEmpty()) { Set redundantPendingSelectionSourcesForOrderBy = diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionVisitor.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionVisitor.java index fe167699..f76961eb 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionVisitor.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionVisitor.java @@ -148,10 +148,16 @@ public EntityResponse visit(DataFetcherNode dataFetcherNode) { // fetching both attribute selections and metric order by selections for // optimized pagination - List attributeSelections = - executionContext - .getSourceToSelectionExpressionMap() - .getOrDefault(source, executionContext.getEntityIdExpressions()); + List attributeSelections = new ArrayList<>(); + if (!source.equals("EDS")) { + attributeSelections = + executionContext + .getSourceToSelectionExpressionMap() + .getOrDefault(source, executionContext.getEntityIdExpressions()); + } else { + attributeSelections = executionContext.getEntityIdExpressions(); + } + List metricOrderBySelections = executionContext .getSourceToMetricOrderByExpressionMap()