Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const position = ([] as number[]).concat(...indices.map(i => {
// Which ring we are on as a value between 0 and 1
const idx = bounds.le(cRows, i)
const phi = idx / rows.length
// How far around the ring we are as a value between 0 and 1
const theta = (i - cRows[idx]) / rows[idx]
return [phi, theta]
}))
function lod (lox, loy, hix, hiy, maxLevel) {
let ranges = []
for (let level = 0; level < maxLevel; level++) {
let levelGroups = groups[level]
let from = offsets[level][0]
let levelGroupStart = group(lox, loy, level)
let levelGroupEnd = group(hix, hiy, level)
// FIXME: utilize sublevels to speed up search range here
let startOffset = search.ge(levelGroups, levelGroupStart)
let endOffset = search.gt(levelGroups, levelGroupEnd, startOffset, levelGroups.length - 1)
ranges[level] = [startOffset + from, endOffset + from]
}
return ranges
}
private makeLines(series: DataSeries): Group {
// Get the range we are viewing
let end = this.now + series.timeDelta
let start = end - this.model.bufferSeconds
let values = series.series
end = Math.max(0, bounds.lt(values, Vector2.of(), p => p.x - end))
start = Math.max(0, bounds.lt(values, Vector2.of(), p => p.x - start))
values = values.slice(start, end)
// If we have no values, don't draw the line
if (values.length === 0) {
return Group.of()
}
const lines = []
if (series.highlight) {
lines.push(Shape.of(
PathGeometry.of(values),
LineAppearance.of({
stroke: {
color: '#ffff00',
width: 8,
const min = this.dataSeries.reduce((minValue, series: DataSeries) => {
// Get the range we are viewing
let end = this.now + series.timeDelta
let start = end - this.model.bufferSeconds
const values = series.series
end = Math.max(0, bounds.lt(values, Vector2.of(), p => p.x - end))
start = Math.max(0, bounds.lt(values, Vector2.of(), p => p.x - start))
return values.slice(start, end).reduce((min, value) => {
return Math.min(min, value.y)
}, minValue)
}, Number.MAX_VALUE)
return min === Number.MAX_VALUE ? -1 : min
function lod (lox, loy, hix, hiy, maxLevel) {
let ranges = []
for (let level = 0; level < maxLevel; level++) {
let levelGroups = groups[level]
let from = offsets[level][0]
let levelGroupStart = group(lox, loy, level)
let levelGroupEnd = group(hix, hiy, level)
// FIXME: utilize sublevels to speed up search range here
let startOffset = search.ge(levelGroups, levelGroupStart)
let endOffset = search.gt(levelGroups, levelGroupEnd, startOffset, levelGroups.length - 1)
ranges[level] = [startOffset + from, endOffset + from]
}
return ranges
}
});
var sortedHigh = this._orderedRanges.map(
function (r) {
return { v: r.max, b: r.isMaxInclusive };
});
// this for loop doesn't invoke any async callback
for (var i = 0; i < providedQueryRanges.length; i++) {
var queryRange = providedQueryRanges[i];
if (queryRange.isEmpty()) {
continue;
}
var minIndex = bs.le(sortedLow, { v: queryRange.min, b: !queryRange.isMinInclusive }, this._vbCompareFunction);
assert.ok(minIndex >= 0, "error in collection routing map, queried value is less than the start range.");
var maxIndex = bs.ge(sortedHigh, { v: queryRange.max, b: queryRange.isMaxInclusive }, this._vbCompareFunction);
assert.ok(maxIndex < sortedHigh.length, "error in collection routing map, queried value is greater than the end range.");
// the for loop doesn't invoke any async callback
for (var j = minIndex; j < maxIndex + 1; j++) {
if (queryRange.overlaps(this._orderedRanges[j])) {
minToPartitionRange[this._orderedPartitionKeyRanges[j][_PartitionKeyRange.MinInclusive]] = this._orderedPartitionKeyRanges[j];
}
}
}
var overlappingPartitionKeyRanges = _.values(minToPartitionRange);
var getKey = function (r) {
return r[_PartitionKeyRange.MinInclusive];
};
return _.sortBy(overlappingPartitionKeyRanges, getKey);
updateObject: function(name, obj) {
var oldindex = -1;
if (this.map.hasOwnProperty(name)) {
var oldobj = this.map[name];
// Already up to date: nothing to do!
if (obj !== null && oldobj.mtime == obj.mtime) {
return;
}
oldindex = lb(this.list, oldobj, byMtime);
if (obj === null) {
// Remove the item at its old position
this.list.splice(oldindex, 1);
delete this.map[name];
return;
}
}
if (obj == null) {
// If the file doesn't exist, there is nothing to insert.
return;
}
// Insert the item at its new position
this.map[name] = obj;
var index = lb(this.list, obj, byMtime);
if (oldindex == -1) {
// It's a new item: insert it.
}
oldindex = lb(this.list, oldobj, byMtime);
if (obj === null) {
// Remove the item at its old position
this.list.splice(oldindex, 1);
delete this.map[name];
return;
}
}
if (obj == null) {
// If the file doesn't exist, there is nothing to insert.
return;
}
// Insert the item at its new position
this.map[name] = obj;
var index = lb(this.list, obj, byMtime);
if (oldindex == -1) {
// It's a new item: insert it.
this.list.splice(index, 0, obj);
} else {
// It's moving in the list: shift the old items over, then set it.
if (index < oldindex) {
for (var j = oldindex; j > index; --j) {
this.list[j] = this.list[j - 1];
}
} else if (index > oldindex) {
// If shifting right, our target index is off-by-one because
// we ourselves are to the left of our destination index.
index -= 1;
for (var j = oldindex; j < index; ++j) {
this.list[j] = this.list[j + 1];
}
console.log(
dedent`${opName}, Operations, ${ops}
${opName}, AverageLatency(us), ${stats.mean(lats)}
${opName}, LatencyVariance(us), ${stats.stdev(lats)}
${opName}, MinLatency(us), ${lats[0]}
${opName}, MaxLatency(us), ${lats[lats.length - 1]}
${opName}, 95thPercentileLatency(us), ${stats.percentile(lats, 0.95)}
${opName}, 99thPercentileLatency(us), ${stats.percentile(lats, 0.99)}
${opName}, 99.9thPercentileLatency(us), ${stats.percentile(lats, 0.999)}
${opName}, Return=OK, ${ops}`
);
for (let i = 0; i < numBucket; i++) {
const hi = bounds.lt(lats, i + 1);
const lo = bounds.le(lats, i);
console.log(`${opName}, ${i}, ${hi - lo}`);
}
const lo = bounds.le(lats, numBucket);
console.log(`${opName}, ${numBucket}, ${ops - lo}`);
});
}
const opName = `[${operation.toUpperCase()}]`;
console.log(
dedent`${opName}, Operations, ${ops}
${opName}, AverageLatency(us), ${stats.mean(lats)}
${opName}, LatencyVariance(us), ${stats.stdev(lats)}
${opName}, MinLatency(us), ${lats[0]}
${opName}, MaxLatency(us), ${lats[lats.length - 1]}
${opName}, 95thPercentileLatency(us), ${stats.percentile(lats, 0.95)}
${opName}, 99thPercentileLatency(us), ${stats.percentile(lats, 0.99)}
${opName}, 99.9thPercentileLatency(us), ${stats.percentile(lats, 0.999)}
${opName}, Return=OK, ${ops}`
);
for (let i = 0; i < numBucket; i++) {
const hi = bounds.lt(lats, i + 1);
const lo = bounds.le(lats, i);
console.log(`${opName}, ${i}, ${hi - lo}`);
}
const lo = bounds.le(lats, numBucket);
console.log(`${opName}, ${numBucket}, ${ops - lo}`);
});
}