UNPKG

@azure/cosmos

Version:
110 lines (109 loc) 5.44 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var queryPreparationTime_exports = {}; __export(queryPreparationTime_exports, { QueryPreparationTimes: () => QueryPreparationTimes }); module.exports = __toCommonJS(queryPreparationTime_exports); var import_queryMetricsConstants = __toESM(require("./queryMetricsConstants.js")); var import_queryMetricsUtils = require("./queryMetricsUtils.js"); var import_timeSpan = require("./timeSpan.js"); class QueryPreparationTimes { constructor(queryCompilationTime, logicalPlanBuildTime, physicalPlanBuildTime, queryOptimizationTime) { this.queryCompilationTime = queryCompilationTime; this.logicalPlanBuildTime = logicalPlanBuildTime; this.physicalPlanBuildTime = physicalPlanBuildTime; this.queryOptimizationTime = queryOptimizationTime; } /** * returns a new QueryPreparationTimes instance that is the addition of this and the arguments. */ add(...queryPreparationTimesArray) { let queryCompilationTime = this.queryCompilationTime; let logicalPlanBuildTime = this.logicalPlanBuildTime; let physicalPlanBuildTime = this.physicalPlanBuildTime; let queryOptimizationTime = this.queryOptimizationTime; for (const queryPreparationTimes of queryPreparationTimesArray) { if (queryPreparationTimes == null) { throw new Error("queryPreparationTimesArray has null or undefined item(s)"); } queryCompilationTime = queryCompilationTime.add(queryPreparationTimes.queryCompilationTime); logicalPlanBuildTime = logicalPlanBuildTime.add(queryPreparationTimes.logicalPlanBuildTime); physicalPlanBuildTime = physicalPlanBuildTime.add( queryPreparationTimes.physicalPlanBuildTime ); queryOptimizationTime = queryOptimizationTime.add( queryPreparationTimes.queryOptimizationTime ); } return new QueryPreparationTimes( queryCompilationTime, logicalPlanBuildTime, physicalPlanBuildTime, queryOptimizationTime ); } /** * Output the QueryPreparationTimes as a delimited string. */ toDelimitedString() { return `${import_queryMetricsConstants.default.QueryCompileTimeInMs}=${this.queryCompilationTime.totalMilliseconds()};${import_queryMetricsConstants.default.LogicalPlanBuildTimeInMs}=${this.logicalPlanBuildTime.totalMilliseconds()};${import_queryMetricsConstants.default.PhysicalPlanBuildTimeInMs}=${this.physicalPlanBuildTime.totalMilliseconds()};${import_queryMetricsConstants.default.QueryOptimizationTimeInMs}=${this.queryOptimizationTime.totalMilliseconds()}`; } static zero = new QueryPreparationTimes( import_timeSpan.TimeSpan.zero, import_timeSpan.TimeSpan.zero, import_timeSpan.TimeSpan.zero, import_timeSpan.TimeSpan.zero ); /** * Returns a new instance of the QueryPreparationTimes class that is the * aggregation of an array of QueryPreparationTimes. */ static createFromArray(queryPreparationTimesArray) { if (queryPreparationTimesArray == null) { throw new Error("queryPreparationTimesArray is null or undefined item(s)"); } return QueryPreparationTimes.zero.add(...queryPreparationTimesArray); } /** * Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string. */ static createFromDelimitedString(delimitedString) { const metrics = (0, import_queryMetricsUtils.parseDelimitedString)(delimitedString); return new QueryPreparationTimes( (0, import_queryMetricsUtils.timeSpanFromMetrics)(metrics, import_queryMetricsConstants.default.QueryCompileTimeInMs), (0, import_queryMetricsUtils.timeSpanFromMetrics)(metrics, import_queryMetricsConstants.default.LogicalPlanBuildTimeInMs), (0, import_queryMetricsUtils.timeSpanFromMetrics)(metrics, import_queryMetricsConstants.default.PhysicalPlanBuildTimeInMs), (0, import_queryMetricsUtils.timeSpanFromMetrics)(metrics, import_queryMetricsConstants.default.QueryOptimizationTimeInMs) ); } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { QueryPreparationTimes });