@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
89 lines (88 loc) • 3.61 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 ParallelQueryRangeStrategy_exports = {};
__export(ParallelQueryRangeStrategy_exports, {
ParallelQueryRangeStrategy: () => ParallelQueryRangeStrategy
});
module.exports = __toCommonJS(ParallelQueryRangeStrategy_exports);
var import_PartitionRangeManager = require("../PartitionRangeManager.js");
var import_logicalPartitionRange = require("../logicalPartitionRange.js");
class ParallelQueryRangeStrategy {
getStrategyType() {
return "ParallelQuery";
}
filterPartitionRanges(targetRanges, continuationRanges) {
if (!targetRanges || targetRanges.length === 0) {
return { rangeTokenPairs: [] };
}
if (!continuationRanges || continuationRanges.length === 0) {
const rangeTokenPairs2 = targetRanges.map((range) => ({
range,
continuationToken: void 0,
filteringCondition: void 0
}));
return { rangeTokenPairs: rangeTokenPairs2 };
}
const rangeTokenPairs = [];
continuationRanges.sort((left, right) => {
const leftRange = (0, import_logicalPartitionRange.getLogicalPartitionRange)(left.range, left.epkMin, left.epkMax);
const rightRange = (0, import_logicalPartitionRange.getLogicalPartitionRange)(right.range, right.epkMin, right.epkMax);
return leftRange.minInclusive.localeCompare(rightRange.minInclusive);
});
for (const range of continuationRanges) {
if ((0, import_PartitionRangeManager.isPartitionRangeActive)(range.continuationToken, range.isActive)) {
rangeTokenPairs.push({ ...range });
}
}
const sortedTargetRanges = [...targetRanges].sort(
(left, right) => left.minInclusive.localeCompare(right.minInclusive)
);
const firstLogicalRange = (0, import_logicalPartitionRange.getLogicalPartitionRange)(
continuationRanges[0].range,
continuationRanges[0].epkMin,
continuationRanges[0].epkMax
);
const queryMax = sortedTargetRanges[sortedTargetRanges.length - 1].maxExclusive;
const coveredRanges = continuationRanges.map(
(range) => (0, import_logicalPartitionRange.getLogicalPartitionRange)(range.range, range.epkMin, range.epkMax)
);
const uncoveredRanges = (0, import_logicalPartitionRange.getUncoveredPartitionKeyRanges)(
sortedTargetRanges,
coveredRanges,
firstLogicalRange.minInclusive,
queryMax
);
rangeTokenPairs.push(
...uncoveredRanges.map((range) => ({
range: range.partitionKeyRange,
continuationToken: void 0,
filteringCondition: void 0,
epkMin: range.minInclusive,
epkMax: range.maxExclusive
}))
);
return {
rangeTokenPairs
};
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ParallelQueryRangeStrategy
});
//# sourceMappingURL=ParallelQueryRangeStrategy.js.map