@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
76 lines (75 loc) • 3.28 kB
JavaScript
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 ParallelQueryContinuationTokenManager_exports = {};
__export(ParallelQueryContinuationTokenManager_exports, {
ParallelQueryContinuationTokenManager: () => ParallelQueryContinuationTokenManager
});
module.exports = __toCommonJS(ParallelQueryContinuationTokenManager_exports);
var import_BaseContinuationTokenManager = require("./BaseContinuationTokenManager.js");
var import_CompositeQueryContinuationToken = require("../../documents/ContinuationToken/CompositeQueryContinuationToken.js");
class ParallelQueryContinuationTokenManager extends import_BaseContinuationTokenManager.BaseContinuationTokenManager {
processRangesForPagination(pageSize, _isResponseEmpty) {
const result = this.partitionManager.processParallelRanges(pageSize);
if (!result || !result.processedRangeMappings || result.processedRangeMappings.length === 0) {
return { endIndex: 0, processedRanges: [] };
}
const rangeMappings = result.processedRangeMappings.map(
(mapping) => (0, import_CompositeQueryContinuationToken.convertRangeMappingToQueryRange)(mapping)
);
this.updateRangeList(rangeMappings);
if (result.lastPartitionBeforeCutoff && result.lastPartitionBeforeCutoff.mapping) {
this.offset = result.lastPartitionBeforeCutoff.mapping.offset;
this.limit = result.lastPartitionBeforeCutoff.mapping.limit;
}
return { endIndex: result.endIndex, processedRanges: result.processedRanges };
}
getCurrentContinuationToken() {
if (this.rangeList.length === 0) {
return void 0;
}
return {
rid: this.collectionLink,
rangeMappings: this.rangeList,
offset: this.offset,
limit: this.limit
};
}
getSerializationFunction() {
return import_CompositeQueryContinuationToken.serializeCompositeToken;
}
processQuerySpecificResponse(_responseResult) {
}
performQuerySpecificDataTrim(_processedRanges, _endIndex) {
}
updateRangeList(rangeMappings) {
for (const newRange of rangeMappings) {
const existingRangeIndex = this.rangeList.findIndex(
(existingRange) => existingRange.queryRange.min === newRange.queryRange.min && existingRange.queryRange.max === newRange.queryRange.max
);
if (existingRangeIndex >= 0) {
this.rangeList[existingRangeIndex] = newRange;
} else {
this.rangeList.push(newRange);
}
}
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ParallelQueryContinuationTokenManager
});