query-profile.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. "use strict";
  2. /*!
  3. * Copyright 2024 Google LLC. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.ExplainResults = exports.ExplainMetrics = exports.ExecutionStats = exports.PlanSummary = void 0;
  19. /**
  20. * PlanSummary contains information about the planning stage of a query.
  21. *
  22. * @class PlanSummary
  23. */
  24. class PlanSummary {
  25. /**
  26. * @private
  27. * @internal
  28. */
  29. constructor(indexesUsed) {
  30. this.indexesUsed = indexesUsed;
  31. }
  32. /**
  33. * @private
  34. * @internal
  35. */
  36. static _fromProto(plan, serializer) {
  37. const indexes = [];
  38. if (plan && plan.indexesUsed) {
  39. for (const index of plan.indexesUsed) {
  40. indexes.push(serializer.decodeGoogleProtobufStruct(index));
  41. }
  42. }
  43. return new PlanSummary(indexes);
  44. }
  45. }
  46. exports.PlanSummary = PlanSummary;
  47. /**
  48. * ExecutionStats contains information about the execution of a query.
  49. *
  50. * @class ExecutionStats
  51. */
  52. class ExecutionStats {
  53. /**
  54. * @private
  55. * @internal
  56. */
  57. constructor(resultsReturned, executionDuration, readOperations, debugStats) {
  58. this.resultsReturned = resultsReturned;
  59. this.executionDuration = executionDuration;
  60. this.readOperations = readOperations;
  61. this.debugStats = debugStats;
  62. }
  63. /**
  64. * @private
  65. * @internal
  66. */
  67. static _fromProto(stats, serializer) {
  68. var _a, _b;
  69. if (stats) {
  70. return new ExecutionStats(Number(stats.resultsReturned), {
  71. seconds: Number((_a = stats.executionDuration) === null || _a === void 0 ? void 0 : _a.seconds),
  72. nanoseconds: Number((_b = stats.executionDuration) === null || _b === void 0 ? void 0 : _b.nanos),
  73. }, Number(stats.readOperations), serializer.decodeGoogleProtobufStruct(stats.debugStats));
  74. }
  75. return null;
  76. }
  77. }
  78. exports.ExecutionStats = ExecutionStats;
  79. /**
  80. * ExplainMetrics contains information about planning and execution of a query.
  81. *
  82. * @class ExplainMetrics
  83. */
  84. class ExplainMetrics {
  85. /**
  86. * @private
  87. * @internal
  88. */
  89. constructor(planSummary, executionStats) {
  90. this.planSummary = planSummary;
  91. this.executionStats = executionStats;
  92. }
  93. /**
  94. * @private
  95. * @internal
  96. */
  97. static _fromProto(metrics, serializer) {
  98. return new ExplainMetrics(PlanSummary._fromProto(metrics.planSummary, serializer), ExecutionStats._fromProto(metrics.executionStats, serializer));
  99. }
  100. }
  101. exports.ExplainMetrics = ExplainMetrics;
  102. /**
  103. * ExplainResults contains information about planning, execution, and results
  104. * of a query.
  105. *
  106. * @class ExplainResults
  107. */
  108. class ExplainResults {
  109. /**
  110. * @private
  111. * @internal
  112. */
  113. constructor(metrics, snapshot) {
  114. this.metrics = metrics;
  115. this.snapshot = snapshot;
  116. }
  117. }
  118. exports.ExplainResults = ExplainResults;
  119. //# sourceMappingURL=query-profile.js.map