mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-12 15:37:27 +01:00
add copy of cosmos node.js SDK as local dependency
This commit is contained in:
committed by
Chris Anderson
parent
ff1e733679
commit
ca396cdfbe
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
/** @hidden */
|
||||
export interface Aggregator {
|
||||
aggregate: (other: any) => void;
|
||||
getResult: () => number;
|
||||
}
|
||||
//# sourceMappingURL=Aggregator.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Aggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/Aggregator.ts"],"names":[],"mappings":"AAEA,cAAc;AACd,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,MAAM,CAAC;CACzB"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=Aggregator.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Aggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/Aggregator.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** @hidden */\nexport interface Aggregator {\n aggregate: (other: any) => void;\n getResult: () => number;\n}\n"]}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { Aggregator } from "./Aggregator";
|
||||
/** @hidden */
|
||||
export interface AverageAggregateResult {
|
||||
sum: number;
|
||||
count: number;
|
||||
}
|
||||
/** @hidden */
|
||||
export declare class AverageAggregator implements Aggregator {
|
||||
sum: number;
|
||||
count: number;
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other: AverageAggregateResult): void;
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult(): number;
|
||||
}
|
||||
//# sourceMappingURL=AverageAggregator.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AverageAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/AverageAggregator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,qBAAa,iBAAkB,YAAW,UAAU;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACrB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAYrD;;OAEG;IACI,SAAS,IAAI,MAAM;CAM3B"}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/** @hidden */
|
||||
export class AverageAggregator {
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other) {
|
||||
if (other == null || other.sum == null) {
|
||||
return;
|
||||
}
|
||||
if (this.sum == null) {
|
||||
this.sum = 0.0;
|
||||
this.count = 0;
|
||||
}
|
||||
this.sum += other.sum;
|
||||
this.count += other.count;
|
||||
}
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult() {
|
||||
if (this.sum == null || this.count <= 0) {
|
||||
return undefined;
|
||||
}
|
||||
return this.sum / this.count;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=AverageAggregator.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AverageAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/AverageAggregator.ts"],"names":[],"mappings":"AAUA,cAAc;AACd,MAAM,OAAO,iBAAiB;IAG5B;;OAEG;IACI,SAAS,CAAC,KAA6B;QAC5C,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE;YACtC,OAAO;SACR;QACD,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE;YACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;SAChB;QACD,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC;QACtB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,SAAS;QACd,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE;YACvC,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Aggregator } from \"./Aggregator\";\n\n/** @hidden */\nexport interface AverageAggregateResult {\n sum: number;\n count: number;\n}\n\n/** @hidden */\nexport class AverageAggregator implements Aggregator {\n public sum: number;\n public count: number;\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: AverageAggregateResult): void {\n if (other == null || other.sum == null) {\n return;\n }\n if (this.sum == null) {\n this.sum = 0.0;\n this.count = 0;\n }\n this.sum += other.sum;\n this.count += other.count;\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n if (this.sum == null || this.count <= 0) {\n return undefined;\n }\n return this.sum / this.count;\n }\n}\n"]}
|
||||
local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import { Aggregator } from "./Aggregator";
|
||||
/** @hidden */
|
||||
export declare class CountAggregator implements Aggregator {
|
||||
value: number;
|
||||
/**
|
||||
* Represents an aggregator for COUNT operator.
|
||||
* @hidden
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other: number): void;
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult(): number;
|
||||
}
|
||||
//# sourceMappingURL=CountAggregator.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CountAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/CountAggregator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,qBAAa,eAAgB,YAAW,UAAU;IACzC,KAAK,EAAE,MAAM,CAAC;IACrB;;;OAGG;;IAIH;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACI,SAAS,IAAI,MAAM;CAG3B"}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/** @hidden */
|
||||
export class CountAggregator {
|
||||
/**
|
||||
* Represents an aggregator for COUNT operator.
|
||||
* @hidden
|
||||
*/
|
||||
constructor() {
|
||||
this.value = 0;
|
||||
}
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other) {
|
||||
this.value += other;
|
||||
}
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=CountAggregator.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CountAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/CountAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,eAAe;IAE1B;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAa;QAC5B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Aggregator } from \"./Aggregator\";\n\n/** @hidden */\nexport class CountAggregator implements Aggregator {\n public value: number;\n /**\n * Represents an aggregator for COUNT operator.\n * @hidden\n */\n constructor() {\n this.value = 0;\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: number): void {\n this.value += other;\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
import { Aggregator } from "./Aggregator";
|
||||
interface MaxAggregateResult {
|
||||
count: number;
|
||||
max?: number;
|
||||
}
|
||||
/** @hidden */
|
||||
export declare class MaxAggregator implements Aggregator {
|
||||
private value;
|
||||
private comparer;
|
||||
/**
|
||||
* Represents an aggregator for MAX operator.
|
||||
* @hidden
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other: MaxAggregateResult): void;
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult(): number;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=MaxAggregator.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MaxAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MaxAggregator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,cAAc;AACd,qBAAa,aAAc,YAAW,UAAU;IAC9C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAoC;IACpD;;;OAGG;;IAKH;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAUjD;;OAEG;IACI,SAAS,IAAI,MAAM;CAG3B"}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator";
|
||||
/** @hidden */
|
||||
export class MaxAggregator {
|
||||
/**
|
||||
* Represents an aggregator for MAX operator.
|
||||
* @hidden
|
||||
*/
|
||||
constructor() {
|
||||
this.value = undefined;
|
||||
this.comparer = new OrderByDocumentProducerComparator(["Ascending"]);
|
||||
}
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other) {
|
||||
if (this.value === undefined) {
|
||||
this.value = other.max;
|
||||
}
|
||||
else if (this.comparer.compareValue(other.max, typeof other.max, this.value, typeof this.value) > 0) {
|
||||
this.value = other.max;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=MaxAggregator.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MaxAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MaxAggregator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iCAAiC,EAAE,MAAM,sCAAsC,CAAC;AAQzF,cAAc;AACd,MAAM,OAAO,aAAa;IAGxB;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAiC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IACvE,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAyB;QACxC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;SACxB;aAAM,IACL,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAC1F;YACA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;SACxB;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { OrderByDocumentProducerComparator } from \"../orderByDocumentProducerComparator\";\nimport { Aggregator } from \"./Aggregator\";\n\ninterface MaxAggregateResult {\n count: number;\n max?: number;\n}\n\n/** @hidden */\nexport class MaxAggregator implements Aggregator {\n private value: number;\n private comparer: OrderByDocumentProducerComparator;\n /**\n * Represents an aggregator for MAX operator.\n * @hidden\n */\n constructor() {\n this.value = undefined;\n this.comparer = new OrderByDocumentProducerComparator([\"Ascending\"]);\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: MaxAggregateResult): void {\n if (this.value === undefined) {\n this.value = other.max;\n } else if (\n this.comparer.compareValue(other.max, typeof other.max, this.value, typeof this.value) > 0\n ) {\n this.value = other.max;\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
import { Aggregator } from "./Aggregator";
|
||||
export interface MinAggregateResult {
|
||||
min: number;
|
||||
count: number;
|
||||
}
|
||||
/** @hidden */
|
||||
export declare class MinAggregator implements Aggregator {
|
||||
private value;
|
||||
private comparer;
|
||||
/**
|
||||
* Represents an aggregator for MIN operator.
|
||||
* @hidden
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other: MinAggregateResult): void;
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult(): number;
|
||||
}
|
||||
//# sourceMappingURL=MinAggregator.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MinAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MinAggregator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,qBAAa,aAAc,YAAW,UAAU;IAC9C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAoC;IACpD;;;OAGG;;IAKH;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAajD;;OAEG;IACI,SAAS,IAAI,MAAM;CAG3B"}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator";
|
||||
/** @hidden */
|
||||
export class MinAggregator {
|
||||
/**
|
||||
* Represents an aggregator for MIN operator.
|
||||
* @hidden
|
||||
*/
|
||||
constructor() {
|
||||
this.value = undefined;
|
||||
this.comparer = new OrderByDocumentProducerComparator(["Ascending"]);
|
||||
}
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other) {
|
||||
if (this.value === undefined) {
|
||||
// || typeof this.value === "object"
|
||||
this.value = other.min;
|
||||
}
|
||||
else {
|
||||
const otherType = other.min === null ? "NoValue" : typeof other.min; // || typeof other === "object"
|
||||
const thisType = this.value === null ? "NoValue" : typeof this.value;
|
||||
if (this.comparer.compareValue(other.min, otherType, this.value, thisType) < 0) {
|
||||
this.value = other.min;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=MinAggregator.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MinAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MinAggregator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iCAAiC,EAAE,MAAM,sCAAsC,CAAC;AAQzF,cAAc;AACd,MAAM,OAAO,aAAa;IAGxB;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAiC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IACvE,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAyB;QACxC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,oCAAoC;YACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;SACxB;aAAM;YACL,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,+BAA+B;YACpG,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC;YACrE,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAC9E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;aACxB;SACF;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { OrderByDocumentProducerComparator } from \"../orderByDocumentProducerComparator\";\nimport { Aggregator } from \"./Aggregator\";\n\nexport interface MinAggregateResult {\n min: number;\n count: number;\n}\n\n/** @hidden */\nexport class MinAggregator implements Aggregator {\n private value: number;\n private comparer: OrderByDocumentProducerComparator;\n /**\n * Represents an aggregator for MIN operator.\n * @hidden\n */\n constructor() {\n this.value = undefined;\n this.comparer = new OrderByDocumentProducerComparator([\"Ascending\"]);\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: MinAggregateResult): void {\n if (this.value === undefined) {\n // || typeof this.value === \"object\"\n this.value = other.min;\n } else {\n const otherType = other.min === null ? \"NoValue\" : typeof other.min; // || typeof other === \"object\"\n const thisType = this.value === null ? \"NoValue\" : typeof this.value;\n if (this.comparer.compareValue(other.min, otherType, this.value, thisType) < 0) {\n this.value = other.min;\n }\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { Aggregator } from "./Aggregator";
|
||||
/** @hidden */
|
||||
export declare class StaticValueAggregator implements Aggregator {
|
||||
value: any;
|
||||
aggregate(other: unknown): void;
|
||||
getResult(): any;
|
||||
}
|
||||
//# sourceMappingURL=StaticValueAggregator.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"StaticValueAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/StaticValueAggregator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,qBAAa,qBAAsB,YAAW,UAAU;IAC/C,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM/B,SAAS,IAAI,GAAG;CAGxB"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/** @hidden */
|
||||
export class StaticValueAggregator {
|
||||
aggregate(other) {
|
||||
if (this.value === undefined) {
|
||||
this.value = other;
|
||||
}
|
||||
}
|
||||
getResult() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=StaticValueAggregator.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"StaticValueAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/StaticValueAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,qBAAqB;IAEzB,SAAS,CAAC,KAAc;QAC7B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SACpB;IACH,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Aggregator } from \"./Aggregator\";\n\n/** @hidden */\nexport class StaticValueAggregator implements Aggregator {\n public value: any;\n public aggregate(other: unknown): void {\n if (this.value === undefined) {\n this.value = other;\n }\n }\n\n public getResult(): any {\n return this.value;\n }\n}\n"]}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import { Aggregator } from "./Aggregator";
|
||||
/** @hidden */
|
||||
export declare class SumAggregator implements Aggregator {
|
||||
sum: number;
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other: number): void;
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult(): number;
|
||||
}
|
||||
//# sourceMappingURL=SumAggregator.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SumAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/SumAggregator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,qBAAa,aAAc,YAAW,UAAU;IACvC,GAAG,EAAE,MAAM,CAAC;IACnB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWrC;;OAEG;IACI,SAAS,IAAI,MAAM;CAG3B"}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/** @hidden */
|
||||
export class SumAggregator {
|
||||
/**
|
||||
* Add the provided item to aggregation result.
|
||||
*/
|
||||
aggregate(other) {
|
||||
if (other === undefined) {
|
||||
return;
|
||||
}
|
||||
if (this.sum === undefined) {
|
||||
this.sum = other;
|
||||
}
|
||||
else {
|
||||
this.sum += other;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the aggregation result.
|
||||
*/
|
||||
getResult() {
|
||||
return this.sum;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SumAggregator.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SumAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/SumAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,aAAa;IAExB;;OAEG;IACI,SAAS,CAAC,KAAa;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,OAAO;SACR;QACD,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAAE;YAC1B,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;SAClB;aAAM;YACL,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC;SACnB;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Aggregator } from \"./Aggregator\";\n\n/** @hidden */\nexport class SumAggregator implements Aggregator {\n public sum: number;\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: number): void {\n if (other === undefined) {\n return;\n }\n if (this.sum === undefined) {\n this.sum = other;\n } else {\n this.sum += other;\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.sum;\n }\n}\n"]}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { AverageAggregator } from "./AverageAggregator";
|
||||
import { CountAggregator } from "./CountAggregator";
|
||||
import { MaxAggregator } from "./MaxAggregator";
|
||||
import { MinAggregator } from "./MinAggregator";
|
||||
import { SumAggregator } from "./SumAggregator";
|
||||
import { StaticValueAggregator } from "./StaticValueAggregator";
|
||||
import { AggregateType } from "../../request/ErrorResponse";
|
||||
export declare function createAggregator(aggregateType: AggregateType): AverageAggregator | CountAggregator | MaxAggregator | MinAggregator | SumAggregator | StaticValueAggregator;
|
||||
export { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator };
|
||||
export { Aggregator } from "./Aggregator";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,aAAa,GAE1B,iBAAiB,GACjB,eAAe,GACf,aAAa,GACb,aAAa,GACb,aAAa,GACb,qBAAqB,CAexB;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { AverageAggregator } from "./AverageAggregator";
|
||||
import { CountAggregator } from "./CountAggregator";
|
||||
import { MaxAggregator } from "./MaxAggregator";
|
||||
import { MinAggregator } from "./MinAggregator";
|
||||
import { SumAggregator } from "./SumAggregator";
|
||||
import { StaticValueAggregator } from "./StaticValueAggregator";
|
||||
export function createAggregator(aggregateType) {
|
||||
switch (aggregateType) {
|
||||
case "Average":
|
||||
return new AverageAggregator();
|
||||
case "Count":
|
||||
return new CountAggregator();
|
||||
case "Max":
|
||||
return new MaxAggregator();
|
||||
case "Min":
|
||||
return new MinAggregator();
|
||||
case "Sum":
|
||||
return new SumAggregator();
|
||||
default:
|
||||
return new StaticValueAggregator();
|
||||
}
|
||||
}
|
||||
export { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator };
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,MAAM,UAAU,gBAAgB,CAC9B,aAA4B;IAQ5B,QAAQ,aAAa,EAAE;QACrB,KAAK,SAAS;YACZ,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACjC,KAAK,OAAO;YACV,OAAO,IAAI,eAAe,EAAE,CAAC;QAC/B,KAAK,KAAK;YACR,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B,KAAK,KAAK;YACR,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B,KAAK,KAAK;YACR,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B;YACE,OAAO,IAAI,qBAAqB,EAAE,CAAC;KACtC;AACH,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AverageAggregator } from \"./AverageAggregator\";\nimport { CountAggregator } from \"./CountAggregator\";\nimport { MaxAggregator } from \"./MaxAggregator\";\nimport { MinAggregator } from \"./MinAggregator\";\nimport { SumAggregator } from \"./SumAggregator\";\nimport { StaticValueAggregator } from \"./StaticValueAggregator\";\nimport { AggregateType } from \"../../request/ErrorResponse\";\n\nexport function createAggregator(\n aggregateType: AggregateType,\n):\n | AverageAggregator\n | CountAggregator\n | MaxAggregator\n | MinAggregator\n | SumAggregator\n | StaticValueAggregator {\n switch (aggregateType) {\n case \"Average\":\n return new AverageAggregator();\n case \"Count\":\n return new CountAggregator();\n case \"Max\":\n return new MaxAggregator();\n case \"Min\":\n return new MinAggregator();\n case \"Sum\":\n return new SumAggregator();\n default:\n return new StaticValueAggregator();\n }\n}\n\nexport { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator };\nexport { Aggregator } from \"./Aggregator\";\n"]}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export interface CosmosHeaders {
|
||||
[key: string]: string | boolean | number;
|
||||
}
|
||||
//# sourceMappingURL=CosmosHeaders.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CosmosHeaders.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/CosmosHeaders.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CAC1C"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=CosmosHeaders.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CosmosHeaders.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/CosmosHeaders.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface CosmosHeaders {\n [key: string]: string | boolean | number;\n}\n"]}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { QueryOperationOptions, Response } from "../../request";
|
||||
import { ExecutionContext } from "../ExecutionContext";
|
||||
import { QueryInfo } from "../../request/ErrorResponse";
|
||||
import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal";
|
||||
import { RUConsumedManager } from "../../common";
|
||||
/** @hidden */
|
||||
export declare class GroupByEndpointComponent implements ExecutionContext {
|
||||
private executionContext;
|
||||
private queryInfo;
|
||||
constructor(executionContext: ExecutionContext, queryInfo: QueryInfo);
|
||||
private readonly groupings;
|
||||
private readonly aggregateResultArray;
|
||||
private completed;
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
hasMoreResults(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=GroupByEndpointComponent.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GroupByEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAKxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAYjD,cAAc;AACd,qBAAa,wBAAyB,YAAW,gBAAgB;IAE7D,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,SAAS;gBADT,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS;IAG9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmD;IAC7E,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAa;IAClD,OAAO,CAAC,SAAS,CAAkB;IAEtB,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAmFlB,cAAc,IAAI,OAAO;CAGjC"}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
import { hashObject } from "../../utils/hashObject";
|
||||
import { createAggregator } from "../Aggregators";
|
||||
import { getInitialHeader, mergeHeaders } from "../headerUtils";
|
||||
import { emptyGroup, extractAggregateResult } from "./emptyGroup";
|
||||
import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError";
|
||||
/** @hidden */
|
||||
export class GroupByEndpointComponent {
|
||||
constructor(executionContext, queryInfo) {
|
||||
this.executionContext = executionContext;
|
||||
this.queryInfo = queryInfo;
|
||||
this.groupings = new Map();
|
||||
this.aggregateResultArray = [];
|
||||
this.completed = false;
|
||||
}
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
// If we have a full result set, begin returning results
|
||||
if (this.aggregateResultArray.length > 0) {
|
||||
return {
|
||||
result: this.aggregateResultArray.pop(),
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
if (this.completed) {
|
||||
return {
|
||||
result: undefined,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
const aggregateHeaders = getInitialHeader();
|
||||
try {
|
||||
while (this.executionContext.hasMoreResults()) {
|
||||
// Grab the next result
|
||||
const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager));
|
||||
mergeHeaders(aggregateHeaders, headers);
|
||||
// If it exists, process it via aggregators
|
||||
if (result) {
|
||||
const group = result.groupByItems ? await hashObject(result.groupByItems) : emptyGroup;
|
||||
const aggregators = this.groupings.get(group);
|
||||
const payload = result.payload;
|
||||
if (aggregators) {
|
||||
// Iterator over all results in the payload
|
||||
Object.keys(payload).map((key) => {
|
||||
// in case the value of a group is null make sure we create a dummy payload with item2==null
|
||||
const effectiveGroupByValue = payload[key]
|
||||
? payload[key]
|
||||
: new Map().set("item2", null);
|
||||
const aggregateResult = extractAggregateResult(effectiveGroupByValue);
|
||||
aggregators.get(key).aggregate(aggregateResult);
|
||||
});
|
||||
}
|
||||
else {
|
||||
// This is the first time we have seen a grouping. Setup the initial result without aggregate values
|
||||
const grouping = new Map();
|
||||
this.groupings.set(group, grouping);
|
||||
// Iterator over all results in the payload
|
||||
Object.keys(payload).map((key) => {
|
||||
const aggregateType = this.queryInfo.groupByAliasToAggregateType[key];
|
||||
// Create a new aggregator for this specific aggregate field
|
||||
const aggregator = createAggregator(aggregateType);
|
||||
grouping.set(key, aggregator);
|
||||
if (aggregateType) {
|
||||
const aggregateResult = extractAggregateResult(payload[key]);
|
||||
aggregator.aggregate(aggregateResult);
|
||||
}
|
||||
else {
|
||||
aggregator.aggregate(payload[key]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === RUCapPerOperationExceededErrorCode) {
|
||||
err.fetchedResults = undefined;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
for (const grouping of this.groupings.values()) {
|
||||
const groupResult = {};
|
||||
for (const [aggregateKey, aggregator] of grouping.entries()) {
|
||||
groupResult[aggregateKey] = aggregator.getResult();
|
||||
}
|
||||
this.aggregateResultArray.push(groupResult);
|
||||
}
|
||||
this.completed = true;
|
||||
return {
|
||||
result: this.aggregateResultArray.pop(),
|
||||
headers: aggregateHeaders,
|
||||
};
|
||||
}
|
||||
hasMoreResults() {
|
||||
return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GroupByEndpointComponent.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+18
@@ -0,0 +1,18 @@
|
||||
import { QueryOperationOptions, Response } from "../../request";
|
||||
import { ExecutionContext } from "../ExecutionContext";
|
||||
import { QueryInfo } from "../../request/ErrorResponse";
|
||||
import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal";
|
||||
import { RUConsumedManager } from "../../common";
|
||||
/** @hidden */
|
||||
export declare class GroupByValueEndpointComponent implements ExecutionContext {
|
||||
private executionContext;
|
||||
private queryInfo;
|
||||
private readonly aggregators;
|
||||
private readonly aggregateResultArray;
|
||||
private aggregateType;
|
||||
private completed;
|
||||
constructor(executionContext: ExecutionContext, queryInfo: QueryInfo);
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
hasMoreResults(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=GroupByValueEndpointComponent.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GroupByValueEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAiB,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAKvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAYjD,cAAc;AACd,qBAAa,6BAA8B,YAAW,gBAAgB;IAOlE,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,SAAS;IAPnB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsC;IAClE,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAa;IAClD,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,SAAS,CAAkB;gBAGzB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS;IAMjB,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAkFlB,cAAc,IAAI,OAAO;CAGjC"}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
import { hashObject } from "../../utils/hashObject";
|
||||
import { createAggregator } from "../Aggregators";
|
||||
import { getInitialHeader, mergeHeaders } from "../headerUtils";
|
||||
import { emptyGroup, extractAggregateResult } from "./emptyGroup";
|
||||
import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError";
|
||||
/** @hidden */
|
||||
export class GroupByValueEndpointComponent {
|
||||
constructor(executionContext, queryInfo) {
|
||||
this.executionContext = executionContext;
|
||||
this.queryInfo = queryInfo;
|
||||
this.aggregators = new Map();
|
||||
this.aggregateResultArray = [];
|
||||
this.completed = false;
|
||||
// VALUE queries will only every have a single grouping
|
||||
this.aggregateType = this.queryInfo.aggregates[0];
|
||||
}
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
// Start returning results if we have processed a full results set
|
||||
if (this.aggregateResultArray.length > 0) {
|
||||
return {
|
||||
result: this.aggregateResultArray.pop(),
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
if (this.completed) {
|
||||
return {
|
||||
result: undefined,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
const aggregateHeaders = getInitialHeader();
|
||||
try {
|
||||
while (this.executionContext.hasMoreResults()) {
|
||||
// Grab the next result
|
||||
const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager));
|
||||
mergeHeaders(aggregateHeaders, headers);
|
||||
// If it exists, process it via aggregators
|
||||
if (result) {
|
||||
let grouping = emptyGroup;
|
||||
let payload = result;
|
||||
if (result.groupByItems) {
|
||||
// If the query contains a GROUP BY clause, it will have a payload property and groupByItems
|
||||
payload = result.payload;
|
||||
grouping = await hashObject(result.groupByItems);
|
||||
}
|
||||
const aggregator = this.aggregators.get(grouping);
|
||||
if (!aggregator) {
|
||||
// This is the first time we have seen a grouping so create a new aggregator
|
||||
this.aggregators.set(grouping, createAggregator(this.aggregateType));
|
||||
}
|
||||
if (this.aggregateType) {
|
||||
const aggregateResult = extractAggregateResult(payload[0]);
|
||||
// if aggregate result is null, we need to short circuit aggregation and return undefined
|
||||
if (aggregateResult === null) {
|
||||
this.completed = true;
|
||||
}
|
||||
this.aggregators.get(grouping).aggregate(aggregateResult);
|
||||
}
|
||||
else {
|
||||
// Queries with no aggregates pass the payload directly to the aggregator
|
||||
// Example: SELECT VALUE c.team FROM c GROUP BY c.team
|
||||
this.aggregators.get(grouping).aggregate(payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === RUCapPerOperationExceededErrorCode) {
|
||||
err.fetchedResults = undefined;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
// We bail early since we got an undefined result back `[{}]`
|
||||
if (this.completed) {
|
||||
return {
|
||||
result: undefined,
|
||||
headers: aggregateHeaders,
|
||||
};
|
||||
}
|
||||
// If no results are left in the underlying execution context, convert our aggregate results to an array
|
||||
for (const aggregator of this.aggregators.values()) {
|
||||
this.aggregateResultArray.push(aggregator.getResult());
|
||||
}
|
||||
this.completed = true;
|
||||
return {
|
||||
result: this.aggregateResultArray.pop(),
|
||||
headers: aggregateHeaders,
|
||||
};
|
||||
}
|
||||
hasMoreResults() {
|
||||
return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GroupByValueEndpointComponent.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+23
@@ -0,0 +1,23 @@
|
||||
import { QueryInfo, QueryOperationOptions, Response } from "../../request";
|
||||
import { ExecutionContext } from "../ExecutionContext";
|
||||
import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal";
|
||||
import { RUConsumedManager } from "../../common";
|
||||
/** @hidden */
|
||||
export declare class NonStreamingOrderByDistinctEndpointComponent implements ExecutionContext {
|
||||
private executionContext;
|
||||
private queryInfo;
|
||||
private priorityQueueBufferSize;
|
||||
private aggregateMap;
|
||||
private nonStreamingOrderByPQ;
|
||||
private finalResultArray;
|
||||
private sortOrders;
|
||||
private isCompleted;
|
||||
constructor(executionContext: ExecutionContext, queryInfo: QueryInfo, priorityQueueBufferSize: number);
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
/**
|
||||
* Build final sorted result array from which responses will be served.
|
||||
*/
|
||||
private buildFinalResultArray;
|
||||
hasMoreResults(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=NonStreamingOrderByDistinctEndpointComponent.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"NonStreamingOrderByDistinctEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOjD,cAAc;AACd,qBAAa,4CAA6C,YAAW,gBAAgB;IAQjF,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,uBAAuB;IATjC,OAAO,CAAC,YAAY,CAAoD;IACxE,OAAO,CAAC,qBAAqB,CAA8D;IAC3F,OAAO,CAAC,gBAAgB,CAA8B;IACtD,OAAO,CAAC,UAAU,CAAW;IAC7B,OAAO,CAAC,WAAW,CAAkB;gBAG3B,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,uBAAuB,EAAE,MAAM;IAiB5B,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAkDzB;;OAEG;YACW,qBAAqB;IAoB5B,cAAc,IAAI,OAAO;CAIjC"}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
import { getInitialHeader } from "../headerUtils";
|
||||
import { hashObject } from "../../utils/hashObject";
|
||||
import { NonStreamingOrderByPriorityQueue } from "../../utils/nonStreamingOrderByPriorityQueue";
|
||||
import { NonStreamingOrderByMap } from "../../utils/nonStreamingOrderByMap";
|
||||
import { OrderByComparator } from "../orderByComparator";
|
||||
/** @hidden */
|
||||
export class NonStreamingOrderByDistinctEndpointComponent {
|
||||
constructor(executionContext, queryInfo, priorityQueueBufferSize) {
|
||||
this.executionContext = executionContext;
|
||||
this.queryInfo = queryInfo;
|
||||
this.priorityQueueBufferSize = priorityQueueBufferSize;
|
||||
this.isCompleted = false;
|
||||
this.sortOrders = this.queryInfo.orderBy;
|
||||
const comparator = new OrderByComparator(this.sortOrders);
|
||||
this.aggregateMap = new NonStreamingOrderByMap((a, b) => {
|
||||
return comparator.compareItems(a, b);
|
||||
});
|
||||
this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue((a, b) => {
|
||||
return comparator.compareItems(b, a);
|
||||
}, this.priorityQueueBufferSize);
|
||||
}
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
// if size is 0, just return undefined. Valid if query is TOP 0 or LIMIT 0
|
||||
if (this.priorityQueueBufferSize === 0) {
|
||||
return {
|
||||
result: undefined,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
let resHeaders = getInitialHeader();
|
||||
if (!this.isCompleted && this.executionContext.hasMoreResults()) {
|
||||
// Grab the next result
|
||||
const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager));
|
||||
resHeaders = headers;
|
||||
if (result) {
|
||||
// make hash of result object and update the map if required.
|
||||
const key = await hashObject(result === null || result === void 0 ? void 0 : result.payload);
|
||||
this.aggregateMap.set(key, result);
|
||||
}
|
||||
if (!this.executionContext.hasMoreResults()) {
|
||||
this.isCompleted = true;
|
||||
await this.buildFinalResultArray();
|
||||
}
|
||||
}
|
||||
if (this.isCompleted) {
|
||||
// start returning the results if final result is computed.
|
||||
if (this.finalResultArray.length > 0) {
|
||||
return {
|
||||
result: this.finalResultArray.shift(),
|
||||
headers: resHeaders,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
result: undefined,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
// keep returning empty till final results are getting computed.
|
||||
return {
|
||||
result: {},
|
||||
headers: resHeaders,
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Build final sorted result array from which responses will be served.
|
||||
*/
|
||||
async buildFinalResultArray() {
|
||||
var _a;
|
||||
const allValues = this.aggregateMap.getAllValues();
|
||||
for (const value of allValues) {
|
||||
this.nonStreamingOrderByPQ.enqueue(value);
|
||||
}
|
||||
const offSet = this.queryInfo.offset ? this.queryInfo.offset : 0;
|
||||
const queueSize = this.nonStreamingOrderByPQ.size();
|
||||
const finalArraySize = queueSize - offSet;
|
||||
if (finalArraySize <= 0) {
|
||||
this.finalResultArray = [];
|
||||
}
|
||||
else {
|
||||
this.finalResultArray = new Array(finalArraySize);
|
||||
for (let count = finalArraySize - 1; count >= 0; count--) {
|
||||
this.finalResultArray[count] = (_a = this.nonStreamingOrderByPQ.dequeue()) === null || _a === void 0 ? void 0 : _a.payload;
|
||||
}
|
||||
}
|
||||
}
|
||||
hasMoreResults() {
|
||||
if (this.priorityQueueBufferSize === 0)
|
||||
return false;
|
||||
return this.executionContext.hasMoreResults() || this.finalResultArray.length > 0;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=NonStreamingOrderByDistinctEndpointComponent.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+27
@@ -0,0 +1,27 @@
|
||||
import { RUConsumedManager } from "../../common/RUConsumedManager";
|
||||
import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal";
|
||||
import { QueryOperationOptions, Response } from "../../request";
|
||||
import { ExecutionContext } from "../ExecutionContext";
|
||||
export declare class NonStreamingOrderByEndpointComponent implements ExecutionContext {
|
||||
private executionContext;
|
||||
private sortOrders;
|
||||
private priorityQueueBufferSize;
|
||||
private offset;
|
||||
private nonStreamingOrderByPQ;
|
||||
private isCompleted;
|
||||
/**
|
||||
* Represents an endpoint in handling an non-streaming order by query. For each processed orderby
|
||||
* result it returns 'payload' item of the result
|
||||
*
|
||||
* @param executionContext - Underlying Execution Context
|
||||
* @hidden
|
||||
*/
|
||||
constructor(executionContext: ExecutionContext, sortOrders: any[], priorityQueueBufferSize?: number, offset?: number);
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
/**
|
||||
* Determine if there are still remaining resources to processs.
|
||||
* @returns true if there is other elements to process in the NonStreamingOrderByEndpointComponent.
|
||||
*/
|
||||
hasMoreResults(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=NonStreamingOrderByEndpointComponent.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"NonStreamingOrderByEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAMvD,qBAAa,oCAAqC,YAAW,gBAAgB;IAWzE,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,uBAAuB;IAC/B,OAAO,CAAC,MAAM;IAbhB,OAAO,CAAC,qBAAqB,CAA8D;IAC3F,OAAO,CAAC,WAAW,CAAkB;IACrC;;;;;;OAMG;gBAEO,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,GAAG,EAAE,EACjB,uBAAuB,GAAE,MAAa,EACtC,MAAM,GAAE,MAAU;IAWf,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAgEzB;;;OAGG;IACI,cAAc,IAAI,OAAO;CAMjC"}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
import { OrderByComparator } from "../orderByComparator";
|
||||
import { NonStreamingOrderByPriorityQueue } from "../../utils/nonStreamingOrderByPriorityQueue";
|
||||
import { getInitialHeader } from "../headerUtils";
|
||||
import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError";
|
||||
export class NonStreamingOrderByEndpointComponent {
|
||||
/**
|
||||
* Represents an endpoint in handling an non-streaming order by query. For each processed orderby
|
||||
* result it returns 'payload' item of the result
|
||||
*
|
||||
* @param executionContext - Underlying Execution Context
|
||||
* @hidden
|
||||
*/
|
||||
constructor(executionContext, sortOrders, priorityQueueBufferSize = 2000, offset = 0) {
|
||||
this.executionContext = executionContext;
|
||||
this.sortOrders = sortOrders;
|
||||
this.priorityQueueBufferSize = priorityQueueBufferSize;
|
||||
this.offset = offset;
|
||||
this.isCompleted = false;
|
||||
const comparator = new OrderByComparator(this.sortOrders);
|
||||
this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue((a, b) => {
|
||||
return comparator.compareItems(b, a);
|
||||
}, this.priorityQueueBufferSize);
|
||||
}
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
var _a, _b;
|
||||
if (this.priorityQueueBufferSize <= 0 ||
|
||||
(this.isCompleted && this.nonStreamingOrderByPQ.isEmpty())) {
|
||||
return {
|
||||
result: undefined,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
if (this.isCompleted && !this.nonStreamingOrderByPQ.isEmpty()) {
|
||||
const item = (_a = this.nonStreamingOrderByPQ.dequeue()) === null || _a === void 0 ? void 0 : _a.payload;
|
||||
return {
|
||||
result: item,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
try {
|
||||
if (this.executionContext.hasMoreResults()) {
|
||||
const { result: item, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
if (item !== undefined) {
|
||||
this.nonStreamingOrderByPQ.enqueue(item);
|
||||
}
|
||||
return {
|
||||
result: {},
|
||||
headers,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this.isCompleted = true;
|
||||
// Reverse the priority queue to get the results in the correct order
|
||||
this.nonStreamingOrderByPQ = this.nonStreamingOrderByPQ.reverse();
|
||||
// For offset limit case we set the size of priority queue to offset + limit
|
||||
// and we drain offset number of items from the priority queue
|
||||
while (this.offset < this.priorityQueueBufferSize && this.offset > 0) {
|
||||
this.nonStreamingOrderByPQ.dequeue();
|
||||
this.offset--;
|
||||
}
|
||||
if (this.nonStreamingOrderByPQ.size() !== 0) {
|
||||
const item = (_b = this.nonStreamingOrderByPQ.dequeue()) === null || _b === void 0 ? void 0 : _b.payload;
|
||||
return {
|
||||
result: item,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
result: undefined,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === RUCapPerOperationExceededErrorCode) {
|
||||
err.fetchedResults = undefined;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determine if there are still remaining resources to processs.
|
||||
* @returns true if there is other elements to process in the NonStreamingOrderByEndpointComponent.
|
||||
*/
|
||||
hasMoreResults() {
|
||||
return (this.priorityQueueBufferSize > 0 &&
|
||||
(this.executionContext.hasMoreResults() || this.nonStreamingOrderByPQ.size() !== 0));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=NonStreamingOrderByEndpointComponent.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+14
@@ -0,0 +1,14 @@
|
||||
import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal";
|
||||
import { QueryOperationOptions, Response } from "../../request";
|
||||
import { ExecutionContext } from "../ExecutionContext";
|
||||
import { RUConsumedManager } from "../../common";
|
||||
/** @hidden */
|
||||
export declare class OffsetLimitEndpointComponent implements ExecutionContext {
|
||||
private executionContext;
|
||||
private offset;
|
||||
private limit;
|
||||
constructor(executionContext: ExecutionContext, offset: number, limit: number);
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
hasMoreResults(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=OffsetLimitEndpointComponent.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OffsetLimitEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd,qBAAa,4BAA6B,YAAW,gBAAgB;IAEjE,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;gBAFL,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM;IAGV,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAoClB,cAAc,IAAI,OAAO;CAGjC"}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError";
|
||||
import { getInitialHeader, mergeHeaders } from "../headerUtils";
|
||||
/** @hidden */
|
||||
export class OffsetLimitEndpointComponent {
|
||||
constructor(executionContext, offset, limit) {
|
||||
this.executionContext = executionContext;
|
||||
this.offset = offset;
|
||||
this.limit = limit;
|
||||
}
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
const aggregateHeaders = getInitialHeader();
|
||||
try {
|
||||
while (this.offset > 0) {
|
||||
// Grab next item but ignore the result. We only need the headers
|
||||
const { headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
this.offset--;
|
||||
mergeHeaders(aggregateHeaders, headers);
|
||||
}
|
||||
if (this.limit > 0) {
|
||||
const { result, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
this.limit--;
|
||||
mergeHeaders(aggregateHeaders, headers);
|
||||
return { result, headers: aggregateHeaders };
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === RUCapPerOperationExceededErrorCode) {
|
||||
err.fetchedResults = undefined;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
// If both limit and offset are 0, return nothing
|
||||
return {
|
||||
result: undefined,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
hasMoreResults() {
|
||||
return (this.offset > 0 || this.limit > 0) && this.executionContext.hasMoreResults();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=OffsetLimitEndpointComponent.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OffsetLimitEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGhE,cAAc;AACd,MAAM,OAAO,4BAA4B;IACvC,YACU,gBAAkC,EAClC,MAAc,EACd,KAAa;QAFb,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,WAAM,GAAN,MAAM,CAAQ;QACd,UAAK,GAAL,KAAK,CAAQ;IACpB,CAAC;IAEG,KAAK,CAAC,QAAQ,CACnB,cAAsC,EACtC,gBAAwC,EACxC,iBAAqC;QAErC,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;QAC5C,IAAI;YACF,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;gBACtB,iEAAiE;gBACjE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CACtD,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;gBACF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACd,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;aACzC;YACD,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE;gBAClB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC9D,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;gBACF,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;gBACxC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;aAC9C;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;QACD,iDAAiD;QACjD,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,gBAAgB,EAAE;SAC5B,CAAC;IACJ,CAAC;IAEM,cAAc;QACnB,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IACvF,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OffsetLimitEndpointComponent implements ExecutionContext {\n constructor(\n private executionContext: ExecutionContext,\n private offset: number,\n private limit: number,\n ) {}\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise<Response<any>> {\n const aggregateHeaders = getInitialHeader();\n try {\n while (this.offset > 0) {\n // Grab next item but ignore the result. We only need the headers\n const { headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this.offset--;\n mergeHeaders(aggregateHeaders, headers);\n }\n if (this.limit > 0) {\n const { result, headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this.limit--;\n mergeHeaders(aggregateHeaders, headers);\n return { result, headers: aggregateHeaders };\n }\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n // If both limit and offset are 0, return nothing\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n public hasMoreResults(): boolean {\n return (this.offset > 0 || this.limit > 0) && this.executionContext.hasMoreResults();\n }\n}\n"]}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal";
|
||||
import { QueryOperationOptions, Response } from "../../request";
|
||||
import { ExecutionContext } from "../ExecutionContext";
|
||||
import { RUConsumedManager } from "../../common";
|
||||
/** @hidden */
|
||||
export declare class OrderByEndpointComponent implements ExecutionContext {
|
||||
private executionContext;
|
||||
/**
|
||||
* Represents an endpoint in handling an order by query. For each processed orderby
|
||||
* result it returns 'payload' item of the result
|
||||
*
|
||||
* @param executionContext - Underlying Execution Context
|
||||
* @hidden
|
||||
*/
|
||||
constructor(executionContext: ExecutionContext);
|
||||
/**
|
||||
* Execute a provided function on the next element in the OrderByEndpointComponent.
|
||||
*/
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
/**
|
||||
* Determine if there are still remaining resources to processs.
|
||||
* @returns true if there is other elements to process in the OrderByEndpointComponent.
|
||||
*/
|
||||
hasMoreResults(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=OrderByEndpointComponent.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OrderByEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd,qBAAa,wBAAyB,YAAW,gBAAgB;IAQnD,OAAO,CAAC,gBAAgB;IAPpC;;;;;;OAMG;gBACiB,gBAAgB,EAAE,gBAAgB;IACtD;;OAEG;IACU,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAmBzB;;;OAGG;IACI,cAAc,IAAI,OAAO;CAGjC"}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError";
|
||||
/** @hidden */
|
||||
export class OrderByEndpointComponent {
|
||||
/**
|
||||
* Represents an endpoint in handling an order by query. For each processed orderby
|
||||
* result it returns 'payload' item of the result
|
||||
*
|
||||
* @param executionContext - Underlying Execution Context
|
||||
* @hidden
|
||||
*/
|
||||
constructor(executionContext) {
|
||||
this.executionContext = executionContext;
|
||||
}
|
||||
/**
|
||||
* Execute a provided function on the next element in the OrderByEndpointComponent.
|
||||
*/
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
try {
|
||||
const { result: item, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
return {
|
||||
result: item !== undefined ? item.payload : undefined,
|
||||
headers,
|
||||
};
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === RUCapPerOperationExceededErrorCode) {
|
||||
err.fetchedResults = undefined;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determine if there are still remaining resources to processs.
|
||||
* @returns true if there is other elements to process in the OrderByEndpointComponent.
|
||||
*/
|
||||
hasMoreResults() {
|
||||
return this.executionContext.hasMoreResults();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=OrderByEndpointComponent.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OrderByEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAIlG,cAAc;AACd,MAAM,OAAO,wBAAwB;IACnC;;;;;;OAMG;IACH,YAAoB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAC1D;;OAEG;IACI,KAAK,CAAC,QAAQ,CACnB,cAAsC,EACtC,gBAAwC,EACxC,iBAAqC;QAErC,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CACpE,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;YACF,OAAO;gBACL,MAAM,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBACrD,OAAO;aACR,CAAC;SACH;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAED;;;OAGG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OrderByEndpointComponent implements ExecutionContext {\n /**\n * Represents an endpoint in handling an order by query. For each processed orderby\n * result it returns 'payload' item of the result\n *\n * @param executionContext - Underlying Execution Context\n * @hidden\n */\n constructor(private executionContext: ExecutionContext) {}\n /**\n * Execute a provided function on the next element in the OrderByEndpointComponent.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise<Response<any>> {\n try {\n const { result: item, headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n return {\n result: item !== undefined ? item.payload : undefined,\n headers,\n };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n /**\n * Determine if there are still remaining resources to processs.\n * @returns true if there is other elements to process in the OrderByEndpointComponent.\n */\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n"]}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { QueryOperationOptions, Response } from "../../request";
|
||||
import { ExecutionContext } from "../ExecutionContext";
|
||||
import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal";
|
||||
import { RUConsumedManager } from "../../common";
|
||||
/** @hidden */
|
||||
export declare class OrderedDistinctEndpointComponent implements ExecutionContext {
|
||||
private executionContext;
|
||||
private hashedLastResult;
|
||||
constructor(executionContext: ExecutionContext);
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
hasMoreResults(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=OrderedDistinctEndpointComponent.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OrderedDistinctEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd,qBAAa,gCAAiC,YAAW,gBAAgB;IAE3D,OAAO,CAAC,gBAAgB;IADpC,OAAO,CAAC,gBAAgB,CAAS;gBACb,gBAAgB,EAAE,gBAAgB;IAEzC,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAuBlB,cAAc,IAAI,OAAO;CAGjC"}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { hashObject } from "../../utils/hashObject";
|
||||
import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError";
|
||||
/** @hidden */
|
||||
export class OrderedDistinctEndpointComponent {
|
||||
constructor(executionContext) {
|
||||
this.executionContext = executionContext;
|
||||
}
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
try {
|
||||
const { headers, result } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
if (result) {
|
||||
const hashedResult = await hashObject(result);
|
||||
if (hashedResult === this.hashedLastResult) {
|
||||
return { result: undefined, headers };
|
||||
}
|
||||
this.hashedLastResult = hashedResult;
|
||||
}
|
||||
return { result, headers };
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === RUCapPerOperationExceededErrorCode) {
|
||||
err.fetchedResults = undefined;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
hasMoreResults() {
|
||||
return this.executionContext.hasMoreResults();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=OrderedDistinctEndpointComponent.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OrderedDistinctEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAGlG,cAAc;AACd,MAAM,OAAO,gCAAgC;IAE3C,YAAoB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAEnD,KAAK,CAAC,QAAQ,CACnB,cAAsC,EACtC,gBAAwC,EACxC,iBAAqC;QAErC,IAAI;YACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC9D,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;YACF,IAAI,MAAM,EAAE;gBACV,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC9C,IAAI,YAAY,KAAK,IAAI,CAAC,gBAAgB,EAAE;oBAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;iBACvC;gBACD,IAAI,CAAC,gBAAgB,GAAG,YAAY,CAAC;aACtC;YACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;SAC5B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OrderedDistinctEndpointComponent implements ExecutionContext {\n private hashedLastResult: string;\n constructor(private executionContext: ExecutionContext) {}\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise<Response<any>> {\n try {\n const { headers, result } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n if (result) {\n const hashedResult = await hashObject(result);\n if (hashedResult === this.hashedLastResult) {\n return { result: undefined, headers };\n }\n this.hashedLastResult = hashedResult;\n }\n return { result, headers };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n"]}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { QueryOperationOptions, Response } from "../../request";
|
||||
import { ExecutionContext } from "../ExecutionContext";
|
||||
import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal";
|
||||
import { RUConsumedManager } from "../../common";
|
||||
/** @hidden */
|
||||
export declare class UnorderedDistinctEndpointComponent implements ExecutionContext {
|
||||
private executionContext;
|
||||
private hashedResults;
|
||||
constructor(executionContext: ExecutionContext);
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
hasMoreResults(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=UnorderedDistinctEndpointComponent.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"UnorderedDistinctEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd,qBAAa,kCAAmC,YAAW,gBAAgB;IAE7D,OAAO,CAAC,gBAAgB;IADpC,OAAO,CAAC,aAAa,CAAc;gBACf,gBAAgB,EAAE,gBAAgB;IAIzC,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAuBlB,cAAc,IAAI,OAAO;CAGjC"}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import { hashObject } from "../../utils/hashObject";
|
||||
import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError";
|
||||
/** @hidden */
|
||||
export class UnorderedDistinctEndpointComponent {
|
||||
constructor(executionContext) {
|
||||
this.executionContext = executionContext;
|
||||
this.hashedResults = new Set();
|
||||
}
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
try {
|
||||
const { headers, result } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
if (result) {
|
||||
const hashedResult = await hashObject(result);
|
||||
if (this.hashedResults.has(hashedResult)) {
|
||||
return { result: undefined, headers };
|
||||
}
|
||||
this.hashedResults.add(hashedResult);
|
||||
}
|
||||
return { result, headers };
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === RUCapPerOperationExceededErrorCode) {
|
||||
err.fetchedResults = undefined;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
hasMoreResults() {
|
||||
return this.executionContext.hasMoreResults();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=UnorderedDistinctEndpointComponent.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"UnorderedDistinctEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAGlG,cAAc;AACd,MAAM,OAAO,kCAAkC;IAE7C,YAAoB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;QACpD,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,QAAQ,CACnB,cAAsC,EACtC,gBAAwC,EACxC,iBAAqC;QAErC,IAAI;YACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC9D,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;YACF,IAAI,MAAM,EAAE;gBACV,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC9C,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;oBACxC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;iBACvC;gBACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;aACtC;YACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;SAC5B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class UnorderedDistinctEndpointComponent implements ExecutionContext {\n private hashedResults: Set<string>;\n constructor(private executionContext: ExecutionContext) {\n this.hashedResults = new Set();\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise<Response<any>> {\n try {\n const { headers, result } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n if (result) {\n const hashedResult = await hashObject(result);\n if (this.hashedResults.has(hashedResult)) {\n return { result: undefined, headers };\n }\n this.hashedResults.add(hashedResult);\n }\n return { result, headers };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n"]}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export declare const emptyGroup = "__empty__";
|
||||
export declare const extractAggregateResult: (payload: {
|
||||
item2?: unknown;
|
||||
item: unknown;
|
||||
}) => any;
|
||||
//# sourceMappingURL=emptyGroup.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emptyGroup.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/emptyGroup.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,cAAc,CAAC;AAItC,eAAO,MAAM,sBAAsB,YAAa;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,KAAG,GACI,CAAC"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
// All aggregates are effectively a group by operation
|
||||
// The empty group is used for aggregates without a GROUP BY clause
|
||||
export const emptyGroup = "__empty__";
|
||||
// Newer API versions rewrite the query to return `item2`. It fixes some legacy issues with the original `item` result
|
||||
// Aggregator code should use item2 when available
|
||||
export const extractAggregateResult = (payload) => Object.keys(payload).length > 0 ? (payload.item2 ? payload.item2 : payload.item) : null;
|
||||
//# sourceMappingURL=emptyGroup.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"emptyGroup.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/emptyGroup.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,sDAAsD;AACtD,mEAAmE;AACnE,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;AAEtC,sHAAsH;AACtH,kDAAkD;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAA2C,EAAO,EAAE,CACzF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// All aggregates are effectively a group by operation\n// The empty group is used for aggregates without a GROUP BY clause\nexport const emptyGroup = \"__empty__\";\n\n// Newer API versions rewrite the query to return `item2`. It fixes some legacy issues with the original `item` result\n// Aggregator code should use item2 when available\nexport const extractAggregateResult = (payload: { item2?: unknown; item: unknown }): any =>\n Object.keys(payload).length > 0 ? (payload.item2 ? payload.item2 : payload.item) : null;\n"]}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal";
|
||||
import { QueryOperationOptions, Response } from "../request";
|
||||
import { RUConsumedManager } from "../common";
|
||||
/** @hidden */
|
||||
export interface ExecutionContext {
|
||||
nextItem: (diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumed?: RUConsumedManager) => Promise<Response<any>>;
|
||||
hasMoreResults: () => boolean;
|
||||
fetchMore?: (diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumed?: RUConsumedManager) => Promise<Response<any>>;
|
||||
}
|
||||
//# sourceMappingURL=ExecutionContext.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/ExecutionContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,cAAc;AACd,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,CACR,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,UAAU,CAAC,EAAE,iBAAiB,KAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,cAAc,EAAE,MAAM,OAAO,CAAC;IAC9B,SAAS,CAAC,EAAE,CACV,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,UAAU,CAAC,EAAE,iBAAiB,KAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7B"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=ExecutionContext.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ExecutionContext.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/ExecutionContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../request\";\nimport { RUConsumedManager } from \"../common\";\n\n/** @hidden */\nexport interface ExecutionContext {\n nextItem: (\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumed?: RUConsumedManager,\n ) => Promise<Response<any>>;\n hasMoreResults: () => boolean;\n fetchMore?: (\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumed?: RUConsumedManager,\n ) => Promise<Response<any>>; // TODO: code smell\n}\n"]}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/** @hidden */
|
||||
export declare enum FetchResultType {
|
||||
"Done" = 0,
|
||||
"Exception" = 1,
|
||||
"Result" = 2
|
||||
}
|
||||
/** @hidden */
|
||||
export declare class FetchResult {
|
||||
feedResponse: any;
|
||||
fetchResultType: FetchResultType;
|
||||
error: any;
|
||||
/**
|
||||
* Wraps fetch results for the document producer.
|
||||
* This allows the document producer to buffer exceptions so that actual results don't get flushed during splits.
|
||||
*
|
||||
* @param feedReponse - The response the document producer got back on a successful fetch
|
||||
* @param error - The exception meant to be buffered on an unsuccessful fetch
|
||||
* @hidden
|
||||
*/
|
||||
constructor(feedResponse: unknown, error: unknown);
|
||||
}
|
||||
//# sourceMappingURL=FetchResult.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FetchResult.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/FetchResult.ts"],"names":[],"mappings":"AAEA,cAAc;AACd,oBAAY,eAAe;IACzB,MAAM,IAAI;IACV,WAAW,IAAI;IACf,QAAQ,IAAI;CACb;AAED,cAAc;AACd,qBAAa,WAAW;IACf,YAAY,EAAE,GAAG,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,EAAE,GAAG,CAAC;IAClB;;;;;;;OAOG;gBACS,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;CAUlD"}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/** @hidden */
|
||||
export var FetchResultType;
|
||||
(function (FetchResultType) {
|
||||
FetchResultType[FetchResultType["Done"] = 0] = "Done";
|
||||
FetchResultType[FetchResultType["Exception"] = 1] = "Exception";
|
||||
FetchResultType[FetchResultType["Result"] = 2] = "Result";
|
||||
})(FetchResultType || (FetchResultType = {}));
|
||||
/** @hidden */
|
||||
export class FetchResult {
|
||||
/**
|
||||
* Wraps fetch results for the document producer.
|
||||
* This allows the document producer to buffer exceptions so that actual results don't get flushed during splits.
|
||||
*
|
||||
* @param feedReponse - The response the document producer got back on a successful fetch
|
||||
* @param error - The exception meant to be buffered on an unsuccessful fetch
|
||||
* @hidden
|
||||
*/
|
||||
constructor(feedResponse, error) {
|
||||
// TODO: feedResponse/error
|
||||
if (feedResponse !== undefined) {
|
||||
this.feedResponse = feedResponse;
|
||||
this.fetchResultType = FetchResultType.Result;
|
||||
}
|
||||
else {
|
||||
this.error = error;
|
||||
this.fetchResultType = FetchResultType.Exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=FetchResult.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FetchResult.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/FetchResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc;AACd,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,qDAAU,CAAA;IACV,+DAAe,CAAA;IACf,yDAAY,CAAA;AACd,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED,cAAc;AACd,MAAM,OAAO,WAAW;IAItB;;;;;;;OAOG;IACH,YAAY,YAAqB,EAAE,KAAc;QAC/C,2BAA2B;QAC3B,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;YACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC;SAC/C;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC,SAAS,CAAC;SAClD;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** @hidden */\nexport enum FetchResultType {\n \"Done\" = 0,\n \"Exception\" = 1,\n \"Result\" = 2,\n}\n\n/** @hidden */\nexport class FetchResult {\n public feedResponse: any;\n public fetchResultType: FetchResultType;\n public error: any;\n /**\n * Wraps fetch results for the document producer.\n * This allows the document producer to buffer exceptions so that actual results don't get flushed during splits.\n *\n * @param feedReponse - The response the document producer got back on a successful fetch\n * @param error - The exception meant to be buffered on an unsuccessful fetch\n * @hidden\n */\n constructor(feedResponse: unknown, error: unknown) {\n // TODO: feedResponse/error\n if (feedResponse !== undefined) {\n this.feedResponse = feedResponse;\n this.fetchResultType = FetchResultType.Result;\n } else {\n this.error = error;\n this.fetchResultType = FetchResultType.Exception;\n }\n }\n}\n"]}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Represents a SQL query in the Azure Cosmos DB service.
|
||||
*
|
||||
* Queries with inputs should be parameterized to protect against SQL injection.
|
||||
*
|
||||
* @example Parameterized SQL Query
|
||||
* ```typescript
|
||||
* const query: SqlQuerySpec = {
|
||||
* query: "SELECT * FROM Families f where f.lastName = @lastName",
|
||||
* parameters: [
|
||||
* {name: "@lastName", value: "Wakefield"}
|
||||
* ]
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
export interface SqlQuerySpec {
|
||||
/** The text of the SQL query */
|
||||
query: string;
|
||||
/** The parameters you provide in the query */
|
||||
parameters?: SqlParameter[];
|
||||
}
|
||||
/**
|
||||
* Represents a parameter in a Parameterized SQL query, specified in {@link SqlQuerySpec}
|
||||
*/
|
||||
export interface SqlParameter {
|
||||
/** Name of the parameter. (i.e. `@lastName`) */
|
||||
name: string;
|
||||
/** Value of the parameter (this is safe to come from users, assuming they are authorized) */
|
||||
value: JSONValue;
|
||||
}
|
||||
export type JSONValue = boolean | number | string | null | JSONArray | JSONObject;
|
||||
export interface JSONObject {
|
||||
[key: string]: JSONValue;
|
||||
}
|
||||
export interface JSONArray extends ArrayLike<JSONValue> {
|
||||
}
|
||||
//# sourceMappingURL=SqlQuerySpec.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SqlQuerySpec.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/SqlQuerySpec.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,6FAA6F;IAC7F,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,CAAC;AAClF,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AACD,MAAM,WAAW,SAAU,SAAQ,SAAS,CAAC,SAAS,CAAC;CAAG"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=SqlQuerySpec.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SqlQuerySpec.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/SqlQuerySpec.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Represents a SQL query in the Azure Cosmos DB service.\n *\n * Queries with inputs should be parameterized to protect against SQL injection.\n *\n * @example Parameterized SQL Query\n * ```typescript\n * const query: SqlQuerySpec = {\n * query: \"SELECT * FROM Families f where f.lastName = @lastName\",\n * parameters: [\n * {name: \"@lastName\", value: \"Wakefield\"}\n * ]\n * };\n * ```\n */\nexport interface SqlQuerySpec {\n /** The text of the SQL query */\n query: string;\n /** The parameters you provide in the query */\n parameters?: SqlParameter[];\n}\n\n/**\n * Represents a parameter in a Parameterized SQL query, specified in {@link SqlQuerySpec}\n */\nexport interface SqlParameter {\n /** Name of the parameter. (i.e. `@lastName`) */\n name: string;\n /** Value of the parameter (this is safe to come from users, assuming they are authorized) */\n value: JSONValue;\n}\n\nexport type JSONValue = boolean | number | string | null | JSONArray | JSONObject;\nexport interface JSONObject {\n [key: string]: JSONValue;\n}\nexport interface JSONArray extends ArrayLike<JSONValue> {}\n"]}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
import { RUConsumedManager } from "../common";
|
||||
import { FeedOptions, QueryOperationOptions, Response } from "../request";
|
||||
import { ExecutionContext } from "./index";
|
||||
import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal";
|
||||
/** @hidden */
|
||||
export type FetchFunctionCallback = (diagnosticNode: DiagnosticNodeInternal, options: FeedOptions) => Promise<Response<any>>;
|
||||
/** @hidden */
|
||||
export declare class DefaultQueryExecutionContext implements ExecutionContext {
|
||||
private static readonly STATES;
|
||||
private resources;
|
||||
private currentIndex;
|
||||
private currentPartitionIndex;
|
||||
private fetchFunctions;
|
||||
private options;
|
||||
continuationToken: string;
|
||||
get continuation(): string;
|
||||
private state;
|
||||
private nextFetchFunction;
|
||||
/**
|
||||
* Provides the basic Query Execution Context.
|
||||
* This wraps the internal logic query execution using provided fetch functions
|
||||
*
|
||||
* @param clientContext - Is used to read the partitionKeyRanges for split proofing
|
||||
* @param query - A SQL query.
|
||||
* @param options - Represents the feed options.
|
||||
* @param fetchFunctions - A function to retrieve each page of data.
|
||||
* An array of functions may be used to query more than one partition.
|
||||
* @hidden
|
||||
*/
|
||||
constructor(options: FeedOptions, fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[]);
|
||||
/**
|
||||
* Execute a provided callback on the next element in the execution context.
|
||||
*/
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
/**
|
||||
* Retrieve the current element on the execution context.
|
||||
*/
|
||||
current(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
/**
|
||||
* Determine if there are still remaining resources to processs based on
|
||||
* the value of the continuation token or the elements remaining on the current batch in the execution context.
|
||||
*
|
||||
* @returns true if there is other elements to process in the DefaultQueryExecutionContext.
|
||||
*/
|
||||
hasMoreResults(): boolean;
|
||||
/**
|
||||
* Fetches the next batch of the feed and pass them as an array to a callback
|
||||
*/
|
||||
fetchMore(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
private _canFetchMore;
|
||||
}
|
||||
//# sourceMappingURL=defaultQueryExecutionContext.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defaultQueryExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/defaultQueryExecutionContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAsB,MAAM,uCAAuC,CAAC;AAMnG,cAAc;AACd,MAAM,MAAM,qBAAqB,GAAG,CAClC,cAAc,EAAE,sBAAsB,EACtC,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAS5B,cAAc;AACd,qBAAa,4BAA6B,YAAW,gBAAgB;IACnE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAU;IACxC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,OAAO,CAAc;IACtB,iBAAiB,EAAE,MAAM,CAAC;IACjC,IAAW,YAAY,IAAI,MAAM,CAEhC;IACD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,iBAAiB,CAAyB;IAClD;;;;;;;;;;OAUG;gBAED,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,qBAAqB,GAAG,qBAAqB,EAAE;IAWjE;;OAEG;IACU,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAMzB;;OAEG;IACU,OAAO,CAClB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAgCzB;;;;;OAKG;IACI,cAAc,IAAI,OAAO;IAShC;;OAEG;IACU,SAAS,CACpB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAqHzB,OAAO,CAAC,aAAa;CAQtB"}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { createClientLogger } from "@azure/logger";
|
||||
import { Constants } from "../common";
|
||||
import { ClientSideMetrics, QueryMetrics } from "../queryMetrics";
|
||||
import { getInitialHeader, getRequestChargeIfAny } from "./headerUtils";
|
||||
import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal";
|
||||
import { addDignosticChild } from "../utils/diagnostics";
|
||||
import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel";
|
||||
import { RUCapPerOperationExceededError } from "../request/RUCapPerOperationExceededError";
|
||||
const logger = createClientLogger("ClientContext");
|
||||
/** @hidden */
|
||||
var STATES;
|
||||
(function (STATES) {
|
||||
STATES["start"] = "start";
|
||||
STATES["inProgress"] = "inProgress";
|
||||
STATES["ended"] = "ended";
|
||||
})(STATES || (STATES = {}));
|
||||
/** @hidden */
|
||||
export class DefaultQueryExecutionContext {
|
||||
get continuation() {
|
||||
return this.continuationToken;
|
||||
}
|
||||
/**
|
||||
* Provides the basic Query Execution Context.
|
||||
* This wraps the internal logic query execution using provided fetch functions
|
||||
*
|
||||
* @param clientContext - Is used to read the partitionKeyRanges for split proofing
|
||||
* @param query - A SQL query.
|
||||
* @param options - Represents the feed options.
|
||||
* @param fetchFunctions - A function to retrieve each page of data.
|
||||
* An array of functions may be used to query more than one partition.
|
||||
* @hidden
|
||||
*/
|
||||
constructor(options, fetchFunctions) {
|
||||
this.resources = [];
|
||||
this.currentIndex = 0;
|
||||
this.currentPartitionIndex = 0;
|
||||
this.fetchFunctions = Array.isArray(fetchFunctions) ? fetchFunctions : [fetchFunctions];
|
||||
this.options = options || {};
|
||||
this.continuationToken = this.options.continuationToken || this.options.continuation || null;
|
||||
this.state = DefaultQueryExecutionContext.STATES.start;
|
||||
}
|
||||
/**
|
||||
* Execute a provided callback on the next element in the execution context.
|
||||
*/
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
++this.currentIndex;
|
||||
const response = await this.current(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
return response;
|
||||
}
|
||||
/**
|
||||
* Retrieve the current element on the execution context.
|
||||
*/
|
||||
async current(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
if (this.currentIndex < this.resources.length) {
|
||||
return {
|
||||
result: this.resources[this.currentIndex],
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
if (this._canFetchMore()) {
|
||||
const { result: resources, headers } = await this.fetchMore(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
this.resources = resources;
|
||||
if (this.resources.length === 0) {
|
||||
if (!this.continuationToken && this.currentPartitionIndex >= this.fetchFunctions.length) {
|
||||
this.state = DefaultQueryExecutionContext.STATES.ended;
|
||||
return { result: undefined, headers };
|
||||
}
|
||||
else {
|
||||
return this.current(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
}
|
||||
}
|
||||
return { result: this.resources[this.currentIndex], headers };
|
||||
}
|
||||
else {
|
||||
this.state = DefaultQueryExecutionContext.STATES.ended;
|
||||
return {
|
||||
result: undefined,
|
||||
headers: getInitialHeader(),
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determine if there are still remaining resources to processs based on
|
||||
* the value of the continuation token or the elements remaining on the current batch in the execution context.
|
||||
*
|
||||
* @returns true if there is other elements to process in the DefaultQueryExecutionContext.
|
||||
*/
|
||||
hasMoreResults() {
|
||||
return (this.state === DefaultQueryExecutionContext.STATES.start ||
|
||||
this.continuationToken !== undefined ||
|
||||
this.currentIndex < this.resources.length - 1 ||
|
||||
this.currentPartitionIndex < this.fetchFunctions.length);
|
||||
}
|
||||
/**
|
||||
* Fetches the next batch of the feed and pass them as an array to a callback
|
||||
*/
|
||||
async fetchMore(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
return addDignosticChild(async (childDiagnosticNode) => {
|
||||
if (this.currentPartitionIndex >= this.fetchFunctions.length) {
|
||||
return {
|
||||
headers: getInitialHeader(),
|
||||
result: undefined,
|
||||
};
|
||||
}
|
||||
// Keep to the original continuation and to restore the value after fetchFunction call
|
||||
const originalContinuation = this.options.continuationToken || this.options.continuation;
|
||||
this.options.continuationToken = this.continuationToken;
|
||||
// Return undefined if there is no more results
|
||||
if (this.currentPartitionIndex >= this.fetchFunctions.length) {
|
||||
return {
|
||||
headers: getInitialHeader(),
|
||||
result: undefined,
|
||||
};
|
||||
}
|
||||
let resources;
|
||||
let responseHeaders;
|
||||
try {
|
||||
let p;
|
||||
if (this.nextFetchFunction !== undefined) {
|
||||
logger.verbose("using prefetch");
|
||||
p = this.nextFetchFunction;
|
||||
this.nextFetchFunction = undefined;
|
||||
}
|
||||
else {
|
||||
logger.verbose("using fresh fetch");
|
||||
p = this.fetchFunctions[this.currentPartitionIndex](childDiagnosticNode, this.options);
|
||||
}
|
||||
const response = await p;
|
||||
resources = response.result;
|
||||
childDiagnosticNode.recordQueryResult(resources, CosmosDbDiagnosticLevel.debugUnsafe);
|
||||
responseHeaders = response.headers;
|
||||
this.continuationToken = responseHeaders[Constants.HttpHeaders.Continuation];
|
||||
if (!this.continuationToken) {
|
||||
++this.currentPartitionIndex;
|
||||
}
|
||||
if (this.options && this.options.bufferItems === true) {
|
||||
const fetchFunction = this.fetchFunctions[this.currentPartitionIndex];
|
||||
this.nextFetchFunction = fetchFunction
|
||||
? fetchFunction(childDiagnosticNode, Object.assign(Object.assign({}, this.options), { continuationToken: this.continuationToken }))
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.state = DefaultQueryExecutionContext.STATES.ended;
|
||||
// return callback(err, undefined, responseHeaders);
|
||||
// TODO: Error and data being returned is an antipattern, this might broken
|
||||
throw err;
|
||||
}
|
||||
this.state = DefaultQueryExecutionContext.STATES.inProgress;
|
||||
this.currentIndex = 0;
|
||||
this.options.continuationToken = originalContinuation;
|
||||
this.options.continuation = originalContinuation;
|
||||
// deserializing query metrics so that we aren't working with delimited strings in the rest of the code base
|
||||
if (Constants.HttpHeaders.QueryMetrics in responseHeaders) {
|
||||
const delimitedString = responseHeaders[Constants.HttpHeaders.QueryMetrics];
|
||||
let queryMetrics = QueryMetrics.createFromDelimitedString(delimitedString);
|
||||
// Add the request charge to the query metrics so that we can have per partition request charge.
|
||||
if (Constants.HttpHeaders.RequestCharge in responseHeaders) {
|
||||
const requestCharge = Number(responseHeaders[Constants.HttpHeaders.RequestCharge]) || 0;
|
||||
queryMetrics = new QueryMetrics(queryMetrics.retrievedDocumentCount, queryMetrics.retrievedDocumentSize, queryMetrics.outputDocumentCount, queryMetrics.outputDocumentSize, queryMetrics.indexHitDocumentCount, queryMetrics.totalQueryExecutionTime, queryMetrics.queryPreparationTimes, queryMetrics.indexLookupTime, queryMetrics.documentLoadTime, queryMetrics.vmExecutionTime, queryMetrics.runtimeExecutionTimes, queryMetrics.documentWriteTime, new ClientSideMetrics(requestCharge));
|
||||
}
|
||||
// Wraping query metrics in a object where the key is '0' just so single partition
|
||||
// and partition queries have the same response schema
|
||||
responseHeaders[Constants.HttpHeaders.QueryMetrics] = {};
|
||||
responseHeaders[Constants.HttpHeaders.QueryMetrics]["0"] = queryMetrics;
|
||||
}
|
||||
if (operationOptions && operationOptions.ruCapPerOperation && ruConsumedManager) {
|
||||
await ruConsumedManager.addToRUConsumed(getRequestChargeIfAny(responseHeaders));
|
||||
const ruConsumedValue = await ruConsumedManager.getRUConsumed();
|
||||
if (ruConsumedValue > operationOptions.ruCapPerOperation) {
|
||||
// For RUCapPerOperationExceededError error, we won't be updating the state from
|
||||
// inProgress as we want to support continue
|
||||
throw new RUCapPerOperationExceededError("Request Unit limit per Operation call exceeded", resources);
|
||||
}
|
||||
}
|
||||
return { result: resources, headers: responseHeaders };
|
||||
}, diagnosticNode, DiagnosticNodeType.DEFAULT_QUERY_NODE, {
|
||||
queryMethodIdentifier: "fetchMore",
|
||||
});
|
||||
}
|
||||
_canFetchMore() {
|
||||
const res = this.state === DefaultQueryExecutionContext.STATES.start ||
|
||||
(this.continuationToken && this.state === DefaultQueryExecutionContext.STATES.inProgress) ||
|
||||
(this.currentPartitionIndex < this.fetchFunctions.length &&
|
||||
this.state === DefaultQueryExecutionContext.STATES.inProgress);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
DefaultQueryExecutionContext.STATES = STATES;
|
||||
//# sourceMappingURL=defaultQueryExecutionContext.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+63
@@ -0,0 +1,63 @@
|
||||
import { PartitionKeyRange, Resource } from "../client";
|
||||
import { ClientContext } from "../ClientContext";
|
||||
import { RUConsumedManager } from "../common";
|
||||
import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal";
|
||||
import { FeedOptions, QueryOperationOptions } from "../request";
|
||||
import { Response } from "../request";
|
||||
import { FetchResult } from "./FetchResult";
|
||||
import { SqlQuerySpec } from "./index";
|
||||
/** @hidden */
|
||||
export declare class DocumentProducer {
|
||||
private clientContext;
|
||||
private collectionLink;
|
||||
private query;
|
||||
targetPartitionKeyRange: PartitionKeyRange;
|
||||
fetchResults: FetchResult[];
|
||||
allFetched: boolean;
|
||||
private err;
|
||||
previousContinuationToken: string;
|
||||
continuationToken: string;
|
||||
generation: number;
|
||||
private respHeaders;
|
||||
private internalExecutionContext;
|
||||
/**
|
||||
* Provides the Target Partition Range Query Execution Context.
|
||||
* @param clientContext - The service endpoint to use to create the client.
|
||||
* @param collectionLink - Represents collection link
|
||||
* @param query - A SQL query.
|
||||
* @param targetPartitionKeyRange - Query Target Partition key Range
|
||||
* @hidden
|
||||
*/
|
||||
constructor(clientContext: ClientContext, collectionLink: string, query: SqlQuerySpec, targetPartitionKeyRange: PartitionKeyRange, options: FeedOptions);
|
||||
/**
|
||||
* Synchronously gives the contiguous buffered results (stops at the first non result) if any
|
||||
* @returns buffered current items if any
|
||||
* @hidden
|
||||
*/
|
||||
peekBufferedItems(): any[];
|
||||
fetchFunction: (diagnosticNode: DiagnosticNodeInternal, options: FeedOptions) => Promise<Response<Resource>>;
|
||||
hasMoreResults(): boolean;
|
||||
gotSplit(): boolean;
|
||||
private _getAndResetActiveResponseHeaders;
|
||||
private _updateStates;
|
||||
private static _needPartitionKeyRangeCacheRefresh;
|
||||
/**
|
||||
* Fetches and bufferes the next page of results and executes the given callback
|
||||
*/
|
||||
bufferMore(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
/**
|
||||
* Synchronously gives the bufferend current item if any
|
||||
* @returns buffered current item if any
|
||||
* @hidden
|
||||
*/
|
||||
getTargetParitionKeyRange(): PartitionKeyRange;
|
||||
/**
|
||||
* Fetches the next element in the DocumentProducer.
|
||||
*/
|
||||
nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
/**
|
||||
* Retrieve the current element on the DocumentProducer.
|
||||
*/
|
||||
current(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise<Response<any>>;
|
||||
}
|
||||
//# sourceMappingURL=documentProducer.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"documentProducer.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/documentProducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAOL,iBAAiB,EAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,cAAc;AACd,qBAAa,gBAAgB;IAsBzB,OAAO,CAAC,aAAa;IArBvB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAwB;IAC9B,uBAAuB,EAAE,iBAAiB,CAAC;IAC3C,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,GAAG,CAAQ;IACZ,yBAAyB,EAAE,MAAM,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAK;IAC9B,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,wBAAwB,CAA+B;IAE/D;;;;;;;OAOG;gBAEO,aAAa,EAAE,aAAa,EACpC,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,YAAY,EACnB,uBAAuB,EAAE,iBAAiB,EAC1C,OAAO,EAAE,WAAW;IAiBtB;;;;OAIG;IACI,iBAAiB,IAAI,GAAG,EAAE;IAmB1B,aAAa,mBACF,sBAAsB,WAC7B,WAAW,KACnB,QAAQ,SAAS,QAAQ,CAAC,CAAC,CAe5B;IAEK,cAAc,IAAI,OAAO;IAIzB,QAAQ,IAAI,OAAO;IAW1B,OAAO,CAAC,iCAAiC;IAMzC,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,MAAM,CAAC,kCAAkC;IASjD;;OAEG;IACU,UAAU,CACrB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAqDzB;;;;OAIG;IACI,yBAAyB,IAAI,iBAAiB;IAIrD;;OAEG;IACU,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAiCzB;;OAEG;IACU,OAAO,CAClB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;CA0C1B"}
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
import { Constants, getIdFromLink, getPathFromLink, ResourceType, StatusCodes, SubStatusCodes, } from "../common";
|
||||
import { DefaultQueryExecutionContext } from "./defaultQueryExecutionContext";
|
||||
import { FetchResult, FetchResultType } from "./FetchResult";
|
||||
import { getInitialHeader, mergeHeaders } from "./headerUtils";
|
||||
/** @hidden */
|
||||
export class DocumentProducer {
|
||||
/**
|
||||
* Provides the Target Partition Range Query Execution Context.
|
||||
* @param clientContext - The service endpoint to use to create the client.
|
||||
* @param collectionLink - Represents collection link
|
||||
* @param query - A SQL query.
|
||||
* @param targetPartitionKeyRange - Query Target Partition key Range
|
||||
* @hidden
|
||||
*/
|
||||
constructor(clientContext, collectionLink, query, targetPartitionKeyRange, options) {
|
||||
this.clientContext = clientContext;
|
||||
this.generation = 0;
|
||||
this.fetchFunction = async (diagnosticNode, options) => {
|
||||
const path = getPathFromLink(this.collectionLink, ResourceType.item);
|
||||
diagnosticNode.addData({ partitionKeyRangeId: this.targetPartitionKeyRange.id });
|
||||
const id = getIdFromLink(this.collectionLink);
|
||||
return this.clientContext.queryFeed({
|
||||
path,
|
||||
resourceType: ResourceType.item,
|
||||
resourceId: id,
|
||||
resultFn: (result) => result.Documents,
|
||||
query: this.query,
|
||||
options,
|
||||
diagnosticNode,
|
||||
partitionKeyRangeId: this.targetPartitionKeyRange["id"],
|
||||
});
|
||||
};
|
||||
// TODO: any options
|
||||
this.collectionLink = collectionLink;
|
||||
this.query = query;
|
||||
this.targetPartitionKeyRange = targetPartitionKeyRange;
|
||||
this.fetchResults = [];
|
||||
this.allFetched = false;
|
||||
this.err = undefined;
|
||||
this.previousContinuationToken = undefined;
|
||||
this.continuationToken = undefined;
|
||||
this.respHeaders = getInitialHeader();
|
||||
this.internalExecutionContext = new DefaultQueryExecutionContext(options, this.fetchFunction);
|
||||
}
|
||||
/**
|
||||
* Synchronously gives the contiguous buffered results (stops at the first non result) if any
|
||||
* @returns buffered current items if any
|
||||
* @hidden
|
||||
*/
|
||||
peekBufferedItems() {
|
||||
const bufferedResults = [];
|
||||
for (let i = 0, done = false; i < this.fetchResults.length && !done; i++) {
|
||||
const fetchResult = this.fetchResults[i];
|
||||
switch (fetchResult.fetchResultType) {
|
||||
case FetchResultType.Done:
|
||||
done = true;
|
||||
break;
|
||||
case FetchResultType.Exception:
|
||||
done = true;
|
||||
break;
|
||||
case FetchResultType.Result:
|
||||
bufferedResults.push(fetchResult.feedResponse);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bufferedResults;
|
||||
}
|
||||
hasMoreResults() {
|
||||
return this.internalExecutionContext.hasMoreResults() || this.fetchResults.length !== 0;
|
||||
}
|
||||
gotSplit() {
|
||||
const fetchResult = this.fetchResults[0];
|
||||
if (fetchResult.fetchResultType === FetchResultType.Exception) {
|
||||
if (DocumentProducer._needPartitionKeyRangeCacheRefresh(fetchResult.error)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_getAndResetActiveResponseHeaders() {
|
||||
const ret = this.respHeaders;
|
||||
this.respHeaders = getInitialHeader();
|
||||
return ret;
|
||||
}
|
||||
_updateStates(err, allFetched) {
|
||||
// TODO: any Error
|
||||
if (err) {
|
||||
this.err = err;
|
||||
return;
|
||||
}
|
||||
if (allFetched) {
|
||||
this.allFetched = true;
|
||||
}
|
||||
if (this.internalExecutionContext.continuationToken === this.continuationToken) {
|
||||
// nothing changed
|
||||
return;
|
||||
}
|
||||
this.previousContinuationToken = this.continuationToken;
|
||||
this.continuationToken = this.internalExecutionContext.continuationToken;
|
||||
}
|
||||
static _needPartitionKeyRangeCacheRefresh(error) {
|
||||
// TODO: error
|
||||
return (error.code === StatusCodes.Gone &&
|
||||
"substatus" in error &&
|
||||
error["substatus"] === SubStatusCodes.PartitionKeyRangeGone);
|
||||
}
|
||||
/**
|
||||
* Fetches and bufferes the next page of results and executes the given callback
|
||||
*/
|
||||
async bufferMore(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
if (this.err) {
|
||||
throw this.err;
|
||||
}
|
||||
try {
|
||||
const { result: resources, headers: headerResponse } = await this.internalExecutionContext.fetchMore(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
++this.generation;
|
||||
this._updateStates(undefined, resources === undefined);
|
||||
if (resources !== undefined) {
|
||||
// some more results
|
||||
resources.forEach((element) => {
|
||||
// TODO: resources any
|
||||
this.fetchResults.push(new FetchResult(element, undefined));
|
||||
});
|
||||
}
|
||||
// need to modify the header response so that the query metrics are per partition
|
||||
if (headerResponse != null && Constants.HttpHeaders.QueryMetrics in headerResponse) {
|
||||
// "0" is the default partition before one is actually assigned.
|
||||
const queryMetrics = headerResponse[Constants.HttpHeaders.QueryMetrics]["0"];
|
||||
// Wraping query metrics in a object where the keys are the partition key range.
|
||||
headerResponse[Constants.HttpHeaders.QueryMetrics] = {};
|
||||
headerResponse[Constants.HttpHeaders.QueryMetrics][this.targetPartitionKeyRange.id] =
|
||||
queryMetrics;
|
||||
}
|
||||
return { result: resources, headers: headerResponse };
|
||||
}
|
||||
catch (err) {
|
||||
// TODO: any error
|
||||
if (DocumentProducer._needPartitionKeyRangeCacheRefresh(err)) {
|
||||
// Split just happend
|
||||
// Buffer the error so the execution context can still get the feedResponses in the itemBuffer
|
||||
const bufferedError = new FetchResult(undefined, err);
|
||||
this.fetchResults.push(bufferedError);
|
||||
// Putting a dummy result so that the rest of code flows
|
||||
return {
|
||||
result: [bufferedError],
|
||||
headers: err.headers,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this._updateStates(err, err.resources === undefined);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Synchronously gives the bufferend current item if any
|
||||
* @returns buffered current item if any
|
||||
* @hidden
|
||||
*/
|
||||
getTargetParitionKeyRange() {
|
||||
return this.targetPartitionKeyRange;
|
||||
}
|
||||
/**
|
||||
* Fetches the next element in the DocumentProducer.
|
||||
*/
|
||||
async nextItem(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
if (this.err) {
|
||||
this._updateStates(this.err, undefined);
|
||||
throw this.err;
|
||||
}
|
||||
try {
|
||||
const { result, headers } = await this.current(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
const fetchResult = this.fetchResults.shift();
|
||||
this._updateStates(undefined, result === undefined);
|
||||
if (fetchResult.feedResponse !== result) {
|
||||
throw new Error(`Expected ${fetchResult.feedResponse} to equal ${result}`);
|
||||
}
|
||||
switch (fetchResult.fetchResultType) {
|
||||
case FetchResultType.Done:
|
||||
return { result: undefined, headers };
|
||||
case FetchResultType.Exception:
|
||||
fetchResult.error.headers = headers;
|
||||
throw fetchResult.error;
|
||||
case FetchResultType.Result:
|
||||
return { result: fetchResult.feedResponse, headers };
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this._updateStates(err, err.item === undefined);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Retrieve the current element on the DocumentProducer.
|
||||
*/
|
||||
async current(diagnosticNode, operationOptions, ruConsumedManager) {
|
||||
// If something is buffered just give that
|
||||
if (this.fetchResults.length > 0) {
|
||||
const fetchResult = this.fetchResults[0];
|
||||
// Need to unwrap fetch results
|
||||
switch (fetchResult.fetchResultType) {
|
||||
case FetchResultType.Done:
|
||||
return {
|
||||
result: undefined,
|
||||
headers: this._getAndResetActiveResponseHeaders(),
|
||||
};
|
||||
case FetchResultType.Exception:
|
||||
fetchResult.error.headers = this._getAndResetActiveResponseHeaders();
|
||||
throw fetchResult.error;
|
||||
case FetchResultType.Result:
|
||||
return {
|
||||
result: fetchResult.feedResponse,
|
||||
headers: this._getAndResetActiveResponseHeaders(),
|
||||
};
|
||||
}
|
||||
}
|
||||
// If there isn't anymore items left to fetch then let the user know.
|
||||
if (this.allFetched) {
|
||||
return {
|
||||
result: undefined,
|
||||
headers: this._getAndResetActiveResponseHeaders(),
|
||||
};
|
||||
}
|
||||
// If there are no more bufferd items and there are still items to be fetched then buffer more
|
||||
const { result, headers } = await this.bufferMore(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
mergeHeaders(this.respHeaders, headers);
|
||||
if (result === undefined) {
|
||||
return { result: undefined, headers: this.respHeaders };
|
||||
}
|
||||
return this.current(diagnosticNode, operationOptions, ruConsumedManager);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=documentProducer.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+14
@@ -0,0 +1,14 @@
|
||||
export interface CosmosHeaders {
|
||||
[key: string]: any;
|
||||
}
|
||||
/** @hidden */
|
||||
export declare function getRequestChargeIfAny(headers: CosmosHeaders | number): number;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export declare function getInitialHeader(): CosmosHeaders;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export declare function mergeHeaders(headers: CosmosHeaders, toBeMergedHeaders: CosmosHeaders): void;
|
||||
//# sourceMappingURL=headerUtils.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"headerUtils.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/headerUtils.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,cAAc;AAEd,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,CAiB7E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED;;GAEG;AAEH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,aAAa,GAAG,IAAI,CAuC3F"}
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { Constants } from "../common";
|
||||
import { QueryMetrics } from "../queryMetrics/queryMetrics";
|
||||
/** @hidden */
|
||||
// TODO: docs
|
||||
export function getRequestChargeIfAny(headers) {
|
||||
if (typeof headers === "number") {
|
||||
return headers;
|
||||
}
|
||||
else if (typeof headers === "string") {
|
||||
return parseFloat(headers);
|
||||
}
|
||||
if (headers) {
|
||||
const rc = headers[Constants.HttpHeaders.RequestCharge];
|
||||
if (rc) {
|
||||
return parseFloat(rc);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export function getInitialHeader() {
|
||||
const headers = {};
|
||||
headers[Constants.HttpHeaders.RequestCharge] = 0;
|
||||
headers[Constants.HttpHeaders.QueryMetrics] = {};
|
||||
return headers;
|
||||
}
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
// TODO: The name of this method isn't very accurate to what it does
|
||||
export function mergeHeaders(headers, toBeMergedHeaders) {
|
||||
if (headers[Constants.HttpHeaders.RequestCharge] === undefined) {
|
||||
headers[Constants.HttpHeaders.RequestCharge] = 0;
|
||||
}
|
||||
if (headers[Constants.HttpHeaders.QueryMetrics] === undefined) {
|
||||
headers[Constants.HttpHeaders.QueryMetrics] = QueryMetrics.zero;
|
||||
}
|
||||
if (!toBeMergedHeaders) {
|
||||
return;
|
||||
}
|
||||
headers[Constants.HttpHeaders.RequestCharge] += getRequestChargeIfAny(toBeMergedHeaders);
|
||||
if (toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed]) {
|
||||
headers[Constants.HttpHeaders.IsRUPerMinuteUsed] =
|
||||
toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed];
|
||||
}
|
||||
if (Constants.HttpHeaders.QueryMetrics in toBeMergedHeaders) {
|
||||
const headerQueryMetrics = headers[Constants.HttpHeaders.QueryMetrics];
|
||||
const toBeMergedHeaderQueryMetrics = toBeMergedHeaders[Constants.HttpHeaders.QueryMetrics];
|
||||
for (const partitionId in toBeMergedHeaderQueryMetrics) {
|
||||
if (headerQueryMetrics[partitionId]) {
|
||||
const combinedQueryMetrics = headerQueryMetrics[partitionId].add([
|
||||
toBeMergedHeaderQueryMetrics[partitionId],
|
||||
]);
|
||||
headerQueryMetrics[partitionId] = combinedQueryMetrics;
|
||||
}
|
||||
else {
|
||||
headerQueryMetrics[partitionId] = toBeMergedHeaderQueryMetrics[partitionId];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Constants.HttpHeaders.IndexUtilization in toBeMergedHeaders) {
|
||||
headers[Constants.HttpHeaders.IndexUtilization] =
|
||||
toBeMergedHeaders[Constants.HttpHeaders.IndexUtilization];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=headerUtils.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"headerUtils.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/headerUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAM5D,cAAc;AACd,aAAa;AACb,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,OAAO,CAAC;KAChB;SAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QACtC,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;KAC5B;IAED,IAAI,OAAO,EAAE;QACX,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QACxD,IAAI,EAAE,EAAE;YACN,OAAO,UAAU,CAAC,EAAY,CAAC,CAAC;SACjC;aAAM;YACL,OAAO,CAAC,CAAC;SACV;KACF;SAAM;QACL,OAAO,CAAC,CAAC;KACV;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACjD,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;IACjD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,oEAAoE;AACpE,MAAM,UAAU,YAAY,CAAC,OAAsB,EAAE,iBAAgC;IACnF,IAAI,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,SAAS,EAAE;QAC9D,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;KAClD;IAED,IAAI,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE;QAC7D,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC;KACjE;IAED,IAAI,CAAC,iBAAiB,EAAE;QACtB,OAAO;KACR;IAED,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACzF,IAAI,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE;QAC9D,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,iBAAiB,CAAC;YAC9C,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;KAC9D;IAED,IAAI,SAAS,CAAC,WAAW,CAAC,YAAY,IAAI,iBAAiB,EAAE;QAC3D,MAAM,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACvE,MAAM,4BAA4B,GAAG,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAE3F,KAAK,MAAM,WAAW,IAAI,4BAA4B,EAAE;YACtD,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE;gBACnC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC;oBAC/D,4BAA4B,CAAC,WAAW,CAAC;iBAC1C,CAAC,CAAC;gBACH,kBAAkB,CAAC,WAAW,CAAC,GAAG,oBAAoB,CAAC;aACxD;iBAAM;gBACL,kBAAkB,CAAC,WAAW,CAAC,GAAG,4BAA4B,CAAC,WAAW,CAAC,CAAC;aAC7E;SACF;KACF;IAED,IAAI,SAAS,CAAC,WAAW,CAAC,gBAAgB,IAAI,iBAAiB,EAAE;QAC/D,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC;YAC7C,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;KAC7D;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common\";\nimport { QueryMetrics } from \"../queryMetrics/queryMetrics\";\n\nexport interface CosmosHeaders {\n [key: string]: any;\n}\n\n/** @hidden */\n// TODO: docs\nexport function getRequestChargeIfAny(headers: CosmosHeaders | number): number {\n if (typeof headers === \"number\") {\n return headers;\n } else if (typeof headers === \"string\") {\n return parseFloat(headers);\n }\n\n if (headers) {\n const rc = headers[Constants.HttpHeaders.RequestCharge];\n if (rc) {\n return parseFloat(rc as string);\n } else {\n return 0;\n }\n } else {\n return 0;\n }\n}\n\n/**\n * @hidden\n */\nexport function getInitialHeader(): CosmosHeaders {\n const headers: CosmosHeaders = {};\n headers[Constants.HttpHeaders.RequestCharge] = 0;\n headers[Constants.HttpHeaders.QueryMetrics] = {};\n return headers;\n}\n\n/**\n * @hidden\n */\n// TODO: The name of this method isn't very accurate to what it does\nexport function mergeHeaders(headers: CosmosHeaders, toBeMergedHeaders: CosmosHeaders): void {\n if (headers[Constants.HttpHeaders.RequestCharge] === undefined) {\n headers[Constants.HttpHeaders.RequestCharge] = 0;\n }\n\n if (headers[Constants.HttpHeaders.QueryMetrics] === undefined) {\n headers[Constants.HttpHeaders.QueryMetrics] = QueryMetrics.zero;\n }\n\n if (!toBeMergedHeaders) {\n return;\n }\n\n headers[Constants.HttpHeaders.RequestCharge] += getRequestChargeIfAny(toBeMergedHeaders);\n if (toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed]) {\n headers[Constants.HttpHeaders.IsRUPerMinuteUsed] =\n toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed];\n }\n\n if (Constants.HttpHeaders.QueryMetrics in toBeMergedHeaders) {\n const headerQueryMetrics = headers[Constants.HttpHeaders.QueryMetrics];\n const toBeMergedHeaderQueryMetrics = toBeMergedHeaders[Constants.HttpHeaders.QueryMetrics];\n\n for (const partitionId in toBeMergedHeaderQueryMetrics) {\n if (headerQueryMetrics[partitionId]) {\n const combinedQueryMetrics = headerQueryMetrics[partitionId].add([\n toBeMergedHeaderQueryMetrics[partitionId],\n ]);\n headerQueryMetrics[partitionId] = combinedQueryMetrics;\n } else {\n headerQueryMetrics[partitionId] = toBeMergedHeaderQueryMetrics[partitionId];\n }\n }\n }\n\n if (Constants.HttpHeaders.IndexUtilization in toBeMergedHeaders) {\n headers[Constants.HttpHeaders.IndexUtilization] =\n toBeMergedHeaders[Constants.HttpHeaders.IndexUtilization];\n }\n}\n"]}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
export * from "./headerUtils";
|
||||
export * from "./SqlQuerySpec";
|
||||
export * from "./defaultQueryExecutionContext";
|
||||
export * from "./Aggregators";
|
||||
export * from "./documentProducer";
|
||||
export * from "./FetchResult";
|
||||
export * from "./orderByDocumentProducerComparator";
|
||||
export * from "./ExecutionContext";
|
||||
export * from "./parallelQueryExecutionContextBase";
|
||||
export * from "./parallelQueryExecutionContext";
|
||||
export * from "./orderByQueryExecutionContext";
|
||||
export * from "./pipelinedQueryExecutionContext";
|
||||
export * from "./orderByComparator";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qCAAqC,CAAC;AACpD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC"}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export * from "./headerUtils";
|
||||
export * from "./SqlQuerySpec";
|
||||
export * from "./defaultQueryExecutionContext";
|
||||
export * from "./Aggregators";
|
||||
export * from "./documentProducer";
|
||||
export * from "./FetchResult";
|
||||
export * from "./orderByDocumentProducerComparator";
|
||||
export * from "./ExecutionContext";
|
||||
export * from "./parallelQueryExecutionContextBase";
|
||||
export * from "./parallelQueryExecutionContext";
|
||||
export * from "./orderByQueryExecutionContext";
|
||||
export * from "./pipelinedQueryExecutionContext";
|
||||
export * from "./orderByComparator";
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qCAAqC,CAAC;AACpD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport * from \"./headerUtils\";\nexport * from \"./SqlQuerySpec\";\nexport * from \"./defaultQueryExecutionContext\";\nexport * from \"./Aggregators\";\nexport * from \"./documentProducer\";\nexport * from \"./FetchResult\";\nexport * from \"./orderByDocumentProducerComparator\";\nexport * from \"./ExecutionContext\";\nexport * from \"./parallelQueryExecutionContextBase\";\nexport * from \"./parallelQueryExecutionContext\";\nexport * from \"./orderByQueryExecutionContext\";\nexport * from \"./pipelinedQueryExecutionContext\";\nexport * from \"./orderByComparator\";\n"]}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user