UNPKG

@azure/cosmos

Version:
93 lines (92 loc) 3.95 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var orderByQueryExecutionContext_exports = {}; __export(orderByQueryExecutionContext_exports, { OrderByQueryExecutionContext: () => OrderByQueryExecutionContext }); module.exports = __toCommonJS(orderByQueryExecutionContext_exports); var import_orderByDocumentProducerComparator = require("./orderByDocumentProducerComparator.js"); var import_parallelQueryExecutionContextBase = require("./parallelQueryExecutionContextBase.js"); var import_TargetPartitionRangeManager = require("./queryFilteringStrategy/TargetPartitionRangeManager.js"); var import_OrderByQueryProcessingStrategy = require("./queryProcessingStrategy/OrderByQueryProcessingStrategy.js"); class OrderByQueryExecutionContext extends import_parallelQueryExecutionContextBase.ParallelQueryExecutionContextBase { /** * Provides the OrderByQueryExecutionContext. * This class is capable of handling orderby queries and dervives from ParallelQueryExecutionContextBase. * * When handling a parallelized query, it instantiates one instance of * DocumentProcuder per target partition key range and aggregates the result of each. * * @param clientContext - The service endpoint to use to create the client. * @param collectionLink - The Collection Link * @param options - Represents the feed options. * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo * @hidden */ constructor(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo, correlatedActivityId) { const rangeManager = import_TargetPartitionRangeManager.TargetPartitionRangeManager.createForOrderByQuery({ queryInfo: partitionedQueryExecutionInfo }); const processingStrategy = new import_OrderByQueryProcessingStrategy.OrderByQueryProcessingStrategy( partitionedQueryExecutionInfo.queryInfo.orderBy ); const orderByComparator = new import_orderByDocumentProducerComparator.OrderByDocumentProducerComparator( partitionedQueryExecutionInfo.queryInfo.orderBy ); const comparator = (docProd1, docProd2) => { return orderByComparator.compare(docProd1, docProd2); }; super( clientContext, collectionLink, query, options, partitionedQueryExecutionInfo, correlatedActivityId, rangeManager, processingStrategy, comparator ); } /** * Fetches next single item from producer for ORDER BY processing. */ async fetchFromProducer(producer) { const response = await producer.fetchNextItem(); if (response && response.result) { return { result: [response.result], headers: response.headers }; } return response; } /** * Determines if buffered producers should continue to be processed for ORDER BY queries. * For ORDER BY, only process when no unfilled producers remain to maintain order. * @param isUnfilledQueueEmpty - Whether the unfilled queue is empty * @hidden */ shouldProcessBufferedProducers(isUnfilledQueueEmpty) { return isUnfilledQueueEmpty; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { OrderByQueryExecutionContext });