From d9d90ac6d9ed3370616fcfc23457b1eeceded4d0 Mon Sep 17 00:00:00 2001 From: Theo van Kraay Date: Thu, 5 Sep 2024 14:57:51 +0100 Subject: [PATCH] temp revert back changes that break even legacy emulator --- .../parallelQueryExecutionContextBase.js | 7 ++--- .../pipelinedQueryExecutionContext.js | 27 +++++++++---------- .../src/routing/smartRoutingMapProvider.js | 5 ++-- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js index bfe2c62bd..7d823212a 100644 --- a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js @@ -58,8 +58,7 @@ export class ParallelQueryExecutionContextBase { this.err = undefined; this.state = ParallelQueryExecutionContextBase.STATES.started; this.routingProvider = new SmartRoutingMapProvider(this.clientContext); - //this.sortOrders = this.partitionedQueryExecutionInfo.queryInfo.orderBy; - this.sortOrders = []; + this.sortOrders = this.partitionedQueryExecutionInfo.queryInfo.orderBy; this.requestContinuation = options ? options.continuationToken || options.continuation : null; // response headers of undergoing operation this.respHeaders = getInitialHeader(); @@ -82,9 +81,7 @@ export class ParallelQueryExecutionContextBase { async _onTargetPartitionRanges() { // invokes the callback when the target partition ranges are ready const parsedRanges = this.partitionedQueryExecutionInfo.queryRanges; - //const queryRanges = parsedRanges.map((item) => QueryRange.parseFromDict(item)); - //hard coding the partition key ranges to be the parsedRanges - const queryRanges = parsedRanges; + const queryRanges = parsedRanges.map((item) => QueryRange.parseFromDict(item)); return this.routingProvider.getOverlappingRanges(this.collectionLink, queryRanges, this.getDiagnosticNode()); } /** diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js index b4d668803..fd0bcf7c4 100644 --- a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js @@ -1,7 +1,10 @@ import { Constants } from "../common"; import { RUCapPerOperationExceededErrorCode } from "../request/RUCapPerOperationExceededError"; +import { GroupByEndpointComponent } from "./EndpointComponent/GroupByEndpointComponent"; +import { GroupByValueEndpointComponent } from "./EndpointComponent/GroupByValueEndpointComponent"; import { NonStreamingOrderByDistinctEndpointComponent } from "./EndpointComponent/NonStreamingOrderByDistinctEndpointComponent"; import { NonStreamingOrderByEndpointComponent } from "./EndpointComponent/NonStreamingOrderByEndpointComponent"; +import { OffsetLimitEndpointComponent } from "./EndpointComponent/OffsetLimitEndpointComponent"; import { OrderByEndpointComponent } from "./EndpointComponent/OrderByEndpointComponent"; import { OrderedDistinctEndpointComponent } from "./EndpointComponent/OrderedDistinctEndpointComponent"; import { UnorderedDistinctEndpointComponent } from "./EndpointComponent/UnorderedDistinctEndpointComponent"; @@ -24,16 +27,13 @@ export class PipelinedQueryExecutionContext { this.pageSize = PipelinedQueryExecutionContext.DEFAULT_PAGE_SIZE; } // Pick between Nonstreaming and streaming endpoints - // this.nonStreamingOrderBy = partitionedQueryExecutionInfo.queryInfo.hasNonStreamingOrderBy; - this.nonStreamingOrderBy = false; + this.nonStreamingOrderBy = partitionedQueryExecutionInfo.queryInfo.hasNonStreamingOrderBy; // Pick between parallel vs order by execution context - // const sortOrders = partitionedQueryExecutionInfo.queryInfo.orderBy; - const sortOrders = []; + const sortOrders = partitionedQueryExecutionInfo.queryInfo.orderBy; // TODO: Currently we don't get any field from backend to determine streaming queries if (this.nonStreamingOrderBy) { this.vectorSearchBufferSize = this.calculateVectorSearchBufferSize(partitionedQueryExecutionInfo.queryInfo, options); - //const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType; - const distinctType = "None"; + const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType; const context = new ParallelQueryExecutionContext(this.clientContext, this.collectionLink, this.query, this.options, this.partitionedQueryExecutionInfo); if (distinctType === "None") { this.endpoint = new NonStreamingOrderByEndpointComponent(context, sortOrders, this.vectorSearchBufferSize, partitionedQueryExecutionInfo.queryInfo.offset); @@ -51,7 +51,7 @@ export class PipelinedQueryExecutionContext { else { this.endpoint = new ParallelQueryExecutionContext(this.clientContext, this.collectionLink, this.query, this.options, this.partitionedQueryExecutionInfo); } - /*if (Object.keys(partitionedQueryExecutionInfo.queryInfo.groupByAliasToAggregateType).length > + if (Object.keys(partitionedQueryExecutionInfo.queryInfo.groupByAliasToAggregateType).length > 0 || partitionedQueryExecutionInfo.queryInfo.aggregates.length > 0 || partitionedQueryExecutionInfo.queryInfo.groupByExpressions.length > 0) { @@ -61,21 +61,20 @@ export class PipelinedQueryExecutionContext { else { this.endpoint = new GroupByEndpointComponent(this.endpoint, partitionedQueryExecutionInfo.queryInfo); } - }*/ + } // If top then add that to the pipeline. TOP N is effectively OFFSET 0 LIMIT N - /*const top = partitionedQueryExecutionInfo.queryInfo.top; + const top = partitionedQueryExecutionInfo.queryInfo.top; if (typeof top === "number") { this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, 0, top); - }*/ + } // If offset+limit then add that to the pipeline - /*const limit = partitionedQueryExecutionInfo.queryInfo.limit; + const limit = partitionedQueryExecutionInfo.queryInfo.limit; const offset = partitionedQueryExecutionInfo.queryInfo.offset; if (typeof limit === "number" && typeof offset === "number") { this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, offset, limit); - }*/ + } // If distinct then add that to the pipeline - // const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType; - const distinctType = "None"; + const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType; if (distinctType === "Ordered") { this.endpoint = new OrderedDistinctEndpointComponent(this.endpoint); } diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js index ca94d6a85..35a8520bc 100644 --- a/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js @@ -57,10 +57,9 @@ export class SmartRoutingMapProvider { */ async getOverlappingRanges(collectionLink, sortedRanges, diagnosticNode) { // validate if the list is non- overlapping and sorted TODO: any PartitionKeyRanges - /*if (!SmartRoutingMapProvider._isSortedAndNonOverlapping(sortedRanges)) { + if (!SmartRoutingMapProvider._isSortedAndNonOverlapping(sortedRanges)) { throw new Error("the list of ranges is not a non-overlapping sorted ranges"); - }*/ - sortedRanges = []; + } let partitionKeyRanges = []; // TODO: any ParitionKeyRanges if (sortedRanges.length === 0) { return partitionKeyRanges;