@datadog/sketches-js
Advanced tools
Comparing version 1.0.5 to 2.0.0
@@ -27,3 +27,2 @@ "use strict"; | ||
var mapping_1 = require("./mapping"); | ||
var compiled_1 = require("./proto/compiled"); | ||
var DEFAULT_RELATIVE_ACCURACY = 0.01; | ||
@@ -122,2 +121,3 @@ /** Base class for DDSketch*/ | ||
/* Merge summary stats */ | ||
this.zeroCount += sketch.zeroCount; | ||
this.count += sketch.count; | ||
@@ -157,3 +157,4 @@ this.sum += sketch.sum; | ||
BaseDDSketch.prototype.toProto = function () { | ||
var message = compiled_1.DDSketch.create({ | ||
var ProtoDDSketch = require('./proto/compiled').DDSketch; | ||
var message = ProtoDDSketch.create({ | ||
mapping: this.mapping.toProto(), | ||
@@ -164,3 +165,3 @@ positiveValues: this.store.toProto(), | ||
}); | ||
return compiled_1.DDSketch.encode(message).finish(); | ||
return ProtoDDSketch.encode(message).finish(); | ||
}; | ||
@@ -176,3 +177,4 @@ /** | ||
BaseDDSketch.fromProto = function (buffer) { | ||
var decoded = compiled_1.DDSketch.decode(buffer); | ||
var ProtoDDSketch = require('./proto/compiled').DDSketch; | ||
var decoded = ProtoDDSketch.decode(buffer); | ||
var mapping = mapping_1.KeyMapping.fromProto(decoded.mapping); | ||
@@ -199,8 +201,6 @@ var store = store_1.DenseStore.fromProto(decoded.positiveValues); | ||
var _b = _a === void 0 ? defaultConfig : _a, _c = _b.relativeAccuracy, relativeAccuracy = _c === void 0 ? DEFAULT_RELATIVE_ACCURACY : _c; | ||
var _this = this; | ||
var mapping = new mapping_1.LogarithmicMapping(relativeAccuracy); | ||
var store = new store_1.DenseStore(); | ||
var negativeStore = new store_1.DenseStore(); | ||
_this = _super.call(this, { mapping: mapping, store: store, negativeStore: negativeStore, zeroCount: 0 }) || this; | ||
return _this; | ||
return _super.call(this, { mapping: mapping, store: store, negativeStore: negativeStore, zeroCount: 0 }) || this; | ||
} | ||
@@ -207,0 +207,0 @@ return DDSketch; |
@@ -27,3 +27,2 @@ "use strict"; | ||
var math_1 = require("../math"); | ||
var compiled_1 = require("../proto/compiled"); | ||
/** | ||
@@ -51,3 +50,3 @@ * A fast KeyMapping that approximates the memory-optimal LogarithmicMapping by | ||
CubicallyInterpolatedMapping.prototype._cubicLog2Approx = function (value) { | ||
var _a = math_1.frexp(value), mantissa = _a[0], exponent = _a[1]; | ||
var _a = (0, math_1.frexp)(value), mantissa = _a[0], exponent = _a[1]; | ||
var significand = 2 * mantissa - 1; | ||
@@ -70,3 +69,3 @@ return (((this.A * significand + this.B) * significand + this.C) * | ||
var mantissa = significandPlusOne / 2; | ||
return math_1.ldexp(mantissa, exponent + 1); | ||
return (0, math_1.ldexp)(mantissa, exponent + 1); | ||
}; | ||
@@ -80,3 +79,4 @@ CubicallyInterpolatedMapping.prototype._logGamma = function (value) { | ||
CubicallyInterpolatedMapping.prototype._protoInterpolation = function () { | ||
return compiled_1.IndexMapping.Interpolation.CUBIC; | ||
var Interpolation = require('../proto/compiled').IndexMapping.Interpolation; | ||
return Interpolation.CUBIC; | ||
}; | ||
@@ -83,0 +83,0 @@ return CubicallyInterpolatedMapping; |
@@ -11,3 +11,2 @@ "use strict"; | ||
var index_1 = require("./index"); | ||
var compiled_1 = require("../proto/compiled"); | ||
// 1.1125369292536007e-308 | ||
@@ -57,3 +56,4 @@ var MIN_SAFE_FLOAT = Math.pow(2, -1023); | ||
KeyMapping.prototype.toProto = function () { | ||
return compiled_1.IndexMapping.create({ | ||
var ProtoIndexMapping = require('../proto/compiled').IndexMapping; | ||
return ProtoIndexMapping.create({ | ||
gamma: this.gamma, | ||
@@ -72,9 +72,10 @@ indexOffset: this._offset, | ||
} | ||
var Interpolation = require('../proto/compiled').IndexMapping.Interpolation; | ||
var interpolation = protoMapping.interpolation, gamma = protoMapping.gamma, indexOffset = protoMapping.indexOffset; | ||
switch (interpolation) { | ||
case compiled_1.IndexMapping.Interpolation.NONE: | ||
case Interpolation.NONE: | ||
return index_1.LogarithmicMapping.fromGammaOffset(gamma, indexOffset); | ||
case compiled_1.IndexMapping.Interpolation.LINEAR: | ||
case Interpolation.LINEAR: | ||
return index_1.LinearlyInterpolatedMapping.fromGammaOffset(gamma, indexOffset); | ||
case compiled_1.IndexMapping.Interpolation.CUBIC: | ||
case Interpolation.CUBIC: | ||
return index_1.CubicallyInterpolatedMapping.fromGammaOffset(gamma, indexOffset); | ||
@@ -94,3 +95,4 @@ default: | ||
KeyMapping.prototype._protoInterpolation = function () { | ||
return compiled_1.IndexMapping.Interpolation.NONE; | ||
var Interpolation = require('../proto/compiled').IndexMapping.Interpolation; | ||
return Interpolation.NONE; | ||
}; | ||
@@ -97,0 +99,0 @@ return KeyMapping; |
@@ -27,3 +27,2 @@ "use strict"; | ||
var math_1 = require("../math"); | ||
var compiled_1 = require("../proto/compiled"); | ||
/** | ||
@@ -50,3 +49,3 @@ * A fast KeyMapping that approximates the memory-optimal one | ||
LinearlyInterpolatedMapping.prototype._log2Approx = function (value) { | ||
var _a = math_1.frexp(value), mantissa = _a[0], exponent = _a[1]; | ||
var _a = (0, math_1.frexp)(value), mantissa = _a[0], exponent = _a[1]; | ||
var significand = 2 * mantissa - 1; | ||
@@ -59,3 +58,3 @@ return significand + (exponent - 1); | ||
var mantissa = (value - exponent + 2) / 2; | ||
return math_1.ldexp(mantissa, exponent); | ||
return (0, math_1.ldexp)(mantissa, exponent); | ||
}; | ||
@@ -69,3 +68,4 @@ LinearlyInterpolatedMapping.prototype._logGamma = function (value) { | ||
LinearlyInterpolatedMapping.prototype._protoInterpolation = function () { | ||
return compiled_1.IndexMapping.Interpolation.LINEAR; | ||
var Interpolation = require('../proto/compiled').IndexMapping.Interpolation; | ||
return Interpolation.LINEAR; | ||
}; | ||
@@ -72,0 +72,0 @@ return LinearlyInterpolatedMapping; |
@@ -26,3 +26,2 @@ "use strict"; | ||
var KeyMapping_1 = require("./KeyMapping"); | ||
var compiled_1 = require("../proto/compiled"); | ||
/** | ||
@@ -48,3 +47,4 @@ * A memory-optimal KeyMapping, i.e., given a targeted relative accuracy, it | ||
LogarithmicMapping.prototype._protoInterpolation = function () { | ||
return compiled_1.IndexMapping.Interpolation.NONE; | ||
var Interpolation = require('../proto/compiled').IndexMapping.Interpolation; | ||
return Interpolation.NONE; | ||
}; | ||
@@ -51,0 +51,0 @@ return LogarithmicMapping; |
@@ -65,3 +65,3 @@ "use strict"; | ||
if (collapseEndIndex > collapseStartIndex) { | ||
var collapseCount = util_1.sumOfRange(store.bins, collapseStartIndex, collapseEndIndex); | ||
var collapseCount = (0, util_1.sumOfRange)(store.bins, collapseStartIndex, collapseEndIndex); | ||
this.bins[this.length() - 1] += collapseCount; | ||
@@ -111,3 +111,3 @@ } | ||
var collapseEndIndex = this.maxKey - this.offset + 1; | ||
var collapsedCount = util_1.sumOfRange(this.bins, collapseStartIndex, collapseEndIndex); | ||
var collapsedCount = (0, util_1.sumOfRange)(this.bins, collapseStartIndex, collapseEndIndex); | ||
this.bins.fill(0, collapseStartIndex, collapseEndIndex); | ||
@@ -114,0 +114,0 @@ this.bins[collapseStartIndex - 1] += collapsedCount; |
@@ -65,3 +65,3 @@ "use strict"; | ||
if (collapseEndIndex > collapseStartIndex) { | ||
var collapseCount = util_1.sumOfRange(store.bins, collapseStartIndex, collapseEndIndex); | ||
var collapseCount = (0, util_1.sumOfRange)(store.bins, collapseStartIndex, collapseEndIndex); | ||
this.bins[0] += collapseCount; | ||
@@ -111,3 +111,3 @@ } | ||
var collapseEndIndex = newMinKey - this.offset; | ||
var collapsedCount = util_1.sumOfRange(this.bins, collapseStartIndex, collapseEndIndex); | ||
var collapsedCount = (0, util_1.sumOfRange)(this.bins, collapseStartIndex, collapseEndIndex); | ||
this.bins.fill(0, collapseStartIndex, collapseEndIndex); | ||
@@ -114,0 +114,0 @@ this.bins[collapseEndIndex] += collapsedCount; |
@@ -8,6 +8,10 @@ "use strict"; | ||
*/ | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -17,3 +21,2 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var util_1 = require("./util"); | ||
var compiled_1 = require("../proto/compiled"); | ||
/** The default number of bins to grow when necessary */ | ||
@@ -98,3 +101,3 @@ var CHUNK_SIZE = 128; | ||
if (collapseEndIndex > collapseStartIndex) { | ||
var collapseCount = util_1.sumOfRange(store.bins, collapseStartIndex, collapseEndIndex); | ||
var collapseCount = (0, util_1.sumOfRange)(store.bins, collapseStartIndex, collapseEndIndex); | ||
this.bins[0] += collapseCount; | ||
@@ -116,3 +119,3 @@ } | ||
DenseStore.prototype.copy = function (store) { | ||
this.bins = __spreadArray([], store.bins); | ||
this.bins = __spreadArray([], store.bins, true); | ||
this.count = store.count; | ||
@@ -198,3 +201,4 @@ this.minKey = store.minKey; | ||
DenseStore.prototype.toProto = function () { | ||
return compiled_1.Store.create({ | ||
var ProtoStore = require('../proto/compiled').Store; | ||
return ProtoStore.create({ | ||
contiguousBinCounts: this.bins, | ||
@@ -201,0 +205,0 @@ contiguousBinIndexOffset: this.offset |
{ | ||
"name": "@datadog/sketches-js", | ||
"version": "1.0.5", | ||
"version": "2.0.0", | ||
"description": "TypeScript implementation of DDSketch, a distributed quantile sketch algorithm ", | ||
@@ -34,5 +34,3 @@ "license": "Apache-2.0", | ||
}, | ||
"dependencies": { | ||
"protobufjs": "^6.11.3" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -47,2 +45,3 @@ "@types/jest": "^26.0.14", | ||
"prettier": "^2.1.2", | ||
"protobufjs": "^6.11.3", | ||
"ts-jest": "^26.4.0", | ||
@@ -49,0 +48,0 @@ "typescript": "^4.0.3" |
@@ -19,2 +19,12 @@ # sketches-js | ||
When using Protobuf serialization, the [protobufjs](https://www.npmjs.com/package/protobufjs) module must also be installed manually: | ||
```sh | ||
# NPM | ||
npm install protobufjs | ||
# Yarn | ||
yarn add protobufjs | ||
``` | ||
## Usage | ||
@@ -21,0 +31,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105439
0
2364
120
11
- Removedprotobufjs@^6.11.3
- Removed@protobufjs/aspromise@1.1.2(transitive)
- Removed@protobufjs/base64@1.1.2(transitive)
- Removed@protobufjs/codegen@2.0.4(transitive)
- Removed@protobufjs/eventemitter@1.1.0(transitive)
- Removed@protobufjs/fetch@1.1.0(transitive)
- Removed@protobufjs/float@1.0.2(transitive)
- Removed@protobufjs/inquire@1.1.0(transitive)
- Removed@protobufjs/path@1.1.2(transitive)
- Removed@protobufjs/pool@1.1.0(transitive)
- Removed@protobufjs/utf8@1.1.0(transitive)
- Removed@types/long@4.0.2(transitive)
- Removed@types/node@22.10.5(transitive)
- Removedlong@4.0.0(transitive)
- Removedprotobufjs@6.11.4(transitive)
- Removedundici-types@6.20.0(transitive)