UNPKG

@azure/cosmos

Version:
66 lines (65 loc) 2.92 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 UnorderedDistinctEndpointComponent_exports = {}; __export(UnorderedDistinctEndpointComponent_exports, { UnorderedDistinctEndpointComponent: () => UnorderedDistinctEndpointComponent }); module.exports = __toCommonJS(UnorderedDistinctEndpointComponent_exports); var import_hashObject = require("../../utils/hashObject.js"); var import_parallelQueryResult = require("../parallelQueryResult.js"); var import_headerUtils = require("../headerUtils.js"); class UnorderedDistinctEndpointComponent { constructor(executionContext) { this.executionContext = executionContext; this.hashedResults = /* @__PURE__ */ new Set(); } hashedResults; hasMoreResults() { const result = this.executionContext.hasMoreResults(); return result; } async fetchMore(diagnosticNode) { const buffer = []; const response = await this.executionContext.fetchMore(diagnosticNode); if (!response) { const result2 = (0, import_parallelQueryResult.createParallelQueryResult)([], /* @__PURE__ */ new Map(), {}, void 0); return { result: result2, headers: (0, import_headerUtils.getInitialHeader)() }; } if (response.result === void 0 || !Array.isArray(response.result.buffer) || response.result.buffer.length === 0) { const result2 = (0, import_parallelQueryResult.createParallelQueryResult)([], /* @__PURE__ */ new Map(), {}, void 0); return { result: result2, headers: response.headers }; } const parallelResult = response.result; const dataToProcess = parallelResult.buffer; for (const item of dataToProcess) { if (item) { const hashedResult = await (0, import_hashObject.hashObject)(item); if (!this.hashedResults.has(hashedResult)) { buffer.push(item); this.hashedResults.add(hashedResult); } } } const result = (0, import_parallelQueryResult.createParallelQueryResult)(buffer, /* @__PURE__ */ new Map(), void 0, void 0); return { result, headers: response.headers }; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { UnorderedDistinctEndpointComponent });