repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/fdt/FdtSketch.java | FdtSketch.computeLgK | static int computeLgK(final double threshold, final double rse) {
final double v = Math.ceil(1.0 / (threshold * rse * rse));
final int lgK = (int) Math.ceil(Math.log(v) / Math.log(2));
if (lgK > MAX_LG_NOM_LONGS) {
throw new SketchesArgumentException("Requested Sketch (LgK = " + lgK + " > 2^26), "
... | java | static int computeLgK(final double threshold, final double rse) {
final double v = Math.ceil(1.0 / (threshold * rse * rse));
final int lgK = (int) Math.ceil(Math.log(v) / Math.log(2));
if (lgK > MAX_LG_NOM_LONGS) {
throw new SketchesArgumentException("Requested Sketch (LgK = " + lgK + " > 2^26), "
... | [
"static",
"int",
"computeLgK",
"(",
"final",
"double",
"threshold",
",",
"final",
"double",
"rse",
")",
"{",
"final",
"double",
"v",
"=",
"Math",
".",
"ceil",
"(",
"1.0",
"/",
"(",
"threshold",
"*",
"rse",
"*",
"rse",
")",
")",
";",
"final",
"int",
... | Computes LgK given the threshold and RSE.
@param threshold the fraction, between zero and 1.0, of the total stream length that defines
a "Frequent" (or heavy) tuple.
@param rse the maximum Relative Standard Error for the estimate of the distinct population of a
reported tuple (selected with a primary key) at the thresh... | [
"Computes",
"LgK",
"given",
"the",
"threshold",
"and",
"RSE",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/fdt/FdtSketch.java#L164-L172 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/ItemsAuxiliary.java | ItemsAuxiliary.getQuantile | T getQuantile(final double fRank) {
checkFractionalRankBounds(fRank);
if (auxN_ <= 0) { return null; }
final long pos = QuantilesHelper.posOfPhi(fRank, auxN_);
return approximatelyAnswerPositionalQuery(pos);
} | java | T getQuantile(final double fRank) {
checkFractionalRankBounds(fRank);
if (auxN_ <= 0) { return null; }
final long pos = QuantilesHelper.posOfPhi(fRank, auxN_);
return approximatelyAnswerPositionalQuery(pos);
} | [
"T",
"getQuantile",
"(",
"final",
"double",
"fRank",
")",
"{",
"checkFractionalRankBounds",
"(",
"fRank",
")",
";",
"if",
"(",
"auxN_",
"<=",
"0",
")",
"{",
"return",
"null",
";",
"}",
"final",
"long",
"pos",
"=",
"QuantilesHelper",
".",
"posOfPhi",
"(",... | Get the estimated quantile given a fractional rank.
@param fRank the fractional rank where: 0 ≤ fRank ≤ 1.0.
@return the estimated quantile | [
"Get",
"the",
"estimated",
"quantile",
"given",
"a",
"fractional",
"rank",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/ItemsAuxiliary.java#L71-L76 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/ItemsAuxiliary.java | ItemsAuxiliary.approximatelyAnswerPositionalQuery | @SuppressWarnings("unchecked")
private T approximatelyAnswerPositionalQuery(final long pos) {
assert 0 <= pos;
assert pos < auxN_;
final int index = QuantilesHelper.chunkContainingPos(auxCumWtsArr_, pos);
return (T) this.auxSamplesArr_[index];
} | java | @SuppressWarnings("unchecked")
private T approximatelyAnswerPositionalQuery(final long pos) {
assert 0 <= pos;
assert pos < auxN_;
final int index = QuantilesHelper.chunkContainingPos(auxCumWtsArr_, pos);
return (T) this.auxSamplesArr_[index];
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"T",
"approximatelyAnswerPositionalQuery",
"(",
"final",
"long",
"pos",
")",
"{",
"assert",
"0",
"<=",
"pos",
";",
"assert",
"pos",
"<",
"auxN_",
";",
"final",
"int",
"index",
"=",
"QuantilesHelper... | Assuming that there are n items in the true stream, this asks what
item would appear in position 0 ≤ pos < n of a hypothetical sorted
version of that stream.
<p>Note that since that since the true stream is unavailable,
we don't actually answer the question for that stream, but rather for
a <i>different</i> stre... | [
"Assuming",
"that",
"there",
"are",
"n",
"items",
"in",
"the",
"true",
"stream",
"this",
"asks",
"what",
"item",
"would",
"appear",
"in",
"position",
"0",
"&le",
";",
"pos",
"<",
";",
"n",
"of",
"a",
"hypothetical",
"sorted",
"version",
"of",
"that",
... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/ItemsAuxiliary.java#L90-L96 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/ItemsAuxiliary.java | ItemsAuxiliary.populateFromItemsSketch | private final static <T> void populateFromItemsSketch(
final int k, final long n, final long bitPattern, final T[] combinedBuffer,
final int baseBufferCount, final int numSamples, final T[] itemsArr, final long[] cumWtsArr,
final Comparator<? super T> comparator) {
long weight = 1;
int nxt = 0... | java | private final static <T> void populateFromItemsSketch(
final int k, final long n, final long bitPattern, final T[] combinedBuffer,
final int baseBufferCount, final int numSamples, final T[] itemsArr, final long[] cumWtsArr,
final Comparator<? super T> comparator) {
long weight = 1;
int nxt = 0... | [
"private",
"final",
"static",
"<",
"T",
">",
"void",
"populateFromItemsSketch",
"(",
"final",
"int",
"k",
",",
"final",
"long",
"n",
",",
"final",
"long",
"bitPattern",
",",
"final",
"T",
"[",
"]",
"combinedBuffer",
",",
"final",
"int",
"baseBufferCount",
... | Populate the arrays and registers from an ItemsSketch
@param <T> the data type
@param k K value of sketch
@param n The current size of the stream
@param bitPattern the bit pattern for valid log levels
@param combinedBuffer the combined buffer reference
@param baseBufferCount the count of the base buffer
@param numSampl... | [
"Populate",
"the",
"arrays",
"and",
"registers",
"from",
"an",
"ItemsSketch"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/ItemsAuxiliary.java#L111-L146 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/DirectCompactUnorderedSketch.java | DirectCompactUnorderedSketch.wrapInstance | static DirectCompactUnorderedSketch wrapInstance(final Memory srcMem, final long seed) {
final short memSeedHash = srcMem.getShort(SEED_HASH_SHORT);
final short computedSeedHash = computeSeedHash(seed);
checkSeedHashes(memSeedHash, computedSeedHash);
return new DirectCompactUnorderedSketch(srcMem);
} | java | static DirectCompactUnorderedSketch wrapInstance(final Memory srcMem, final long seed) {
final short memSeedHash = srcMem.getShort(SEED_HASH_SHORT);
final short computedSeedHash = computeSeedHash(seed);
checkSeedHashes(memSeedHash, computedSeedHash);
return new DirectCompactUnorderedSketch(srcMem);
} | [
"static",
"DirectCompactUnorderedSketch",
"wrapInstance",
"(",
"final",
"Memory",
"srcMem",
",",
"final",
"long",
"seed",
")",
"{",
"final",
"short",
"memSeedHash",
"=",
"srcMem",
".",
"getShort",
"(",
"SEED_HASH_SHORT",
")",
";",
"final",
"short",
"computedSeedHa... | Wraps the given Memory, which must be a SerVer 3, unordered, Compact Sketch image.
Must check the validity of the Memory before calling.
@param srcMem <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
@return this ... | [
"Wraps",
"the",
"given",
"Memory",
"which",
"must",
"be",
"a",
"SerVer",
"3",
"unordered",
"Compact",
"Sketch",
"image",
".",
"Must",
"check",
"the",
"validity",
"of",
"the",
"Memory",
"before",
"calling",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/DirectCompactUnorderedSketch.java#L41-L46 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/DirectCompactUnorderedSketch.java | DirectCompactUnorderedSketch.compact | static DirectCompactUnorderedSketch compact(final UpdateSketch sketch,
final WritableMemory dstMem) {
final int curCount = sketch.getRetainedEntries(true);
long thetaLong = sketch.getThetaLong();
boolean empty = sketch.isEmpty();
thetaLong = thetaOnCompact(empty, curCount, thetaLong);
empty = ... | java | static DirectCompactUnorderedSketch compact(final UpdateSketch sketch,
final WritableMemory dstMem) {
final int curCount = sketch.getRetainedEntries(true);
long thetaLong = sketch.getThetaLong();
boolean empty = sketch.isEmpty();
thetaLong = thetaOnCompact(empty, curCount, thetaLong);
empty = ... | [
"static",
"DirectCompactUnorderedSketch",
"compact",
"(",
"final",
"UpdateSketch",
"sketch",
",",
"final",
"WritableMemory",
"dstMem",
")",
"{",
"final",
"int",
"curCount",
"=",
"sketch",
".",
"getRetainedEntries",
"(",
"true",
")",
";",
"long",
"thetaLong",
"=",
... | Constructs given an UpdateSketch.
@param sketch the given UpdateSketch
@param dstMem the given destination Memory. This clears it before use.
@return a DirectCompactUnorderedSketch | [
"Constructs",
"given",
"an",
"UpdateSketch",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/DirectCompactUnorderedSketch.java#L54-L70 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/DirectCompactUnorderedSketch.java | DirectCompactUnorderedSketch.compact | static DirectCompactUnorderedSketch compact(final long[] cache, final boolean empty,
final short seedHash, final int curCount, final long thetaLong, final WritableMemory dstMem) {
final int preLongs = computeCompactPreLongs(thetaLong, empty, curCount);
final int requiredFlags = READ_ONLY_FLAG_MASK | COMPA... | java | static DirectCompactUnorderedSketch compact(final long[] cache, final boolean empty,
final short seedHash, final int curCount, final long thetaLong, final WritableMemory dstMem) {
final int preLongs = computeCompactPreLongs(thetaLong, empty, curCount);
final int requiredFlags = READ_ONLY_FLAG_MASK | COMPA... | [
"static",
"DirectCompactUnorderedSketch",
"compact",
"(",
"final",
"long",
"[",
"]",
"cache",
",",
"final",
"boolean",
"empty",
",",
"final",
"short",
"seedHash",
",",
"final",
"int",
"curCount",
",",
"final",
"long",
"thetaLong",
",",
"final",
"WritableMemory",... | Constructs this sketch from correct, valid components.
@param cache in compact, ordered form
@param empty The correct <a href="{@docRoot}/resources/dictionary.html#empty">Empty</a>.
@param seedHash The correct
<a href="{@docRoot}/resources/dictionary.html#seedHash">Seed Hash</a>.
@param curCount correct value
@param th... | [
"Constructs",
"this",
"sketch",
"from",
"correct",
"valid",
"components",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/DirectCompactUnorderedSketch.java#L84-L91 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/ReservoirLongsSketch.java | ReservoirLongsSketch.getSamples | public long[] getSamples() {
if (itemsSeen_ == 0) {
return null;
}
final int numSamples = (int) Math.min(reservoirSize_, itemsSeen_);
return java.util.Arrays.copyOf(data_, numSamples);
} | java | public long[] getSamples() {
if (itemsSeen_ == 0) {
return null;
}
final int numSamples = (int) Math.min(reservoirSize_, itemsSeen_);
return java.util.Arrays.copyOf(data_, numSamples);
} | [
"public",
"long",
"[",
"]",
"getSamples",
"(",
")",
"{",
"if",
"(",
"itemsSeen_",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"final",
"int",
"numSamples",
"=",
"(",
"int",
")",
"Math",
".",
"min",
"(",
"reservoirSize_",
",",
"itemsSeen_",
")",
... | Returns a copy of the items in the reservoir. The returned array length may be smaller than the
reservoir capacity.
@return A copy of the reservoir array | [
"Returns",
"a",
"copy",
"of",
"the",
"items",
"in",
"the",
"reservoir",
".",
"The",
"returned",
"array",
"length",
"may",
"be",
"smaller",
"than",
"the",
"reservoir",
"capacity",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/ReservoirLongsSketch.java#L281-L287 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/adouble/DoubleSummary.java | DoubleSummary.fromMemory | public static DeserializeResult<DoubleSummary> fromMemory(final Memory mem) {
return new DeserializeResult<>(new DoubleSummary(mem.getDouble(VALUE_DOUBLE),
Mode.values()[mem.getByte(MODE_BYTE)]), SERIALIZED_SIZE_BYTES);
} | java | public static DeserializeResult<DoubleSummary> fromMemory(final Memory mem) {
return new DeserializeResult<>(new DoubleSummary(mem.getDouble(VALUE_DOUBLE),
Mode.values()[mem.getByte(MODE_BYTE)]), SERIALIZED_SIZE_BYTES);
} | [
"public",
"static",
"DeserializeResult",
"<",
"DoubleSummary",
">",
"fromMemory",
"(",
"final",
"Memory",
"mem",
")",
"{",
"return",
"new",
"DeserializeResult",
"<>",
"(",
"new",
"DoubleSummary",
"(",
"mem",
".",
"getDouble",
"(",
"VALUE_DOUBLE",
")",
",",
"Mo... | Creates an instance of the DoubleSummary given a serialized representation
@param mem Memory object with serialized DoubleSummary
@return DeserializedResult object, which contains a DoubleSummary object and number of bytes
read from the Memory | [
"Creates",
"an",
"instance",
"of",
"the",
"DoubleSummary",
"given",
"a",
"serialized",
"representation"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/adouble/DoubleSummary.java#L125-L128 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/ReservoirLongsUnion.java | ReservoirLongsUnion.update | public void update(final long datum) {
if (gadget_ == null) {
gadget_ = ReservoirLongsSketch.newInstance(maxK_);
}
gadget_.update(datum);
} | java | public void update(final long datum) {
if (gadget_ == null) {
gadget_ = ReservoirLongsSketch.newInstance(maxK_);
}
gadget_.update(datum);
} | [
"public",
"void",
"update",
"(",
"final",
"long",
"datum",
")",
"{",
"if",
"(",
"gadget_",
"==",
"null",
")",
"{",
"gadget_",
"=",
"ReservoirLongsSketch",
".",
"newInstance",
"(",
"maxK_",
")",
";",
"}",
"gadget_",
".",
"update",
"(",
"datum",
")",
";"... | Present this union with a long.
@param datum The given long datum. | [
"Present",
"this",
"union",
"with",
"a",
"long",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/ReservoirLongsUnion.java#L176-L181 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/PreambleUtil.java | PreambleUtil.preambleToString | static String preambleToString(final byte[] byteArr) {
final Memory mem = Memory.wrap(byteArr);
return preambleToString(mem);
} | java | static String preambleToString(final byte[] byteArr) {
final Memory mem = Memory.wrap(byteArr);
return preambleToString(mem);
} | [
"static",
"String",
"preambleToString",
"(",
"final",
"byte",
"[",
"]",
"byteArr",
")",
"{",
"final",
"Memory",
"mem",
"=",
"Memory",
".",
"wrap",
"(",
"byteArr",
")",
";",
"return",
"preambleToString",
"(",
"mem",
")",
";",
"}"
] | Returns a human readable string summary of the preamble state of the given byte array.
Used primarily in testing.
@param byteArr the given byte array.
@return the summary preamble string. | [
"Returns",
"a",
"human",
"readable",
"string",
"summary",
"of",
"the",
"preamble",
"state",
"of",
"the",
"given",
"byte",
"array",
".",
"Used",
"primarily",
"in",
"testing",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/PreambleUtil.java#L196-L199 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesAuxiliary.java | DoublesAuxiliary.populateFromDoublesSketch | private final static void populateFromDoublesSketch(
final int k, final long n, final long bitPattern,
final DoublesSketchAccessor sketchAccessor,
final double[] itemsArr, final long[] cumWtsArr) {
long weight = 1;
int nxt = 0;
long bits = bitPattern;
assert bits == (n / (2... | java | private final static void populateFromDoublesSketch(
final int k, final long n, final long bitPattern,
final DoublesSketchAccessor sketchAccessor,
final double[] itemsArr, final long[] cumWtsArr) {
long weight = 1;
int nxt = 0;
long bits = bitPattern;
assert bits == (n / (2... | [
"private",
"final",
"static",
"void",
"populateFromDoublesSketch",
"(",
"final",
"int",
"k",
",",
"final",
"long",
"n",
",",
"final",
"long",
"bitPattern",
",",
"final",
"DoublesSketchAccessor",
"sketchAccessor",
",",
"final",
"double",
"[",
"]",
"itemsArr",
","... | Populate the arrays and registers from a DoublesSketch
@param k K value of sketch
@param n The current size of the stream
@param bitPattern the bit pattern for valid log levels
@param sketchAccessor A DoublesSketchAccessor around the sketch
@param itemsArr the consolidated array of all items from the sketch populated h... | [
"Populate",
"the",
"arrays",
"and",
"registers",
"from",
"a",
"DoublesSketch"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesAuxiliary.java#L96-L133 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesAuxiliary.java | DoublesAuxiliary.blockyTandemMergeSort | static void blockyTandemMergeSort(final double[] keyArr, final long[] valArr, final int arrLen,
final int blkSize) {
assert blkSize >= 1;
if (arrLen <= blkSize) { return; }
int numblks = arrLen / blkSize;
if ((numblks * blkSize) < arrLen) { numblks += 1; }
assert ((numblks * blkSize) >= arrLen... | java | static void blockyTandemMergeSort(final double[] keyArr, final long[] valArr, final int arrLen,
final int blkSize) {
assert blkSize >= 1;
if (arrLen <= blkSize) { return; }
int numblks = arrLen / blkSize;
if ((numblks * blkSize) < arrLen) { numblks += 1; }
assert ((numblks * blkSize) >= arrLen... | [
"static",
"void",
"blockyTandemMergeSort",
"(",
"final",
"double",
"[",
"]",
"keyArr",
",",
"final",
"long",
"[",
"]",
"valArr",
",",
"final",
"int",
"arrLen",
",",
"final",
"int",
"blkSize",
")",
"{",
"assert",
"blkSize",
">=",
"1",
";",
"if",
"(",
"a... | used by DoublesAuxiliary and UtilTest | [
"used",
"by",
"DoublesAuxiliary",
"and",
"UtilTest"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesAuxiliary.java#L147-L163 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesAuxiliary.java | DoublesAuxiliary.tandemMerge | private static void tandemMerge(final double[] keySrc, final long[] valSrc,
final int arrStart1, final int arrLen1,
final int arrStart2, final int arrLen2,
final double[] keyDst, final long[] valDst,
... | java | private static void tandemMerge(final double[] keySrc, final long[] valSrc,
final int arrStart1, final int arrLen1,
final int arrStart2, final int arrLen2,
final double[] keyDst, final long[] valDst,
... | [
"private",
"static",
"void",
"tandemMerge",
"(",
"final",
"double",
"[",
"]",
"keySrc",
",",
"final",
"long",
"[",
"]",
"valSrc",
",",
"final",
"int",
"arrStart1",
",",
"final",
"int",
"arrLen1",
",",
"final",
"int",
"arrStart2",
",",
"final",
"int",
"ar... | Performs two merges in tandem. One of them provides the sort keys
while the other one passively undergoes the same data motion.
@param keySrc key source
@param valSrc value source
@param arrStart1 Array 1 start offset
@param arrLen1 Array 1 length
@param arrStart2 Array 2 start offset
@param arrLen2 Array 2 length
@par... | [
"Performs",
"two",
"merges",
"in",
"tandem",
".",
"One",
"of",
"them",
"provides",
"the",
"sort",
"keys",
"while",
"the",
"other",
"one",
"passively",
"undergoes",
"the",
"same",
"data",
"motion",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesAuxiliary.java#L235-L267 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hash/MurmurHash3v2.java | MurmurHash3v2.hash | public static long[] hash(final long[] in, final long seed) {
if ((in == null) || (in.length == 0)) {
return emptyOrNull(seed, new long[2]);
}
return hash(Memory.wrap(in), 0L, in.length << 3, seed, new long[2]);
} | java | public static long[] hash(final long[] in, final long seed) {
if ((in == null) || (in.length == 0)) {
return emptyOrNull(seed, new long[2]);
}
return hash(Memory.wrap(in), 0L, in.length << 3, seed, new long[2]);
} | [
"public",
"static",
"long",
"[",
"]",
"hash",
"(",
"final",
"long",
"[",
"]",
"in",
",",
"final",
"long",
"seed",
")",
"{",
"if",
"(",
"(",
"in",
"==",
"null",
")",
"||",
"(",
"in",
".",
"length",
"==",
"0",
")",
")",
"{",
"return",
"emptyOrNul... | Returns a 128-bit hash of the input.
Provided for compatibility with older version of MurmurHash3,
but empty or null input now returns a hash.
@param in long array
@param seed A long valued seed.
@return the hash | [
"Returns",
"a",
"128",
"-",
"bit",
"hash",
"of",
"the",
"input",
".",
"Provided",
"for",
"compatibility",
"with",
"older",
"version",
"of",
"MurmurHash3",
"but",
"empty",
"or",
"null",
"input",
"now",
"returns",
"a",
"hash",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hash/MurmurHash3v2.java#L46-L51 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hash/MurmurHash3v2.java | MurmurHash3v2.hash | public static long[] hash(final String in, final long seed, final long[] hashOut) {
if ((in == null) || (in.length() == 0)) {
return emptyOrNull(seed, hashOut);
}
final byte[] byteArr = in.getBytes(UTF_8);
return hash(Memory.wrap(byteArr), 0L, byteArr.length, seed, hashOut);
} | java | public static long[] hash(final String in, final long seed, final long[] hashOut) {
if ((in == null) || (in.length() == 0)) {
return emptyOrNull(seed, hashOut);
}
final byte[] byteArr = in.getBytes(UTF_8);
return hash(Memory.wrap(byteArr), 0L, byteArr.length, seed, hashOut);
} | [
"public",
"static",
"long",
"[",
"]",
"hash",
"(",
"final",
"String",
"in",
",",
"final",
"long",
"seed",
",",
"final",
"long",
"[",
"]",
"hashOut",
")",
"{",
"if",
"(",
"(",
"in",
"==",
"null",
")",
"||",
"(",
"in",
".",
"length",
"(",
")",
"=... | Returns a 128-bit hash of the input.
@param in a String
@param seed A long valued seed.
@param hashOut A long array of size 2
@return the hash | [
"Returns",
"a",
"128",
"-",
"bit",
"hash",
"of",
"the",
"input",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hash/MurmurHash3v2.java#L137-L143 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hash/MurmurHash3v2.java | MurmurHash3v2.mixK1 | private static long mixK1(long k1) {
k1 *= C1;
k1 = Long.rotateLeft(k1, 31);
k1 *= C2;
return k1;
} | java | private static long mixK1(long k1) {
k1 *= C1;
k1 = Long.rotateLeft(k1, 31);
k1 *= C2;
return k1;
} | [
"private",
"static",
"long",
"mixK1",
"(",
"long",
"k1",
")",
"{",
"k1",
"*=",
"C1",
";",
"k1",
"=",
"Long",
".",
"rotateLeft",
"(",
"k1",
",",
"31",
")",
";",
"k1",
"*=",
"C2",
";",
"return",
"k1",
";",
"}"
] | Self mix of k1
@param k1 input argument
@return mix | [
"Self",
"mix",
"of",
"k1"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hash/MurmurHash3v2.java#L282-L287 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hash/MurmurHash3v2.java | MurmurHash3v2.mixK2 | private static long mixK2(long k2) {
k2 *= C2;
k2 = Long.rotateLeft(k2, 33);
k2 *= C1;
return k2;
} | java | private static long mixK2(long k2) {
k2 *= C2;
k2 = Long.rotateLeft(k2, 33);
k2 *= C1;
return k2;
} | [
"private",
"static",
"long",
"mixK2",
"(",
"long",
"k2",
")",
"{",
"k2",
"*=",
"C2",
";",
"k2",
"=",
"Long",
".",
"rotateLeft",
"(",
"k2",
",",
"33",
")",
";",
"k2",
"*=",
"C1",
";",
"return",
"k2",
";",
"}"
] | Self mix of k2
@param k2 input argument
@return mix | [
"Self",
"mix",
"of",
"k2"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hash/MurmurHash3v2.java#L295-L300 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/ItemsByteArrayImpl.java | ItemsByteArrayImpl.combinedBufferToItemsArray | @SuppressWarnings("unchecked")
private static <T> T[] combinedBufferToItemsArray(final ItemsSketch<T> sketch,
final boolean ordered) {
final int extra = 2; // extra space for min and max values
final int outArrCap = sketch.getRetainedItems();
final T minValue = sketch.getMinValue();
final T[] ou... | java | @SuppressWarnings("unchecked")
private static <T> T[] combinedBufferToItemsArray(final ItemsSketch<T> sketch,
final boolean ordered) {
final int extra = 2; // extra space for min and max values
final int outArrCap = sketch.getRetainedItems();
final T minValue = sketch.getMinValue();
final T[] ou... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"combinedBufferToItemsArray",
"(",
"final",
"ItemsSketch",
"<",
"T",
">",
"sketch",
",",
"final",
"boolean",
"ordered",
")",
"{",
"final",
"int",
"extra",
... | Returns an array of items in compact form, including min and max extracted from the
Combined Buffer.
@param <T> the data type
@param sketch a type of ItemsSketch
@param ordered true if the desired form of the resulting array has the base buffer sorted.
@return an array of items, including min and max extracted from the... | [
"Returns",
"an",
"array",
"of",
"items",
"in",
"compact",
"form",
"including",
"min",
"and",
"max",
"extracted",
"from",
"the",
"Combined",
"Buffer",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/ItemsByteArrayImpl.java#L77-L110 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/JaccardSimilarity.java | JaccardSimilarity.exactlyEqual | public static boolean exactlyEqual(final Sketch sketchA, final Sketch sketchB) {
//Corner case checks
if ((sketchA == null) || (sketchB == null)) { return false; }
if (sketchA == sketchB) { return true; }
if (sketchA.isEmpty() && sketchB.isEmpty()) { return true; }
if (sketchA.isEmpty() || sketchB.i... | java | public static boolean exactlyEqual(final Sketch sketchA, final Sketch sketchB) {
//Corner case checks
if ((sketchA == null) || (sketchB == null)) { return false; }
if (sketchA == sketchB) { return true; }
if (sketchA.isEmpty() && sketchB.isEmpty()) { return true; }
if (sketchA.isEmpty() || sketchB.i... | [
"public",
"static",
"boolean",
"exactlyEqual",
"(",
"final",
"Sketch",
"sketchA",
",",
"final",
"Sketch",
"sketchB",
")",
"{",
"//Corner case checks",
"if",
"(",
"(",
"sketchA",
"==",
"null",
")",
"||",
"(",
"sketchB",
"==",
"null",
")",
")",
"{",
"return"... | Returns true if the two given sketches have exactly the same hash values and the same
theta values. Thus, they are equivalent.
@param sketchA the given sketch A
@param sketchB the given sketch B
@return true if the two given sketches have exactly the same hash values and the same
theta values. | [
"Returns",
"true",
"if",
"the",
"two",
"given",
"sketches",
"have",
"exactly",
"the",
"same",
"hash",
"values",
"and",
"the",
"same",
"theta",
"values",
".",
"Thus",
"they",
"are",
"equivalent",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/JaccardSimilarity.java#L92-L119 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/Union.java | Union.update | public void update(final Sketch<S> sketchIn) {
if (sketchIn == null || sketchIn.isEmpty()) { return; }
if (sketchIn.theta_ < theta_) { theta_ = sketchIn.theta_; }
final SketchIterator<S> it = sketchIn.iterator();
while (it.next()) {
sketch_.merge(it.getKey(), it.getSummary(), summarySetOps_);
... | java | public void update(final Sketch<S> sketchIn) {
if (sketchIn == null || sketchIn.isEmpty()) { return; }
if (sketchIn.theta_ < theta_) { theta_ = sketchIn.theta_; }
final SketchIterator<S> it = sketchIn.iterator();
while (it.next()) {
sketch_.merge(it.getKey(), it.getSummary(), summarySetOps_);
... | [
"public",
"void",
"update",
"(",
"final",
"Sketch",
"<",
"S",
">",
"sketchIn",
")",
"{",
"if",
"(",
"sketchIn",
"==",
"null",
"||",
"sketchIn",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"sketchIn",
".",
"theta_",
"<",
"thet... | Updates the internal set by adding entries from the given sketch
@param sketchIn input sketch to add to the internal set | [
"Updates",
"the",
"internal",
"set",
"by",
"adding",
"entries",
"from",
"the",
"given",
"sketch"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/Union.java#L48-L55 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/fdt/PostProcessor.java | PostProcessor.getGroupList | public List<Group> getGroupList(final int[] priKeyIndices, final int numStdDev,
final int limit) {
//allows subsequent queries with different priKeyIndices without rebuilding the map
if (!mapValid) { populateMap(priKeyIndices); }
return populateList(numStdDev, limit);
} | java | public List<Group> getGroupList(final int[] priKeyIndices, final int numStdDev,
final int limit) {
//allows subsequent queries with different priKeyIndices without rebuilding the map
if (!mapValid) { populateMap(priKeyIndices); }
return populateList(numStdDev, limit);
} | [
"public",
"List",
"<",
"Group",
">",
"getGroupList",
"(",
"final",
"int",
"[",
"]",
"priKeyIndices",
",",
"final",
"int",
"numStdDev",
",",
"final",
"int",
"limit",
")",
"{",
"//allows subsequent queries with different priKeyIndices without rebuilding the map",
"if",
... | Return the most frequent Groups associated with Primary Keys based on the size of the groups.
@param priKeyIndices the indices of the primary dimensions
@param numStdDev the number of standard deviations for the error bounds, this value is an
integer and must be one of 1, 2, or 3.
<a href="{@docRoot}/resources/dictiona... | [
"Return",
"the",
"most",
"frequent",
"Groups",
"associated",
"with",
"Primary",
"Keys",
"based",
"on",
"the",
"size",
"of",
"the",
"groups",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/fdt/PostProcessor.java#L73-L78 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/fdt/PostProcessor.java | PostProcessor.populateMap | private void populateMap(final int[] priKeyIndices) {
final SketchIterator<ArrayOfStringsSummary> it = sketch.iterator();
Arrays.fill(hashArr, 0L);
Arrays.fill(priKeyArr, null);
Arrays.fill(counterArr, 0);
groupCount = 0;
final int lgMapArrSize = Integer.numberOfTrailingZeros(mapArrSize);
w... | java | private void populateMap(final int[] priKeyIndices) {
final SketchIterator<ArrayOfStringsSummary> it = sketch.iterator();
Arrays.fill(hashArr, 0L);
Arrays.fill(priKeyArr, null);
Arrays.fill(counterArr, 0);
groupCount = 0;
final int lgMapArrSize = Integer.numberOfTrailingZeros(mapArrSize);
w... | [
"private",
"void",
"populateMap",
"(",
"final",
"int",
"[",
"]",
"priKeyIndices",
")",
"{",
"final",
"SketchIterator",
"<",
"ArrayOfStringsSummary",
">",
"it",
"=",
"sketch",
".",
"iterator",
"(",
")",
";",
"Arrays",
".",
"fill",
"(",
"hashArr",
",",
"0L",... | Scan each entry in the sketch. Count the number of duplicate occurrences of each
primary key in a hash map.
@param priKeyIndices identifies the primary key indices | [
"Scan",
"each",
"entry",
"in",
"the",
"sketch",
".",
"Count",
"the",
"number",
"of",
"duplicate",
"occurrences",
"of",
"each",
"primary",
"key",
"in",
"a",
"hash",
"map",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/fdt/PostProcessor.java#L85-L108 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/fdt/PostProcessor.java | PostProcessor.populateList | private List<Group> populateList(final int numStdDev, final int limit) {
final List<Group> list = new ArrayList<>();
for (int i = 0; i < mapArrSize; i++) {
if (hashArr[i] != 0) {
final String priKey = priKeyArr[i];
final int count = counterArr[i];
final double est = sketch.getEstim... | java | private List<Group> populateList(final int numStdDev, final int limit) {
final List<Group> list = new ArrayList<>();
for (int i = 0; i < mapArrSize; i++) {
if (hashArr[i] != 0) {
final String priKey = priKeyArr[i];
final int count = counterArr[i];
final double est = sketch.getEstim... | [
"private",
"List",
"<",
"Group",
">",
"populateList",
"(",
"final",
"int",
"numStdDev",
",",
"final",
"int",
"limit",
")",
"{",
"final",
"List",
"<",
"Group",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"... | Create the list of groups along with the error statistics
@param numStdDev number of standard deviations
@param limit the maximum size of the list to return
@return the list of groups along with the error statistics | [
"Create",
"the",
"list",
"of",
"groups",
"along",
"with",
"the",
"error",
"statistics"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/fdt/PostProcessor.java#L116-L142 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/fdt/PostProcessor.java | PostProcessor.getPrimaryKey | private static String getPrimaryKey(final String[] tuple, final int[] priKeyIndices,
final char sep) {
assert priKeyIndices.length < tuple.length;
final StringBuilder sb = new StringBuilder();
final int keys = priKeyIndices.length;
for (int i = 0; i < keys; i++) {
final int idx = priKeyIndic... | java | private static String getPrimaryKey(final String[] tuple, final int[] priKeyIndices,
final char sep) {
assert priKeyIndices.length < tuple.length;
final StringBuilder sb = new StringBuilder();
final int keys = priKeyIndices.length;
for (int i = 0; i < keys; i++) {
final int idx = priKeyIndic... | [
"private",
"static",
"String",
"getPrimaryKey",
"(",
"final",
"String",
"[",
"]",
"tuple",
",",
"final",
"int",
"[",
"]",
"priKeyIndices",
",",
"final",
"char",
"sep",
")",
"{",
"assert",
"priKeyIndices",
".",
"length",
"<",
"tuple",
".",
"length",
";",
... | also used by test | [
"also",
"used",
"by",
"test"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/fdt/PostProcessor.java#L153-L164 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hll/ToByteArrayImpl.java | ToByteArrayImpl.toHllByteArray | static final byte[] toHllByteArray(final AbstractHllArray impl, final boolean compact) {
int auxBytes = 0;
if (impl.tgtHllType == TgtHllType.HLL_4) {
final AuxHashMap auxHashMap = impl.getAuxHashMap();
if (auxHashMap != null) {
auxBytes = (compact)
? auxHashMap.getCompactSizeByte... | java | static final byte[] toHllByteArray(final AbstractHllArray impl, final boolean compact) {
int auxBytes = 0;
if (impl.tgtHllType == TgtHllType.HLL_4) {
final AuxHashMap auxHashMap = impl.getAuxHashMap();
if (auxHashMap != null) {
auxBytes = (compact)
? auxHashMap.getCompactSizeByte... | [
"static",
"final",
"byte",
"[",
"]",
"toHllByteArray",
"(",
"final",
"AbstractHllArray",
"impl",
",",
"final",
"boolean",
"compact",
")",
"{",
"int",
"auxBytes",
"=",
"0",
";",
"if",
"(",
"impl",
".",
"tgtHllType",
"==",
"TgtHllType",
".",
"HLL_4",
")",
... | To byte array used by the heap HLL types. | [
"To",
"byte",
"array",
"used",
"by",
"the",
"heap",
"HLL",
"types",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hll/ToByteArrayImpl.java#L42-L59 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/PreambleUtil.java | PreambleUtil.getAndCheckPreLongs | static int getAndCheckPreLongs(final Memory mem) {
final long cap = mem.getCapacity();
if (cap < 8) { throwNotBigEnough(cap, 8); }
final int preLongs = mem.getByte(0) & 0x3F;
final int required = Math.max(preLongs << 3, 8);
if (cap < required) { throwNotBigEnough(cap, required); }
return preLong... | java | static int getAndCheckPreLongs(final Memory mem) {
final long cap = mem.getCapacity();
if (cap < 8) { throwNotBigEnough(cap, 8); }
final int preLongs = mem.getByte(0) & 0x3F;
final int required = Math.max(preLongs << 3, 8);
if (cap < required) { throwNotBigEnough(cap, required); }
return preLong... | [
"static",
"int",
"getAndCheckPreLongs",
"(",
"final",
"Memory",
"mem",
")",
"{",
"final",
"long",
"cap",
"=",
"mem",
".",
"getCapacity",
"(",
")",
";",
"if",
"(",
"cap",
"<",
"8",
")",
"{",
"throwNotBigEnough",
"(",
"cap",
",",
"8",
")",
";",
"}",
... | Checks Memory for capacity to hold the preamble and returns the extracted preLongs.
@param mem the given Memory
@return the extracted prelongs value. | [
"Checks",
"Memory",
"for",
"capacity",
"to",
"hold",
"the",
"preamble",
"and",
"returns",
"the",
"extracted",
"preLongs",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/PreambleUtil.java#L430-L437 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesIntersection.java | ArrayOfDoublesIntersection.update | public void update(final ArrayOfDoublesSketch sketchIn, final ArrayOfDoublesCombiner combiner) {
final boolean isFirstCall = isFirstCall_;
isFirstCall_ = false;
if (sketchIn == null) {
isEmpty_ = true;
sketch_ = null;
return;
}
Util.checkSeedHashes(seedHash_, sketchIn.getSeedHash()... | java | public void update(final ArrayOfDoublesSketch sketchIn, final ArrayOfDoublesCombiner combiner) {
final boolean isFirstCall = isFirstCall_;
isFirstCall_ = false;
if (sketchIn == null) {
isEmpty_ = true;
sketch_ = null;
return;
}
Util.checkSeedHashes(seedHash_, sketchIn.getSeedHash()... | [
"public",
"void",
"update",
"(",
"final",
"ArrayOfDoublesSketch",
"sketchIn",
",",
"final",
"ArrayOfDoublesCombiner",
"combiner",
")",
"{",
"final",
"boolean",
"isFirstCall",
"=",
"isFirstCall_",
";",
"isFirstCall_",
"=",
"false",
";",
"if",
"(",
"sketchIn",
"==",... | Updates the internal set by intersecting it with the given sketch.
@param sketchIn Input sketch to intersect with the internal set.
@param combiner Method of combining two arrays of double values | [
"Updates",
"the",
"internal",
"set",
"by",
"intersecting",
"it",
"with",
"the",
"given",
"sketch",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesIntersection.java#L43-L90 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesIntersection.java | ArrayOfDoublesIntersection.getResult | public ArrayOfDoublesCompactSketch getResult(final WritableMemory dstMem) {
if (isFirstCall_) {
throw new SketchesStateException(
"getResult() with no intervening intersections is not a legal result.");
}
if (sketch_ == null) {
return new HeapArrayOfDoublesCompactSketch(
null... | java | public ArrayOfDoublesCompactSketch getResult(final WritableMemory dstMem) {
if (isFirstCall_) {
throw new SketchesStateException(
"getResult() with no intervening intersections is not a legal result.");
}
if (sketch_ == null) {
return new HeapArrayOfDoublesCompactSketch(
null... | [
"public",
"ArrayOfDoublesCompactSketch",
"getResult",
"(",
"final",
"WritableMemory",
"dstMem",
")",
"{",
"if",
"(",
"isFirstCall_",
")",
"{",
"throw",
"new",
"SketchesStateException",
"(",
"\"getResult() with no intervening intersections is not a legal result.\"",
")",
";",
... | Gets the internal set as an off-heap compact sketch using the given memory.
@param dstMem Memory for the compact sketch (can be null).
@return Result of the intersections so far as a compact sketch. | [
"Gets",
"the",
"internal",
"set",
"as",
"an",
"off",
"-",
"heap",
"compact",
"sketch",
"using",
"the",
"given",
"memory",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesIntersection.java#L97-L107 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesIntersection.java | ArrayOfDoublesIntersection.reset | public void reset() {
isEmpty_ = false;
theta_ = Long.MAX_VALUE;
sketch_ = null;
isFirstCall_ = true;
} | java | public void reset() {
isEmpty_ = false;
theta_ = Long.MAX_VALUE;
sketch_ = null;
isFirstCall_ = true;
} | [
"public",
"void",
"reset",
"(",
")",
"{",
"isEmpty_",
"=",
"false",
";",
"theta_",
"=",
"Long",
".",
"MAX_VALUE",
";",
"sketch_",
"=",
"null",
";",
"isFirstCall_",
"=",
"true",
";",
"}"
] | Resets the internal set to the initial state, which represents the Universal Set | [
"Resets",
"the",
"internal",
"set",
"to",
"the",
"initial",
"state",
"which",
"represents",
"the",
"Universal",
"Set"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesIntersection.java#L120-L125 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesSketch.java | ArrayOfDoublesSketch.heapify | public static ArrayOfDoublesSketch heapify(final Memory mem, final long seed) {
final SerializerDeserializer.SketchType sketchType = SerializerDeserializer.getSketchType(mem);
if (sketchType == SerializerDeserializer.SketchType.ArrayOfDoublesQuickSelectSketch) {
return new HeapArrayOfDoublesQuickSelectSke... | java | public static ArrayOfDoublesSketch heapify(final Memory mem, final long seed) {
final SerializerDeserializer.SketchType sketchType = SerializerDeserializer.getSketchType(mem);
if (sketchType == SerializerDeserializer.SketchType.ArrayOfDoublesQuickSelectSketch) {
return new HeapArrayOfDoublesQuickSelectSke... | [
"public",
"static",
"ArrayOfDoublesSketch",
"heapify",
"(",
"final",
"Memory",
"mem",
",",
"final",
"long",
"seed",
")",
"{",
"final",
"SerializerDeserializer",
".",
"SketchType",
"sketchType",
"=",
"SerializerDeserializer",
".",
"getSketchType",
"(",
"mem",
")",
... | Heapify the given Memory and seed as a ArrayOfDoublesSketch
@param mem the given Memory
@param seed the given seed
@return an ArrayOfDoublesSketch | [
"Heapify",
"the",
"given",
"Memory",
"and",
"seed",
"as",
"a",
"ArrayOfDoublesSketch"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesSketch.java#L72-L78 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesSketch.java | ArrayOfDoublesSketch.wrap | public static ArrayOfDoublesSketch wrap(final Memory mem, final long seed) {
final SerializerDeserializer.SketchType sketchType = SerializerDeserializer.getSketchType(mem);
if (sketchType == SerializerDeserializer.SketchType.ArrayOfDoublesQuickSelectSketch) {
return new DirectArrayOfDoublesQuickSelectSket... | java | public static ArrayOfDoublesSketch wrap(final Memory mem, final long seed) {
final SerializerDeserializer.SketchType sketchType = SerializerDeserializer.getSketchType(mem);
if (sketchType == SerializerDeserializer.SketchType.ArrayOfDoublesQuickSelectSketch) {
return new DirectArrayOfDoublesQuickSelectSket... | [
"public",
"static",
"ArrayOfDoublesSketch",
"wrap",
"(",
"final",
"Memory",
"mem",
",",
"final",
"long",
"seed",
")",
"{",
"final",
"SerializerDeserializer",
".",
"SketchType",
"sketchType",
"=",
"SerializerDeserializer",
".",
"getSketchType",
"(",
"mem",
")",
";"... | Wrap the given Memory and seed as a ArrayOfDoublesSketch
@param mem the given Memory
@param seed the given seed
@return an ArrayOfDoublesSketch | [
"Wrap",
"the",
"given",
"Memory",
"and",
"seed",
"as",
"a",
"ArrayOfDoublesSketch"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesSketch.java#L95-L101 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/AnotB.java | AnotB.aNotB | public CompactSketch aNotB(final Sketch a, final Sketch b) {
return aNotB(a, b, true, null);
} | java | public CompactSketch aNotB(final Sketch a, final Sketch b) {
return aNotB(a, b, true, null);
} | [
"public",
"CompactSketch",
"aNotB",
"(",
"final",
"Sketch",
"a",
",",
"final",
"Sketch",
"b",
")",
"{",
"return",
"aNotB",
"(",
"a",
",",
"b",
",",
"true",
",",
"null",
")",
";",
"}"
] | Perform A-and-not-B set operation on the two given sketches and return the result as an
ordered CompactSketch on the heap.
@param a The incoming sketch for the first argument
@param b The incoming sketch for the second argument
@return an ordered CompactSketch on the heap | [
"Perform",
"A",
"-",
"and",
"-",
"not",
"-",
"B",
"set",
"operation",
"on",
"the",
"two",
"given",
"sketches",
"and",
"return",
"the",
"result",
"as",
"an",
"ordered",
"CompactSketch",
"on",
"the",
"heap",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/AnotB.java#L69-L71 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hll/HllSketch.java | HllSketch.heapify | public static final HllSketch heapify(final Memory srcMem) {
final CurMode curMode = checkPreamble(srcMem);
final HllSketch heapSketch;
if (curMode == CurMode.HLL) {
final TgtHllType tgtHllType = extractTgtHllType(srcMem);
if (tgtHllType == TgtHllType.HLL_4) {
heapSketch = new HllSketch(... | java | public static final HllSketch heapify(final Memory srcMem) {
final CurMode curMode = checkPreamble(srcMem);
final HllSketch heapSketch;
if (curMode == CurMode.HLL) {
final TgtHllType tgtHllType = extractTgtHllType(srcMem);
if (tgtHllType == TgtHllType.HLL_4) {
heapSketch = new HllSketch(... | [
"public",
"static",
"final",
"HllSketch",
"heapify",
"(",
"final",
"Memory",
"srcMem",
")",
"{",
"final",
"CurMode",
"curMode",
"=",
"checkPreamble",
"(",
"srcMem",
")",
";",
"final",
"HllSketch",
"heapSketch",
";",
"if",
"(",
"curMode",
"==",
"CurMode",
"."... | Heapify the given Memory, which must be a valid HllSketch image and may have data.
@param srcMem the given Memory, which is read-only.
@return an HllSketch on the java heap. | [
"Heapify",
"the",
"given",
"Memory",
"which",
"must",
"be",
"a",
"valid",
"HllSketch",
"image",
"and",
"may",
"have",
"data",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hll/HllSketch.java#L136-L154 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hll/HllSketch.java | HllSketch.writableWrap | public static final HllSketch writableWrap(final WritableMemory wmem) {
final boolean compact = extractCompactFlag(wmem);
if (compact) {
throw new SketchesArgumentException(
"Cannot perform a writableWrap of a writable sketch image that is in compact form.");
}
final int lgConfigK = extr... | java | public static final HllSketch writableWrap(final WritableMemory wmem) {
final boolean compact = extractCompactFlag(wmem);
if (compact) {
throw new SketchesArgumentException(
"Cannot perform a writableWrap of a writable sketch image that is in compact form.");
}
final int lgConfigK = extr... | [
"public",
"static",
"final",
"HllSketch",
"writableWrap",
"(",
"final",
"WritableMemory",
"wmem",
")",
"{",
"final",
"boolean",
"compact",
"=",
"extractCompactFlag",
"(",
"wmem",
")",
";",
"if",
"(",
"compact",
")",
"{",
"throw",
"new",
"SketchesArgumentExceptio... | Wraps the given WritableMemory, which must be a image of a valid updatable sketch,
and may have data. What remains on the java heap is a
thin wrapper object that reads and writes to the given WritableMemory, which, depending on
how the user configures the WritableMemory, may actually reside on the Java heap or off-heap... | [
"Wraps",
"the",
"given",
"WritableMemory",
"which",
"must",
"be",
"a",
"image",
"of",
"a",
"valid",
"updatable",
"sketch",
"and",
"may",
"have",
"data",
".",
"What",
"remains",
"on",
"the",
"java",
"heap",
"is",
"a",
"thin",
"wrapper",
"object",
"that",
... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hll/HllSketch.java#L167-L197 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hll/HllSketch.java | HllSketch.getMaxUpdatableSerializationBytes | public static final int getMaxUpdatableSerializationBytes(final int lgConfigK,
final TgtHllType tgtHllType) {
final int arrBytes;
if (tgtHllType == TgtHllType.HLL_4) {
final int auxBytes = 4 << LG_AUX_ARR_INTS[lgConfigK];
arrBytes = AbstractHllArray.hll4ArrBytes(lgConfigK) + auxBytes;
}
... | java | public static final int getMaxUpdatableSerializationBytes(final int lgConfigK,
final TgtHllType tgtHllType) {
final int arrBytes;
if (tgtHllType == TgtHllType.HLL_4) {
final int auxBytes = 4 << LG_AUX_ARR_INTS[lgConfigK];
arrBytes = AbstractHllArray.hll4ArrBytes(lgConfigK) + auxBytes;
}
... | [
"public",
"static",
"final",
"int",
"getMaxUpdatableSerializationBytes",
"(",
"final",
"int",
"lgConfigK",
",",
"final",
"TgtHllType",
"tgtHllType",
")",
"{",
"final",
"int",
"arrBytes",
";",
"if",
"(",
"tgtHllType",
"==",
"TgtHllType",
".",
"HLL_4",
")",
"{",
... | Returns the maximum size in bytes that this sketch can grow to given lgConfigK.
However, for the HLL_4 sketch type, this value can be exceeded in extremely rare cases.
If exceeded, it will be larger by only a few percent.
@param lgConfigK The Log2 of K for the target HLL sketch. This value must be
between 4 and 21 inc... | [
"Returns",
"the",
"maximum",
"size",
"in",
"bytes",
"that",
"this",
"sketch",
"can",
"grow",
"to",
"given",
"lgConfigK",
".",
"However",
"for",
"the",
"HLL_4",
"sketch",
"type",
"this",
"value",
"can",
"be",
"exceeded",
"in",
"extremely",
"rare",
"cases",
... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hll/HllSketch.java#L283-L297 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesByteArrayImpl.java | DoublesByteArrayImpl.convertToByteArray | private static byte[] convertToByteArray(final DoublesSketch sketch, final int flags,
final boolean ordered, final boolean compact) {
final int preLongs = 2;
final int extra = 2; // extra space for min and max values
final int prePlusExtraBytes = (preLongs + extra)... | java | private static byte[] convertToByteArray(final DoublesSketch sketch, final int flags,
final boolean ordered, final boolean compact) {
final int preLongs = 2;
final int extra = 2; // extra space for min and max values
final int prePlusExtraBytes = (preLongs + extra)... | [
"private",
"static",
"byte",
"[",
"]",
"convertToByteArray",
"(",
"final",
"DoublesSketch",
"sketch",
",",
"final",
"int",
"flags",
",",
"final",
"boolean",
"ordered",
",",
"final",
"boolean",
"compact",
")",
"{",
"final",
"int",
"preLongs",
"=",
"2",
";",
... | Returns a byte array, including preamble, min, max and data extracted from the sketch.
@param sketch the given DoublesSketch
@param flags the Flags field
@param ordered true if the desired form of the resulting array has the base buffer sorted.
@param compact true if the desired form of the resulting array is in compac... | [
"Returns",
"a",
"byte",
"array",
"including",
"preamble",
"min",
"max",
"and",
"data",
"extracted",
"from",
"the",
"sketch",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesByteArrayImpl.java#L64-L114 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/frequencies/ItemsSketch.java | ItemsSketch.update | public void update(final T item, final long count) {
if ((item == null) || (count == 0)) {
return;
}
if (count < 0) {
throw new SketchesArgumentException("Count may not be negative");
}
this.streamWeight += count;
hashMap.adjustOrPutValue(item, count);
if (getNumActiveItems() > ... | java | public void update(final T item, final long count) {
if ((item == null) || (count == 0)) {
return;
}
if (count < 0) {
throw new SketchesArgumentException("Count may not be negative");
}
this.streamWeight += count;
hashMap.adjustOrPutValue(item, count);
if (getNumActiveItems() > ... | [
"public",
"void",
"update",
"(",
"final",
"T",
"item",
",",
"final",
"long",
"count",
")",
"{",
"if",
"(",
"(",
"item",
"==",
"null",
")",
"||",
"(",
"count",
"==",
"0",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"count",
"<",
"0",
")",
"{... | Update this sketch with a item and a positive frequency count.
@param item for which the frequency should be increased. The item can be any long value and is
only used by the sketch to determine uniqueness.
@param count the amount by which the frequency of the item should be increased.
An count of zero is a no-op, and ... | [
"Update",
"this",
"sketch",
"with",
"a",
"item",
"and",
"a",
"positive",
"frequency",
"count",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/frequencies/ItemsSketch.java#L562-L583 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/frequencies/ReversePurgeItemHashMap.java | ReversePurgeItemHashMap.adjustOrPutValue | void adjustOrPutValue(final T key, final long adjustAmount) {
final int arrayMask = keys.length - 1;
int probe = (int) hash(key.hashCode()) & arrayMask;
int drift = 1;
while (states[probe] != 0 && !keys[probe].equals(key)) {
probe = (probe + 1) & arrayMask;
drift++;
//only used for the... | java | void adjustOrPutValue(final T key, final long adjustAmount) {
final int arrayMask = keys.length - 1;
int probe = (int) hash(key.hashCode()) & arrayMask;
int drift = 1;
while (states[probe] != 0 && !keys[probe].equals(key)) {
probe = (probe + 1) & arrayMask;
drift++;
//only used for the... | [
"void",
"adjustOrPutValue",
"(",
"final",
"T",
"key",
",",
"final",
"long",
"adjustAmount",
")",
"{",
"final",
"int",
"arrayMask",
"=",
"keys",
".",
"length",
"-",
"1",
";",
"int",
"probe",
"=",
"(",
"int",
")",
"hash",
"(",
"key",
".",
"hashCode",
"... | Increments the value mapped to the key if the key is present in the map. Otherwise,
the key is inserted with the putAmount.
@param key the key of the value to increment
@param adjustAmount the amount by which to increment the value | [
"Increments",
"the",
"value",
"mapped",
"to",
"the",
"key",
"if",
"the",
"key",
"is",
"present",
"in",
"the",
"map",
".",
"Otherwise",
"the",
"key",
"is",
"inserted",
"with",
"the",
"putAmount",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/frequencies/ReversePurgeItemHashMap.java#L86-L110 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/frequencies/ReversePurgeItemHashMap.java | ReversePurgeItemHashMap.resize | @SuppressWarnings("unchecked")
void resize(final int newSize) {
final Object[] oldKeys = keys;
final long[] oldValues = values;
final short[] oldStates = states;
keys = new Object[newSize];
values = new long[newSize];
states = new short[newSize];
loadThreshold = (int) (newSize * LOAD_FACTO... | java | @SuppressWarnings("unchecked")
void resize(final int newSize) {
final Object[] oldKeys = keys;
final long[] oldValues = values;
final short[] oldStates = states;
keys = new Object[newSize];
values = new long[newSize];
states = new short[newSize];
loadThreshold = (int) (newSize * LOAD_FACTO... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"void",
"resize",
"(",
"final",
"int",
"newSize",
")",
"{",
"final",
"Object",
"[",
"]",
"oldKeys",
"=",
"keys",
";",
"final",
"long",
"[",
"]",
"oldValues",
"=",
"values",
";",
"final",
"short",
"[",
... | assume newSize is power of 2 | [
"assume",
"newSize",
"is",
"power",
"of",
"2"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/frequencies/ReversePurgeItemHashMap.java#L189-L205 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/frequencies/ReversePurgeItemHashMap.java | ReversePurgeItemHashMap.purge | long purge(final int sampleSize) {
final int limit = Math.min(sampleSize, getNumActive());
int numSamples = 0;
int i = 0;
final long[] samples = new long[limit];
while (numSamples < limit) {
if (isActive(i)) {
samples[numSamples] = values[i];
numSamples++;
}
i++;
... | java | long purge(final int sampleSize) {
final int limit = Math.min(sampleSize, getNumActive());
int numSamples = 0;
int i = 0;
final long[] samples = new long[limit];
while (numSamples < limit) {
if (isActive(i)) {
samples[numSamples] = values[i];
numSamples++;
}
i++;
... | [
"long",
"purge",
"(",
"final",
"int",
"sampleSize",
")",
"{",
"final",
"int",
"limit",
"=",
"Math",
".",
"min",
"(",
"sampleSize",
",",
"getNumActive",
"(",
")",
")",
";",
"int",
"numSamples",
"=",
"0",
";",
"int",
"i",
"=",
"0",
";",
"final",
"lon... | This function is called when a key is processed that is not currently assigned a counter, and
all the counters are in use. This function estimates the median of the counters in the sketch
via sampling, decrements all counts by this estimate, throws out all counters that are no
longer positive, and increments offset acc... | [
"This",
"function",
"is",
"called",
"when",
"a",
"key",
"is",
"processed",
"that",
"is",
"not",
"currently",
"assigned",
"a",
"counter",
"and",
"all",
"the",
"counters",
"are",
"in",
"use",
".",
"This",
"function",
"estimates",
"the",
"median",
"of",
"the"... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/frequencies/ReversePurgeItemHashMap.java#L267-L286 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesUnionImplR.java | DoublesUnionImplR.wrapInstance | static DoublesUnionImplR wrapInstance(final Memory mem) {
final DirectUpdateDoublesSketchR sketch = DirectUpdateDoublesSketchR.wrapInstance(mem);
final int k = sketch.getK();
final DoublesUnionImplR union = new DoublesUnionImplR(k);
union.maxK_ = k;
union.gadget_ = sketch;
return union;
} | java | static DoublesUnionImplR wrapInstance(final Memory mem) {
final DirectUpdateDoublesSketchR sketch = DirectUpdateDoublesSketchR.wrapInstance(mem);
final int k = sketch.getK();
final DoublesUnionImplR union = new DoublesUnionImplR(k);
union.maxK_ = k;
union.gadget_ = sketch;
return union;
} | [
"static",
"DoublesUnionImplR",
"wrapInstance",
"(",
"final",
"Memory",
"mem",
")",
"{",
"final",
"DirectUpdateDoublesSketchR",
"sketch",
"=",
"DirectUpdateDoublesSketchR",
".",
"wrapInstance",
"(",
"mem",
")",
";",
"final",
"int",
"k",
"=",
"sketch",
".",
"getK",
... | Returns a read-only Union object that wraps off-heap data structure of the given memory
image of a non-compact DoublesSketch. The data structures of the Union remain off-heap.
@param mem A memory image of a non-compact DoublesSketch to be used as the data
structure for the union and will be modified.
@return a Union o... | [
"Returns",
"a",
"read",
"-",
"only",
"Union",
"object",
"that",
"wraps",
"off",
"-",
"heap",
"data",
"structure",
"of",
"the",
"given",
"memory",
"image",
"of",
"a",
"non",
"-",
"compact",
"DoublesSketch",
".",
"The",
"data",
"structures",
"of",
"the",
"... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesUnionImplR.java#L37-L44 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hll/DirectHllArray.java | DirectHllArray.updateMemory | final void updateMemory(final WritableMemory newWmem) {
wmem = newWmem;
mem = newWmem;
memObj = wmem.getArray();
memAdd = wmem.getCumulativeOffset(0L);
} | java | final void updateMemory(final WritableMemory newWmem) {
wmem = newWmem;
mem = newWmem;
memObj = wmem.getArray();
memAdd = wmem.getCumulativeOffset(0L);
} | [
"final",
"void",
"updateMemory",
"(",
"final",
"WritableMemory",
"newWmem",
")",
"{",
"wmem",
"=",
"newWmem",
";",
"mem",
"=",
"newWmem",
";",
"memObj",
"=",
"wmem",
".",
"getArray",
"(",
")",
";",
"memAdd",
"=",
"wmem",
".",
"getCumulativeOffset",
"(",
... | only called by DirectAuxHashMap | [
"only",
"called",
"by",
"DirectAuxHashMap"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hll/DirectHllArray.java#L67-L72 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesUtil.java | DoublesUtil.copyToHeap | static HeapUpdateDoublesSketch copyToHeap(final DoublesSketch sketch) {
final HeapUpdateDoublesSketch qsCopy;
qsCopy = HeapUpdateDoublesSketch.newInstance(sketch.getK());
qsCopy.putN(sketch.getN());
qsCopy.putMinValue(sketch.getMinValue());
qsCopy.putMaxValue(sketch.getMaxValue());
qsCopy.putBas... | java | static HeapUpdateDoublesSketch copyToHeap(final DoublesSketch sketch) {
final HeapUpdateDoublesSketch qsCopy;
qsCopy = HeapUpdateDoublesSketch.newInstance(sketch.getK());
qsCopy.putN(sketch.getN());
qsCopy.putMinValue(sketch.getMinValue());
qsCopy.putMaxValue(sketch.getMaxValue());
qsCopy.putBas... | [
"static",
"HeapUpdateDoublesSketch",
"copyToHeap",
"(",
"final",
"DoublesSketch",
"sketch",
")",
"{",
"final",
"HeapUpdateDoublesSketch",
"qsCopy",
";",
"qsCopy",
"=",
"HeapUpdateDoublesSketch",
".",
"newInstance",
"(",
"sketch",
".",
"getK",
"(",
")",
")",
";",
"... | Returns an on-heap copy of the given sketch
@param sketch the given sketch
@return a copy of the given sketch | [
"Returns",
"an",
"on",
"-",
"heap",
"copy",
"of",
"the",
"given",
"sketch"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesUtil.java#L33-L66 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesUtil.java | DoublesUtil.checkDoublesSerVer | static void checkDoublesSerVer(final int serVer, final int minSupportedSerVer) {
final int max = DoublesSketch.DOUBLES_SER_VER;
if ((serVer > max) || (serVer < minSupportedSerVer)) {
throw new SketchesArgumentException(
"Possible corruption: Unsupported Serialization Version: " + serVer);
}
... | java | static void checkDoublesSerVer(final int serVer, final int minSupportedSerVer) {
final int max = DoublesSketch.DOUBLES_SER_VER;
if ((serVer > max) || (serVer < minSupportedSerVer)) {
throw new SketchesArgumentException(
"Possible corruption: Unsupported Serialization Version: " + serVer);
}
... | [
"static",
"void",
"checkDoublesSerVer",
"(",
"final",
"int",
"serVer",
",",
"final",
"int",
"minSupportedSerVer",
")",
"{",
"final",
"int",
"max",
"=",
"DoublesSketch",
".",
"DOUBLES_SER_VER",
";",
"if",
"(",
"(",
"serVer",
">",
"max",
")",
"||",
"(",
"ser... | Check the validity of the given serialization version
@param serVer the given serialization version
@param minSupportedSerVer the oldest serialization version supported | [
"Check",
"the",
"validity",
"of",
"the",
"given",
"serialization",
"version"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesUtil.java#L73-L79 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DirectCompactDoublesSketch.java | DirectCompactDoublesSketch.wrapInstance | static DirectCompactDoublesSketch wrapInstance(final Memory srcMem) {
final long memCap = srcMem.getCapacity();
final int preLongs = extractPreLongs(srcMem);
final int serVer = extractSerVer(srcMem);
final int familyID = extractFamilyID(srcMem);
final int flags = extractFlags(srcMem);
final int... | java | static DirectCompactDoublesSketch wrapInstance(final Memory srcMem) {
final long memCap = srcMem.getCapacity();
final int preLongs = extractPreLongs(srcMem);
final int serVer = extractSerVer(srcMem);
final int familyID = extractFamilyID(srcMem);
final int flags = extractFlags(srcMem);
final int... | [
"static",
"DirectCompactDoublesSketch",
"wrapInstance",
"(",
"final",
"Memory",
"srcMem",
")",
"{",
"final",
"long",
"memCap",
"=",
"srcMem",
".",
"getCapacity",
"(",
")",
";",
"final",
"int",
"preLongs",
"=",
"extractPreLongs",
"(",
"srcMem",
")",
";",
"final... | Wrap this sketch around the given compact Memory image of a DoublesSketch.
@param srcMem the given compact Memory image of a DoublesSketch that may have data,
@return a sketch that wraps the given srcMem | [
"Wrap",
"this",
"sketch",
"around",
"the",
"given",
"compact",
"Memory",
"image",
"of",
"a",
"DoublesSketch",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DirectCompactDoublesSketch.java#L123-L147 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DirectCompactDoublesSketch.java | DirectCompactDoublesSketch.checkCompact | static void checkCompact(final int serVer, final int flags) {
final int compactFlagMask = COMPACT_FLAG_MASK | ORDERED_FLAG_MASK;
if ((serVer != 2)
&& ((flags & EMPTY_FLAG_MASK) == 0)
&& ((flags & compactFlagMask) != compactFlagMask)) {
throw new SketchesArgumentException(
... | java | static void checkCompact(final int serVer, final int flags) {
final int compactFlagMask = COMPACT_FLAG_MASK | ORDERED_FLAG_MASK;
if ((serVer != 2)
&& ((flags & EMPTY_FLAG_MASK) == 0)
&& ((flags & compactFlagMask) != compactFlagMask)) {
throw new SketchesArgumentException(
... | [
"static",
"void",
"checkCompact",
"(",
"final",
"int",
"serVer",
",",
"final",
"int",
"flags",
")",
"{",
"final",
"int",
"compactFlagMask",
"=",
"COMPACT_FLAG_MASK",
"|",
"ORDERED_FLAG_MASK",
";",
"if",
"(",
"(",
"serVer",
"!=",
"2",
")",
"&&",
"(",
"(",
... | Checks a sketch's serial version and flags to see if the sketch can be wrapped as a
DirectCompactDoubleSketch. Throws an exception if the sketch is neither empty nor compact
and ordered, unles the sketch uses serialization version 2.
@param serVer the serialization version
@param flags Flags from the sketch to evaluate | [
"Checks",
"a",
"sketch",
"s",
"serial",
"version",
"and",
"flags",
"to",
"see",
"if",
"the",
"sketch",
"can",
"be",
"wrapped",
"as",
"a",
"DirectCompactDoubleSketch",
".",
"Throws",
"an",
"exception",
"if",
"the",
"sketch",
"is",
"neither",
"empty",
"nor",
... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DirectCompactDoublesSketch.java#L234-L243 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/HashOperations.java | HashOperations.countPart | public static int countPart(final long[] srcArr, final int lgArrLongs, final long thetaLong) {
int cnt = 0;
final int len = 1 << lgArrLongs;
for (int i = len; i-- > 0;) {
final long hash = srcArr[i];
if (continueCondition(thetaLong, hash) ) {
continue;
}
cnt++ ;
}
ret... | java | public static int countPart(final long[] srcArr, final int lgArrLongs, final long thetaLong) {
int cnt = 0;
final int len = 1 << lgArrLongs;
for (int i = len; i-- > 0;) {
final long hash = srcArr[i];
if (continueCondition(thetaLong, hash) ) {
continue;
}
cnt++ ;
}
ret... | [
"public",
"static",
"int",
"countPart",
"(",
"final",
"long",
"[",
"]",
"srcArr",
",",
"final",
"int",
"lgArrLongs",
",",
"final",
"long",
"thetaLong",
")",
"{",
"int",
"cnt",
"=",
"0",
";",
"final",
"int",
"len",
"=",
"1",
"<<",
"lgArrLongs",
";",
"... | Counts the cardinality of the first Log2 values of the given source array.
@param srcArr the given source array
@param lgArrLongs <a href="{@docRoot}/resources/dictionary.html#lgArrLongs">See lgArrLongs</a>
@param thetaLong <a href="{@docRoot}/resources/dictionary.html#thetaLong">See Theta Long</a>
@return the cardinal... | [
"Counts",
"the",
"cardinality",
"of",
"the",
"first",
"Log2",
"values",
"of",
"the",
"given",
"source",
"array",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/HashOperations.java#L36-L47 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/HashOperations.java | HashOperations.count | public static int count(final long[] srcArr, final long thetaLong) {
int cnt = 0;
final int len = srcArr.length;
for (int i = len; i-- > 0;) {
final long hash = srcArr[i];
if (continueCondition(thetaLong, hash) ) {
continue;
}
cnt++ ;
}
return cnt;
} | java | public static int count(final long[] srcArr, final long thetaLong) {
int cnt = 0;
final int len = srcArr.length;
for (int i = len; i-- > 0;) {
final long hash = srcArr[i];
if (continueCondition(thetaLong, hash) ) {
continue;
}
cnt++ ;
}
return cnt;
} | [
"public",
"static",
"int",
"count",
"(",
"final",
"long",
"[",
"]",
"srcArr",
",",
"final",
"long",
"thetaLong",
")",
"{",
"int",
"cnt",
"=",
"0",
";",
"final",
"int",
"len",
"=",
"srcArr",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"len",
... | Counts the cardinality of the given source array.
@param srcArr the given source array
@param thetaLong <a href="{@docRoot}/resources/dictionary.html#thetaLong">See Theta Long</a>
@return the cardinality | [
"Counts",
"the",
"cardinality",
"of",
"the",
"given",
"source",
"array",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/HashOperations.java#L55-L66 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/HashOperations.java | HashOperations.hashSearch | public static int hashSearch(final long[] hashTable, final int lgArrLongs, final long hash) {
if (hash == 0) {
throw new SketchesArgumentException("Given hash cannot be zero: " + hash);
}
final int arrayMask = (1 << lgArrLongs) - 1; // current Size -1
final int stride = getStride(hash, lgArrLongs)... | java | public static int hashSearch(final long[] hashTable, final int lgArrLongs, final long hash) {
if (hash == 0) {
throw new SketchesArgumentException("Given hash cannot be zero: " + hash);
}
final int arrayMask = (1 << lgArrLongs) - 1; // current Size -1
final int stride = getStride(hash, lgArrLongs)... | [
"public",
"static",
"int",
"hashSearch",
"(",
"final",
"long",
"[",
"]",
"hashTable",
",",
"final",
"int",
"lgArrLongs",
",",
"final",
"long",
"hash",
")",
"{",
"if",
"(",
"hash",
"==",
"0",
")",
"{",
"throw",
"new",
"SketchesArgumentException",
"(",
"\"... | This is a classical Knuth-style Open Addressing, Double Hash search scheme for on-heap.
Returns the index if found, -1 if not found.
@param hashTable The hash table to search. Must be a power of 2 in size.
@param lgArrLongs <a href="{@docRoot}/resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.
lgArrLongs ≤ l... | [
"This",
"is",
"a",
"classical",
"Knuth",
"-",
"style",
"Open",
"Addressing",
"Double",
"Hash",
"search",
"scheme",
"for",
"on",
"-",
"heap",
".",
"Returns",
"the",
"index",
"if",
"found",
"-",
"1",
"if",
"not",
"found",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/HashOperations.java#L86-L106 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/HashOperations.java | HashOperations.hashArrayInsert | public static int hashArrayInsert(final long[] srcArr, final long[] hashTable,
final int lgArrLongs, final long thetaLong) {
int count = 0;
final int arrLen = srcArr.length;
checkThetaCorruption(thetaLong);
for (int i = 0; i < arrLen; i++ ) { // scan source array, build target array
final lo... | java | public static int hashArrayInsert(final long[] srcArr, final long[] hashTable,
final int lgArrLongs, final long thetaLong) {
int count = 0;
final int arrLen = srcArr.length;
checkThetaCorruption(thetaLong);
for (int i = 0; i < arrLen; i++ ) { // scan source array, build target array
final lo... | [
"public",
"static",
"int",
"hashArrayInsert",
"(",
"final",
"long",
"[",
"]",
"srcArr",
",",
"final",
"long",
"[",
"]",
"hashTable",
",",
"final",
"int",
"lgArrLongs",
",",
"final",
"long",
"thetaLong",
")",
"{",
"int",
"count",
"=",
"0",
";",
"final",
... | Inserts the given long array into the given hash table array of the target size,
removes any negative input values, ignores duplicates and counts the values inserted.
The given hash table may have values, but they must have been inserted by this method or one
of the other OADH insert methods in this class and they may ... | [
"Inserts",
"the",
"given",
"long",
"array",
"into",
"the",
"given",
"hash",
"table",
"array",
"of",
"the",
"target",
"size",
"removes",
"any",
"negative",
"input",
"values",
"ignores",
"duplicates",
"and",
"counts",
"the",
"values",
"inserted",
".",
"The",
"... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/HashOperations.java#L188-L204 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/HashOperations.java | HashOperations.hashSearch | public static int hashSearch(final Memory mem, final int lgArrLongs, final long hash,
final int memOffsetBytes) {
final int arrayMask = (1 << lgArrLongs) - 1;
final int stride = getStride(hash, lgArrLongs);
int curProbe = (int) (hash & arrayMask);
final int loopIndex = curProbe;
do {
fin... | java | public static int hashSearch(final Memory mem, final int lgArrLongs, final long hash,
final int memOffsetBytes) {
final int arrayMask = (1 << lgArrLongs) - 1;
final int stride = getStride(hash, lgArrLongs);
int curProbe = (int) (hash & arrayMask);
final int loopIndex = curProbe;
do {
fin... | [
"public",
"static",
"int",
"hashSearch",
"(",
"final",
"Memory",
"mem",
",",
"final",
"int",
"lgArrLongs",
",",
"final",
"long",
"hash",
",",
"final",
"int",
"memOffsetBytes",
")",
"{",
"final",
"int",
"arrayMask",
"=",
"(",
"1",
"<<",
"lgArrLongs",
")",
... | This is a classical Knuth-style Open Addressing, Double Hash search scheme for off-heap.
Returns the index if found, -1 if not found.
@param mem The Memory hash table to search.
@param lgArrLongs <a href="{@docRoot}/resources/dictionary.html#lgArrLongs">See lgArrLongs</a>.
lgArrLongs ≤ log2(hashTable.length).
@para... | [
"This",
"is",
"a",
"classical",
"Knuth",
"-",
"style",
"Open",
"Addressing",
"Double",
"Hash",
"search",
"scheme",
"for",
"off",
"-",
"heap",
".",
"Returns",
"the",
"index",
"if",
"found",
"-",
"1",
"if",
"not",
"found",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/HashOperations.java#L219-L233 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/HashOperations.java | HashOperations.fastHashInsertOnly | public static int fastHashInsertOnly(final WritableMemory wmem, final int lgArrLongs,
final long hash, final int memOffsetBytes) {
final int arrayMask = (1 << lgArrLongs) - 1; // current Size -1
final int stride = getStride(hash, lgArrLongs);
int curProbe = (int) (hash & arrayMask);
// search for ... | java | public static int fastHashInsertOnly(final WritableMemory wmem, final int lgArrLongs,
final long hash, final int memOffsetBytes) {
final int arrayMask = (1 << lgArrLongs) - 1; // current Size -1
final int stride = getStride(hash, lgArrLongs);
int curProbe = (int) (hash & arrayMask);
// search for ... | [
"public",
"static",
"int",
"fastHashInsertOnly",
"(",
"final",
"WritableMemory",
"wmem",
",",
"final",
"int",
"lgArrLongs",
",",
"final",
"long",
"hash",
",",
"final",
"int",
"memOffsetBytes",
")",
"{",
"final",
"int",
"arrayMask",
"=",
"(",
"1",
"<<",
"lgAr... | This is a classical Knuth-style Open Addressing, Double Hash insert scheme, but inserts
values directly into a Memory.
This method assumes that the input hash is not a duplicate.
Useful for rebuilding tables to avoid unnecessary comparisons.
Returns the index of insertion, which is always positive or zero.
Throws an ex... | [
"This",
"is",
"a",
"classical",
"Knuth",
"-",
"style",
"Open",
"Addressing",
"Double",
"Hash",
"insert",
"scheme",
"but",
"inserts",
"values",
"directly",
"into",
"a",
"Memory",
".",
"This",
"method",
"assumes",
"that",
"the",
"input",
"hash",
"is",
"not",
... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/HashOperations.java#L250-L267 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/ConcurrentHeapQuickSelectSketch.java | ConcurrentHeapQuickSelectSketch.advanceEpoch | @SuppressFBWarnings(value = "VO_VOLATILE_INCREMENT",
justification = "False Positive")
private void advanceEpoch() {
awaitBgPropagationTermination();
startEagerPropagation();
ConcurrentPropagationService.resetExecutorService(Thread.currentThread().getId());
//noinspection NonAtomicOperationOnVol... | java | @SuppressFBWarnings(value = "VO_VOLATILE_INCREMENT",
justification = "False Positive")
private void advanceEpoch() {
awaitBgPropagationTermination();
startEagerPropagation();
ConcurrentPropagationService.resetExecutorService(Thread.currentThread().getId());
//noinspection NonAtomicOperationOnVol... | [
"@",
"SuppressFBWarnings",
"(",
"value",
"=",
"\"VO_VOLATILE_INCREMENT\"",
",",
"justification",
"=",
"\"False Positive\"",
")",
"private",
"void",
"advanceEpoch",
"(",
")",
"{",
"awaitBgPropagationTermination",
"(",
")",
";",
"startEagerPropagation",
"(",
")",
";",
... | Advances the epoch while there is no background propagation
This ensures a propagation invoked before the reset cannot affect the sketch after the reset
is completed. | [
"Advances",
"the",
"epoch",
"while",
"there",
"is",
"no",
"background",
"propagation",
"This",
"ensures",
"a",
"propagation",
"invoked",
"before",
"the",
"reset",
"cannot",
"affect",
"the",
"sketch",
"after",
"the",
"reset",
"is",
"completed",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/ConcurrentHeapQuickSelectSketch.java#L236-L249 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/HeapUpdateDoublesSketch.java | HeapUpdateDoublesSketch.newInstance | static HeapUpdateDoublesSketch newInstance(final int k) {
final HeapUpdateDoublesSketch hqs = new HeapUpdateDoublesSketch(k);
final int baseBufAlloc = 2 * Math.min(DoublesSketch.MIN_K, k); //the min is important
hqs.n_ = 0;
hqs.combinedBuffer_ = new double[baseBufAlloc];
hqs.baseBufferCount_ = 0;
... | java | static HeapUpdateDoublesSketch newInstance(final int k) {
final HeapUpdateDoublesSketch hqs = new HeapUpdateDoublesSketch(k);
final int baseBufAlloc = 2 * Math.min(DoublesSketch.MIN_K, k); //the min is important
hqs.n_ = 0;
hqs.combinedBuffer_ = new double[baseBufAlloc];
hqs.baseBufferCount_ = 0;
... | [
"static",
"HeapUpdateDoublesSketch",
"newInstance",
"(",
"final",
"int",
"k",
")",
"{",
"final",
"HeapUpdateDoublesSketch",
"hqs",
"=",
"new",
"HeapUpdateDoublesSketch",
"(",
"k",
")",
";",
"final",
"int",
"baseBufAlloc",
"=",
"2",
"*",
"Math",
".",
"min",
"("... | Obtains a new on-heap instance of a DoublesSketch.
@param k Parameter that controls space usage of sketch and accuracy of estimates.
Must be greater than 1 and less than 65536 and a power of 2.
@return a HeapUpdateDoublesSketch | [
"Obtains",
"a",
"new",
"on",
"-",
"heap",
"instance",
"of",
"a",
"DoublesSketch",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/HeapUpdateDoublesSketch.java#L92-L102 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/HeapUpdateDoublesSketch.java | HeapUpdateDoublesSketch.srcMemoryToCombinedBuffer | private void srcMemoryToCombinedBuffer(final Memory srcMem, final int serVer,
final boolean srcIsCompact, final int combBufCap) {
final int preLongs = 2;
final int extra = (serVer == 1) ? 3 : 2; // space for min and max values, buf alloc (SerVer 1)
final int preBytes... | java | private void srcMemoryToCombinedBuffer(final Memory srcMem, final int serVer,
final boolean srcIsCompact, final int combBufCap) {
final int preLongs = 2;
final int extra = (serVer == 1) ? 3 : 2; // space for min and max values, buf alloc (SerVer 1)
final int preBytes... | [
"private",
"void",
"srcMemoryToCombinedBuffer",
"(",
"final",
"Memory",
"srcMem",
",",
"final",
"int",
"serVer",
",",
"final",
"boolean",
"srcIsCompact",
",",
"final",
"int",
"combBufCap",
")",
"{",
"final",
"int",
"preLongs",
"=",
"2",
";",
"final",
"int",
... | Loads the Combined Buffer, min and max from the given source Memory.
The resulting Combined Buffer is always in non-compact form and must be pre-allocated.
@param srcMem the given source Memory
@param serVer the serialization version of the source
@param srcIsCompact true if the given source Memory is in compact form
@... | [
"Loads",
"the",
"Combined",
"Buffer",
"min",
"and",
"max",
"from",
"the",
"given",
"source",
"Memory",
".",
"The",
"resulting",
"Combined",
"Buffer",
"is",
"always",
"in",
"non",
"-",
"compact",
"form",
"and",
"must",
"be",
"pre",
"-",
"allocated",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/HeapUpdateDoublesSketch.java#L252-L290 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/HeapUpdateDoublesSketch.java | HeapUpdateDoublesSketch.checkHeapMemCapacity | static void checkHeapMemCapacity(final int k, final long n, final boolean compact,
final int serVer, final long memCapBytes) {
final int metaPre = Family.QUANTILES.getMaxPreLongs() + ((serVer == 1) ? 3 : 2);
final int retainedItems = computeRetainedItems(k, n);
final int r... | java | static void checkHeapMemCapacity(final int k, final long n, final boolean compact,
final int serVer, final long memCapBytes) {
final int metaPre = Family.QUANTILES.getMaxPreLongs() + ((serVer == 1) ? 3 : 2);
final int retainedItems = computeRetainedItems(k, n);
final int r... | [
"static",
"void",
"checkHeapMemCapacity",
"(",
"final",
"int",
"k",
",",
"final",
"long",
"n",
",",
"final",
"boolean",
"compact",
",",
"final",
"int",
"serVer",
",",
"final",
"long",
"memCapBytes",
")",
"{",
"final",
"int",
"metaPre",
"=",
"Family",
".",
... | Checks the validity of the heap memory capacity assuming n, k and the compact state.
@param k the given value of k
@param n the given value of n
@param compact true if memory is in compact form
@param serVer serialization version of the source
@param memCapBytes the current memory capacity in bytes | [
"Checks",
"the",
"validity",
"of",
"the",
"heap",
"memory",
"capacity",
"assuming",
"n",
"k",
"and",
"the",
"compact",
"state",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/HeapUpdateDoublesSketch.java#L409-L426 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/cpc/PreambleUtil.java | PreambleUtil.getNumCoupons | static int getNumCoupons(final Memory mem) {
final Format format = getFormat(mem);
final HiField hiField = HiField.NUM_COUPONS;
final long offset = getHiFieldOffset(format, hiField);
return mem.getInt(offset);
} | java | static int getNumCoupons(final Memory mem) {
final Format format = getFormat(mem);
final HiField hiField = HiField.NUM_COUPONS;
final long offset = getHiFieldOffset(format, hiField);
return mem.getInt(offset);
} | [
"static",
"int",
"getNumCoupons",
"(",
"final",
"Memory",
"mem",
")",
"{",
"final",
"Format",
"format",
"=",
"getFormat",
"(",
"mem",
")",
";",
"final",
"HiField",
"hiField",
"=",
"HiField",
".",
"NUM_COUPONS",
";",
"final",
"long",
"offset",
"=",
"getHiFi... | PREAMBLE HI_FIELD GETS | [
"PREAMBLE",
"HI_FIELD",
"GETS"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/cpc/PreambleUtil.java#L288-L293 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/cpc/PreambleUtil.java | PreambleUtil.putEmptyMerged | static void putEmptyMerged(final WritableMemory wmem,
final int lgK,
final short seedHash) {
final Format format = Format.EMPTY_MERGED;
final byte preInts = getDefinedPreInts(format);
final byte fiCol = (byte) 0;
final byte flags = (byte) ((format.ordinal() << 2) | COMPRESSED_FLAG_MASK);
... | java | static void putEmptyMerged(final WritableMemory wmem,
final int lgK,
final short seedHash) {
final Format format = Format.EMPTY_MERGED;
final byte preInts = getDefinedPreInts(format);
final byte fiCol = (byte) 0;
final byte flags = (byte) ((format.ordinal() << 2) | COMPRESSED_FLAG_MASK);
... | [
"static",
"void",
"putEmptyMerged",
"(",
"final",
"WritableMemory",
"wmem",
",",
"final",
"int",
"lgK",
",",
"final",
"short",
"seedHash",
")",
"{",
"final",
"Format",
"format",
"=",
"Format",
".",
"EMPTY_MERGED",
";",
"final",
"byte",
"preInts",
"=",
"getDe... | PUT INTO MEMORY | [
"PUT",
"INTO",
"MEMORY"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/cpc/PreambleUtil.java#L380-L389 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/cpc/PreambleUtil.java | PreambleUtil.checkLoPreamble | static void checkLoPreamble(final Memory mem) {
rtAssertEquals(getSerVer(mem), SER_VER & 0XFF);
final Format fmt = getFormat(mem);
final int preIntsDef = getDefinedPreInts(fmt) & 0XFF;
rtAssertEquals(getPreInts(mem), preIntsDef);
final Family fam = getFamily(mem);
rtAssert(fam == Family.CPC);
... | java | static void checkLoPreamble(final Memory mem) {
rtAssertEquals(getSerVer(mem), SER_VER & 0XFF);
final Format fmt = getFormat(mem);
final int preIntsDef = getDefinedPreInts(fmt) & 0XFF;
rtAssertEquals(getPreInts(mem), preIntsDef);
final Family fam = getFamily(mem);
rtAssert(fam == Family.CPC);
... | [
"static",
"void",
"checkLoPreamble",
"(",
"final",
"Memory",
"mem",
")",
"{",
"rtAssertEquals",
"(",
"getSerVer",
"(",
"mem",
")",
",",
"SER_VER",
"&",
"0XFF",
")",
";",
"final",
"Format",
"fmt",
"=",
"getFormat",
"(",
"mem",
")",
";",
"final",
"int",
... | basic checks of SerVer, Format, preInts, Family, fiCol, lgK. | [
"basic",
"checks",
"of",
"SerVer",
"Format",
"preInts",
"Family",
"fiCol",
"lgK",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/cpc/PreambleUtil.java#L795-L806 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/kll/KllHelper.java | KllHelper.validateValues | static final void validateValues(final float[] values) {
for (int i = 0; i < values.length ; i++) {
if (Float.isNaN(values[i])) {
throw new SketchesArgumentException("Values must not be NaN");
}
if ((i < (values.length - 1)) && (values[i] >= values[i + 1])) {
throw new SketchesArgu... | java | static final void validateValues(final float[] values) {
for (int i = 0; i < values.length ; i++) {
if (Float.isNaN(values[i])) {
throw new SketchesArgumentException("Values must not be NaN");
}
if ((i < (values.length - 1)) && (values[i] >= values[i + 1])) {
throw new SketchesArgu... | [
"static",
"final",
"void",
"validateValues",
"(",
"final",
"float",
"[",
"]",
"values",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"Float",
".",
"isNaN",
"(",
"values",... | Checks the sequential validity of the given array of float values.
They must be unique, monotonically increasing and not NaN.
@param values the given array of values | [
"Checks",
"the",
"sequential",
"validity",
"of",
"the",
"given",
"array",
"of",
"float",
"values",
".",
"They",
"must",
"be",
"unique",
"monotonically",
"increasing",
"and",
"not",
"NaN",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/kll/KllHelper.java#L45-L55 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/HeapCompactUnorderedSketch.java | HeapCompactUnorderedSketch.compact | static CompactSketch compact(final long[] cache, final boolean empty,
final short seedHash, final int curCount, final long thetaLong) {
if ((curCount == 1) && (thetaLong == Long.MAX_VALUE)) {
return new SingleItemSketch(cache[0], seedHash);
}
return new HeapCompactUnorderedSketch(cache, empty, s... | java | static CompactSketch compact(final long[] cache, final boolean empty,
final short seedHash, final int curCount, final long thetaLong) {
if ((curCount == 1) && (thetaLong == Long.MAX_VALUE)) {
return new SingleItemSketch(cache[0], seedHash);
}
return new HeapCompactUnorderedSketch(cache, empty, s... | [
"static",
"CompactSketch",
"compact",
"(",
"final",
"long",
"[",
"]",
"cache",
",",
"final",
"boolean",
"empty",
",",
"final",
"short",
"seedHash",
",",
"final",
"int",
"curCount",
",",
"final",
"long",
"thetaLong",
")",
"{",
"if",
"(",
"(",
"curCount",
... | Constructs this sketch from correct, valid arguments.
@param cache in compact form
@param empty The correct <a href="{@docRoot}/resources/dictionary.html#empty">Empty</a>.
@param seedHash The correct
<a href="{@docRoot}/resources/dictionary.html#seedHash">Seed Hash</a>.
@param curCount correct value
@param thetaLong Th... | [
"Constructs",
"this",
"sketch",
"from",
"correct",
"valid",
"arguments",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/HeapCompactUnorderedSketch.java#L106-L112 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DirectUpdateDoublesSketch.java | DirectUpdateDoublesSketch.newInstance | static DirectUpdateDoublesSketch newInstance(final int k, final WritableMemory dstMem) {
// must be able to hold at least an empty sketch
final long memCap = dstMem.getCapacity();
checkDirectMemCapacity(k, 0, memCap);
//initialize dstMem
dstMem.putLong(0, 0L); //clear pre0
insertPreLongs(dstMem... | java | static DirectUpdateDoublesSketch newInstance(final int k, final WritableMemory dstMem) {
// must be able to hold at least an empty sketch
final long memCap = dstMem.getCapacity();
checkDirectMemCapacity(k, 0, memCap);
//initialize dstMem
dstMem.putLong(0, 0L); //clear pre0
insertPreLongs(dstMem... | [
"static",
"DirectUpdateDoublesSketch",
"newInstance",
"(",
"final",
"int",
"k",
",",
"final",
"WritableMemory",
"dstMem",
")",
"{",
"// must be able to hold at least an empty sketch",
"final",
"long",
"memCap",
"=",
"dstMem",
".",
"getCapacity",
"(",
")",
";",
"checkD... | Obtains a new Direct instance of a DoublesSketch, which may be off-heap.
@param k Parameter that controls space usage of sketch and accuracy of estimates.
Must be greater than 1 and less than 65536 and a power of 2.
@param dstMem the destination Memory that will be initialized to hold the data for this sketch.
It must... | [
"Obtains",
"a",
"new",
"Direct",
"instance",
"of",
"a",
"DoublesSketch",
"which",
"may",
"be",
"off",
"-",
"heap",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DirectUpdateDoublesSketch.java#L59-L81 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DirectUpdateDoublesSketch.java | DirectUpdateDoublesSketch.growCombinedMemBuffer | private WritableMemory growCombinedMemBuffer(final int itemSpaceNeeded) {
final long memBytes = mem_.getCapacity();
final int needBytes = (itemSpaceNeeded << 3) + COMBINED_BUFFER; //+ preamble + min & max
assert needBytes > memBytes;
memReqSvr = (memReqSvr == null) ? mem_.getMemoryRequestServer() : mem... | java | private WritableMemory growCombinedMemBuffer(final int itemSpaceNeeded) {
final long memBytes = mem_.getCapacity();
final int needBytes = (itemSpaceNeeded << 3) + COMBINED_BUFFER; //+ preamble + min & max
assert needBytes > memBytes;
memReqSvr = (memReqSvr == null) ? mem_.getMemoryRequestServer() : mem... | [
"private",
"WritableMemory",
"growCombinedMemBuffer",
"(",
"final",
"int",
"itemSpaceNeeded",
")",
"{",
"final",
"long",
"memBytes",
"=",
"mem_",
".",
"getCapacity",
"(",
")",
";",
"final",
"int",
"needBytes",
"=",
"(",
"itemSpaceNeeded",
"<<",
"3",
")",
"+",
... | Direct supporting methods | [
"Direct",
"supporting",
"methods"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DirectUpdateDoublesSketch.java#L233-L247 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java | VarOptItemsSketch.newInstance | public static <T> VarOptItemsSketch<T> newInstance(final int k, final ResizeFactor rf) {
return new VarOptItemsSketch<>(k, rf);
} | java | public static <T> VarOptItemsSketch<T> newInstance(final int k, final ResizeFactor rf) {
return new VarOptItemsSketch<>(k, rf);
} | [
"public",
"static",
"<",
"T",
">",
"VarOptItemsSketch",
"<",
"T",
">",
"newInstance",
"(",
"final",
"int",
"k",
",",
"final",
"ResizeFactor",
"rf",
")",
"{",
"return",
"new",
"VarOptItemsSketch",
"<>",
"(",
"k",
",",
"rf",
")",
";",
"}"
] | Construct a varopt sampling sketch with up to k samples using the specified resize factor.
@param k Maximum size of sampling. Allocated size may be smaller until sketch fills.
Unlike many sketches in this package, this value does <em>not</em> need to be a
power of 2.
@param rf <a href="{@docRoot}/resources/dictiona... | [
"Construct",
"a",
"varopt",
"sampling",
"sketch",
"with",
"up",
"to",
"k",
"samples",
"using",
"the",
"specified",
"resize",
"factor",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java#L192-L194 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java | VarOptItemsSketch.newInstanceAsGadget | static <T> VarOptItemsSketch<T> newInstanceAsGadget(final int k) {
final VarOptItemsSketch<T> sketch = new VarOptItemsSketch<>(k, DEFAULT_RESIZE_FACTOR);
sketch.marks_ = new ArrayList<>(sketch.currItemsAlloc_);
return sketch;
} | java | static <T> VarOptItemsSketch<T> newInstanceAsGadget(final int k) {
final VarOptItemsSketch<T> sketch = new VarOptItemsSketch<>(k, DEFAULT_RESIZE_FACTOR);
sketch.marks_ = new ArrayList<>(sketch.currItemsAlloc_);
return sketch;
} | [
"static",
"<",
"T",
">",
"VarOptItemsSketch",
"<",
"T",
">",
"newInstanceAsGadget",
"(",
"final",
"int",
"k",
")",
"{",
"final",
"VarOptItemsSketch",
"<",
"T",
">",
"sketch",
"=",
"new",
"VarOptItemsSketch",
"<>",
"(",
"k",
",",
"DEFAULT_RESIZE_FACTOR",
")",... | Construct a varopt sketch for use as a unioning gadget, meaning the array of marked elements
is also initialized.
@param k Maximum size of sampling. Allocated size may be smaller until sketch fills.
Unlike many sketches in this package, this value does <em>not</em> need to be a
power of 2.
@param <T> The type of obj... | [
"Construct",
"a",
"varopt",
"sketch",
"for",
"use",
"as",
"a",
"unioning",
"gadget",
"meaning",
"the",
"array",
"of",
"marked",
"elements",
"is",
"also",
"initialized",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java#L206-L210 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java | VarOptItemsSketch.copyAndSetN | VarOptItemsSketch<T> copyAndSetN(final boolean asSketch, final long adjustedN) {
final VarOptItemsSketch<T> sketch;
sketch = new VarOptItemsSketch<>(data_, weights_, k_,n_,
currItemsAlloc_, rf_, h_, r_, totalWtR_);
if (!asSketch) {
sketch.marks_ = this.marks_;
sketch.numMarksInH_ = ... | java | VarOptItemsSketch<T> copyAndSetN(final boolean asSketch, final long adjustedN) {
final VarOptItemsSketch<T> sketch;
sketch = new VarOptItemsSketch<>(data_, weights_, k_,n_,
currItemsAlloc_, rf_, h_, r_, totalWtR_);
if (!asSketch) {
sketch.marks_ = this.marks_;
sketch.numMarksInH_ = ... | [
"VarOptItemsSketch",
"<",
"T",
">",
"copyAndSetN",
"(",
"final",
"boolean",
"asSketch",
",",
"final",
"long",
"adjustedN",
")",
"{",
"final",
"VarOptItemsSketch",
"<",
"T",
">",
"sketch",
";",
"sketch",
"=",
"new",
"VarOptItemsSketch",
"<>",
"(",
"data_",
",... | Creates a copy of the sketch, optionally discarding any information about marks that would
indicate the class's use as a union gadget as opposed to a valid sketch.
@param asSketch If true, copies as a sketch; if false, copies as a union gadget
@param adjustedN Target value of n for the resulting sketch. Ignored if neg... | [
"Creates",
"a",
"copy",
"of",
"the",
"sketch",
"optionally",
"discarding",
"any",
"information",
"about",
"marks",
"that",
"would",
"indicate",
"the",
"class",
"s",
"use",
"as",
"a",
"union",
"gadget",
"as",
"opposed",
"to",
"a",
"valid",
"sketch",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java#L682-L697 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java | VarOptItemsSketch.decreaseKBy1 | void decreaseKBy1() {
if (k_ <= 1) {
throw new SketchesStateException("Cannot decrease k below 1 in union");
}
if ((h_ == 0) && (r_ == 0)) {
// exact mode, but no data yet; this reduction is somewhat gratuitous
--k_;
} else if ((h_ > 0) && (r_ == 0)) {
// exact mode, but we have... | java | void decreaseKBy1() {
if (k_ <= 1) {
throw new SketchesStateException("Cannot decrease k below 1 in union");
}
if ((h_ == 0) && (r_ == 0)) {
// exact mode, but no data yet; this reduction is somewhat gratuitous
--k_;
} else if ((h_ > 0) && (r_ == 0)) {
// exact mode, but we have... | [
"void",
"decreaseKBy1",
"(",
")",
"{",
"if",
"(",
"k_",
"<=",
"1",
")",
"{",
"throw",
"new",
"SketchesStateException",
"(",
"\"Cannot decrease k below 1 in union\"",
")",
";",
"}",
"if",
"(",
"(",
"h_",
"==",
"0",
")",
"&&",
"(",
"r_",
"==",
"0",
")",
... | Decreases sketch's value of k by 1, updating stored values as needed.
<p>Subject to certain pre-conditions, decreasing k causes tau to increase. This fact is used by
the unioning algorithm to force "marked" items out of H and into the reservoir region.</p> | [
"Decreases",
"sketch",
"s",
"value",
"of",
"k",
"by",
"1",
"updating",
"stored",
"values",
"as",
"needed",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/VarOptItemsSketch.java#L841-L896 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesUpdatableSketchBuilder.java | ArrayOfDoublesUpdatableSketchBuilder.build | public ArrayOfDoublesUpdatableSketch build(final WritableMemory dstMem) {
return new DirectArrayOfDoublesQuickSelectSketch(nomEntries_, resizeFactor_.lg(),
samplingProbability_, numValues_, seed_, dstMem);
} | java | public ArrayOfDoublesUpdatableSketch build(final WritableMemory dstMem) {
return new DirectArrayOfDoublesQuickSelectSketch(nomEntries_, resizeFactor_.lg(),
samplingProbability_, numValues_, seed_, dstMem);
} | [
"public",
"ArrayOfDoublesUpdatableSketch",
"build",
"(",
"final",
"WritableMemory",
"dstMem",
")",
"{",
"return",
"new",
"DirectArrayOfDoublesQuickSelectSketch",
"(",
"nomEntries_",
",",
"resizeFactor_",
".",
"lg",
"(",
")",
",",
"samplingProbability_",
",",
"numValues_... | Returns an ArrayOfDoublesUpdatableSketch with the current configuration of this Builder.
@param dstMem instance of Memory to be used by the sketch
@return an ArrayOfDoublesUpdatableSketch | [
"Returns",
"an",
"ArrayOfDoublesUpdatableSketch",
"with",
"the",
"current",
"configuration",
"of",
"this",
"Builder",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/ArrayOfDoublesUpdatableSketchBuilder.java#L113-L116 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.bytesToInt | public static int bytesToInt(final byte[] arr) {
int v = 0;
for (int i = 0; i < 4; i++) {
v |= (arr[i] & 0XFF) << (i * 8);
}
return v;
} | java | public static int bytesToInt(final byte[] arr) {
int v = 0;
for (int i = 0; i < 4; i++) {
v |= (arr[i] & 0XFF) << (i * 8);
}
return v;
} | [
"public",
"static",
"int",
"bytesToInt",
"(",
"final",
"byte",
"[",
"]",
"arr",
")",
"{",
"int",
"v",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"v",
"|=",
"(",
"arr",
"[",
"i",
"]",
"&"... | Returns an int extracted from a Little-Endian byte array.
@param arr the given byte array
@return an int extracted from a Little-Endian byte array. | [
"Returns",
"an",
"int",
"extracted",
"from",
"a",
"Little",
"-",
"Endian",
"byte",
"array",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L113-L119 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.bytesToLong | public static long bytesToLong(final byte[] arr) {
long v = 0;
for (int i = 0; i < 8; i++) {
v |= (arr[i] & 0XFFL) << (i * 8);
}
return v;
} | java | public static long bytesToLong(final byte[] arr) {
long v = 0;
for (int i = 0; i < 8; i++) {
v |= (arr[i] & 0XFFL) << (i * 8);
}
return v;
} | [
"public",
"static",
"long",
"bytesToLong",
"(",
"final",
"byte",
"[",
"]",
"arr",
")",
"{",
"long",
"v",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"{",
"v",
"|=",
"(",
"arr",
"[",
"i",
"]",
... | Returns a long extracted from a Little-Endian byte array.
@param arr the given byte array
@return a long extracted from a Little-Endian byte array. | [
"Returns",
"a",
"long",
"extracted",
"from",
"a",
"Little",
"-",
"Endian",
"byte",
"array",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L126-L132 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.intToBytes | public static byte[] intToBytes(int v, final byte[] arr) {
for (int i = 0; i < 4; i++) {
arr[i] = (byte) (v & 0XFF);
v >>>= 8;
}
return arr;
} | java | public static byte[] intToBytes(int v, final byte[] arr) {
for (int i = 0; i < 4; i++) {
arr[i] = (byte) (v & 0XFF);
v >>>= 8;
}
return arr;
} | [
"public",
"static",
"byte",
"[",
"]",
"intToBytes",
"(",
"int",
"v",
",",
"final",
"byte",
"[",
"]",
"arr",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"arr",
"[",
"i",
"]",
"=",
"(",
"byte",
... | Returns a Little-Endian byte array extracted from the given int.
@param v the given int
@param arr a given array of 4 bytes that will be returned with the data
@return a Little-Endian byte array extracted from the given int. | [
"Returns",
"a",
"Little",
"-",
"Endian",
"byte",
"array",
"extracted",
"from",
"the",
"given",
"int",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L140-L146 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.longToBytes | public static byte[] longToBytes(long v, final byte[] arr) {
for (int i = 0; i < 8; i++) {
arr[i] = (byte) (v & 0XFFL);
v >>>= 8;
}
return arr;
} | java | public static byte[] longToBytes(long v, final byte[] arr) {
for (int i = 0; i < 8; i++) {
arr[i] = (byte) (v & 0XFFL);
v >>>= 8;
}
return arr;
} | [
"public",
"static",
"byte",
"[",
"]",
"longToBytes",
"(",
"long",
"v",
",",
"final",
"byte",
"[",
"]",
"arr",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"{",
"arr",
"[",
"i",
"]",
"=",
"(",
"byte",
... | Returns a Little-Endian byte array extracted from the given long.
@param v the given long
@param arr a given array of 8 bytes that will be returned with the data
@return a Little-Endian byte array extracted from the given long. | [
"Returns",
"a",
"Little",
"-",
"Endian",
"byte",
"array",
"extracted",
"from",
"the",
"given",
"long",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L154-L160 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.longToHexBytes | public static String longToHexBytes(final long v) {
final long mask = 0XFFL;
final StringBuilder sb = new StringBuilder();
for (int i = 8; i-- > 0; ) {
final String s = Long.toHexString((v >>> (i * 8)) & mask);
sb.append(zeroPad(s, 2)).append(" ");
}
return sb.toString();
} | java | public static String longToHexBytes(final long v) {
final long mask = 0XFFL;
final StringBuilder sb = new StringBuilder();
for (int i = 8; i-- > 0; ) {
final String s = Long.toHexString((v >>> (i * 8)) & mask);
sb.append(zeroPad(s, 2)).append(" ");
}
return sb.toString();
} | [
"public",
"static",
"String",
"longToHexBytes",
"(",
"final",
"long",
"v",
")",
"{",
"final",
"long",
"mask",
"=",
"0XFF",
"L",
";",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"8",
";",
"i... | Returns a string of spaced hex bytes in Big-Endian order.
@param v the given long
@return string of spaced hex bytes in Big-Endian order. | [
"Returns",
"a",
"string",
"of",
"spaced",
"hex",
"bytes",
"in",
"Big",
"-",
"Endian",
"order",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L169-L177 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.bytesToString | public static String bytesToString(
final byte[] arr, final boolean signed, final boolean littleEndian, final String sep) {
final StringBuilder sb = new StringBuilder();
final int mask = (signed) ? 0XFFFFFFFF : 0XFF;
final int arrLen = arr.length;
if (littleEndian) {
for (int i = 0; i < (arr... | java | public static String bytesToString(
final byte[] arr, final boolean signed, final boolean littleEndian, final String sep) {
final StringBuilder sb = new StringBuilder();
final int mask = (signed) ? 0XFFFFFFFF : 0XFF;
final int arrLen = arr.length;
if (littleEndian) {
for (int i = 0; i < (arr... | [
"public",
"static",
"String",
"bytesToString",
"(",
"final",
"byte",
"[",
"]",
"arr",
",",
"final",
"boolean",
"signed",
",",
"final",
"boolean",
"littleEndian",
",",
"final",
"String",
"sep",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuil... | Returns a string view of a byte array
@param arr the given byte array
@param signed set true if you want the byte values signed.
@param littleEndian set true if you want Little-Endian order
@param sep the separator string between bytes
@return a string view of a byte array | [
"Returns",
"a",
"string",
"view",
"of",
"a",
"byte",
"array"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L187-L204 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.nanoSecToString | public static String nanoSecToString(final long nS) {
final long rem_nS = (long)(nS % 1000.0);
final long rem_uS = (long)((nS / 1000.0) % 1000.0);
final long rem_mS = (long)((nS / 1000000.0) % 1000.0);
final long sec = (long)(nS / 1000000000.0);
final String nSstr = zeroPad(Long.toString(rem_nS),... | java | public static String nanoSecToString(final long nS) {
final long rem_nS = (long)(nS % 1000.0);
final long rem_uS = (long)((nS / 1000.0) % 1000.0);
final long rem_mS = (long)((nS / 1000000.0) % 1000.0);
final long sec = (long)(nS / 1000000000.0);
final String nSstr = zeroPad(Long.toString(rem_nS),... | [
"public",
"static",
"String",
"nanoSecToString",
"(",
"final",
"long",
"nS",
")",
"{",
"final",
"long",
"rem_nS",
"=",
"(",
"long",
")",
"(",
"nS",
"%",
"1000.0",
")",
";",
"final",
"long",
"rem_uS",
"=",
"(",
"long",
")",
"(",
"(",
"nS",
"/",
"100... | Returns the given time in nanoseconds formatted as Sec.mSec uSec nSec
@param nS the given nanoseconds
@return the given time in nanoseconds formatted as Sec.mSec uSec nSec | [
"Returns",
"the",
"given",
"time",
"in",
"nanoseconds",
"formatted",
"as",
"Sec",
".",
"mSec",
"uSec",
"nSec"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L211-L220 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.characterPad | public static final String characterPad(final String s, final int fieldLength, final char padChar,
final boolean postpend) {
final char[] chArr = s.toCharArray();
final int sLen = chArr.length;
if (sLen < fieldLength) {
final char[] out = new char[fieldLength];
final int blanks = fieldLeng... | java | public static final String characterPad(final String s, final int fieldLength, final char padChar,
final boolean postpend) {
final char[] chArr = s.toCharArray();
final int sLen = chArr.length;
if (sLen < fieldLength) {
final char[] out = new char[fieldLength];
final int blanks = fieldLeng... | [
"public",
"static",
"final",
"String",
"characterPad",
"(",
"final",
"String",
"s",
",",
"final",
"int",
"fieldLength",
",",
"final",
"char",
"padChar",
",",
"final",
"boolean",
"postpend",
")",
"{",
"final",
"char",
"[",
"]",
"chArr",
"=",
"s",
".",
"to... | Prepend or postpend the given string with the given character to fill the given field length.
If the given string is equal or greater than the given field length, it will be returned
without modification.
@param s the given string
@param fieldLength the desired field length
@param padChar the desired pad character
@par... | [
"Prepend",
"or",
"postpend",
"the",
"given",
"string",
"with",
"the",
"given",
"character",
"to",
"fill",
"the",
"given",
"field",
"length",
".",
"If",
"the",
"given",
"string",
"is",
"equal",
"or",
"greater",
"than",
"the",
"given",
"field",
"length",
"it... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L260-L287 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.computeSeedHash | public static short computeSeedHash(final long seed) {
final long[] seedArr = {seed};
final short seedHash = (short)((hash(seedArr, 0L)[0]) & 0xFFFFL);
if (seedHash == 0) {
throw new SketchesArgumentException(
"The given seed: " + seed + " produced a seedHash of zero. "
+ "You ... | java | public static short computeSeedHash(final long seed) {
final long[] seedArr = {seed};
final short seedHash = (short)((hash(seedArr, 0L)[0]) & 0xFFFFL);
if (seedHash == 0) {
throw new SketchesArgumentException(
"The given seed: " + seed + " produced a seedHash of zero. "
+ "You ... | [
"public",
"static",
"short",
"computeSeedHash",
"(",
"final",
"long",
"seed",
")",
"{",
"final",
"long",
"[",
"]",
"seedArr",
"=",
"{",
"seed",
"}",
";",
"final",
"short",
"seedHash",
"=",
"(",
"short",
")",
"(",
"(",
"hash",
"(",
"seedArr",
",",
"0L... | Computes and checks the 16-bit seed hash from the given long seed.
The seed hash may not be zero in order to maintain compatibility with older serialized
versions that did not have this concept.
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>
@return the seed hash. | [
"Computes",
"and",
"checks",
"the",
"16",
"-",
"bit",
"seed",
"hash",
"from",
"the",
"given",
"long",
"seed",
".",
"The",
"seed",
"hash",
"may",
"not",
"be",
"zero",
"in",
"order",
"to",
"maintain",
"compatibility",
"with",
"older",
"serialized",
"versions... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L312-L321 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.checkIfMultipleOf8AndGT0 | public static void checkIfMultipleOf8AndGT0(final long v, final String argName) {
if (((v & 0X7L) == 0L) && (v > 0L)) {
return;
}
throw new SketchesArgumentException("The value of the parameter \"" + argName
+ "\" must be a positive multiple of 8 and greater than zero: " + v);
} | java | public static void checkIfMultipleOf8AndGT0(final long v, final String argName) {
if (((v & 0X7L) == 0L) && (v > 0L)) {
return;
}
throw new SketchesArgumentException("The value of the parameter \"" + argName
+ "\" must be a positive multiple of 8 and greater than zero: " + v);
} | [
"public",
"static",
"void",
"checkIfMultipleOf8AndGT0",
"(",
"final",
"long",
"v",
",",
"final",
"String",
"argName",
")",
"{",
"if",
"(",
"(",
"(",
"v",
"&",
"0X7",
"L",
")",
"==",
"0L",
")",
"&&",
"(",
"v",
">",
"0L",
")",
")",
"{",
"return",
"... | Checks if parameter v is a multiple of 8 and greater than zero.
@param v The parameter to check
@param argName This name will be part of the error message if the check fails. | [
"Checks",
"if",
"parameter",
"v",
"is",
"a",
"multiple",
"of",
"8",
"and",
"greater",
"than",
"zero",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L330-L336 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.checkIfPowerOf2 | public static void checkIfPowerOf2(final int v, final String argName) {
if ((v > 0) && ((v & (v - 1)) == 0)) {
return;
}
throw new SketchesArgumentException("The value of the parameter \"" + argName
+ "\" must be a positive integer-power of 2" + " and greater than 0: " + v);
} | java | public static void checkIfPowerOf2(final int v, final String argName) {
if ((v > 0) && ((v & (v - 1)) == 0)) {
return;
}
throw new SketchesArgumentException("The value of the parameter \"" + argName
+ "\" must be a positive integer-power of 2" + " and greater than 0: " + v);
} | [
"public",
"static",
"void",
"checkIfPowerOf2",
"(",
"final",
"int",
"v",
",",
"final",
"String",
"argName",
")",
"{",
"if",
"(",
"(",
"v",
">",
"0",
")",
"&&",
"(",
"(",
"v",
"&",
"(",
"v",
"-",
"1",
")",
")",
"==",
"0",
")",
")",
"{",
"retur... | Checks the given parameter to make sure it is positive, an integer-power of 2 and greater than
zero.
@param v The input argument.
@param argName Used in the thrown exception. | [
"Checks",
"the",
"given",
"parameter",
"to",
"make",
"sure",
"it",
"is",
"positive",
"an",
"integer",
"-",
"power",
"of",
"2",
"and",
"greater",
"than",
"zero",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L366-L372 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.toLog2 | public static int toLog2(final int value, final String argName) {
checkIfPowerOf2(value, argName);
return Integer.numberOfTrailingZeros(value);
} | java | public static int toLog2(final int value, final String argName) {
checkIfPowerOf2(value, argName);
return Integer.numberOfTrailingZeros(value);
} | [
"public",
"static",
"int",
"toLog2",
"(",
"final",
"int",
"value",
",",
"final",
"String",
"argName",
")",
"{",
"checkIfPowerOf2",
"(",
"value",
",",
"argName",
")",
";",
"return",
"Integer",
".",
"numberOfTrailingZeros",
"(",
"value",
")",
";",
"}"
] | Checks the given value if it is a power of 2. If not, it throws an exception.
Otherwise, returns the log-base2 of the given value.
@param value must be a power of 2 and greater than zero.
@param argName the argument name used in the exception if thrown.
@return the log-base2 of the given value | [
"Checks",
"the",
"given",
"value",
"if",
"it",
"is",
"a",
"power",
"of",
"2",
".",
"If",
"not",
"it",
"throws",
"an",
"exception",
".",
"Otherwise",
"returns",
"the",
"log",
"-",
"base2",
"of",
"the",
"given",
"value",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L381-L384 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.evenlyLgSpaced | public static int[] evenlyLgSpaced(final int lgStart, final int lgEnd, final int points) {
if (points <= 0) {
throw new SketchesArgumentException("points must be > 0");
}
if ((lgEnd < 0) || (lgStart < 0)) {
throw new SketchesArgumentException("lgStart and lgEnd must be >= 0.");
}
final i... | java | public static int[] evenlyLgSpaced(final int lgStart, final int lgEnd, final int points) {
if (points <= 0) {
throw new SketchesArgumentException("points must be > 0");
}
if ((lgEnd < 0) || (lgStart < 0)) {
throw new SketchesArgumentException("lgStart and lgEnd must be >= 0.");
}
final i... | [
"public",
"static",
"int",
"[",
"]",
"evenlyLgSpaced",
"(",
"final",
"int",
"lgStart",
",",
"final",
"int",
"lgEnd",
",",
"final",
"int",
"points",
")",
"{",
"if",
"(",
"points",
"<=",
"0",
")",
"{",
"throw",
"new",
"SketchesArgumentException",
"(",
"\"p... | Returns an int array of points that will be evenly spaced on a log axis.
This is designed for Log_base2 numbers.
@param lgStart the Log_base2 of the starting value. E.g., for 1 lgStart = 0.
@param lgEnd the Log_base2 of the ending value. E.g. for 1024 lgEnd = 10.
@param points the total number of points including the s... | [
"Returns",
"an",
"int",
"array",
"of",
"points",
"that",
"will",
"be",
"evenly",
"spaced",
"on",
"a",
"log",
"axis",
".",
"This",
"is",
"designed",
"for",
"Log_base2",
"numbers",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L447-L463 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.simpleIntLog2 | public static int simpleIntLog2(final int x) {
final int exp = Integer.numberOfTrailingZeros(x);
if (x != (1 << exp)) {
throw new SketchesArgumentException("Argument x cannot be negative or zero.");
}
return exp;
} | java | public static int simpleIntLog2(final int x) {
final int exp = Integer.numberOfTrailingZeros(x);
if (x != (1 << exp)) {
throw new SketchesArgumentException("Argument x cannot be negative or zero.");
}
return exp;
} | [
"public",
"static",
"int",
"simpleIntLog2",
"(",
"final",
"int",
"x",
")",
"{",
"final",
"int",
"exp",
"=",
"Integer",
".",
"numberOfTrailingZeros",
"(",
"x",
")",
";",
"if",
"(",
"x",
"!=",
"(",
"1",
"<<",
"exp",
")",
")",
"{",
"throw",
"new",
"Sk... | Gives the log2 of an integer that is known to be a power of 2.
@param x number that is greater than zero
@return the log2 of an integer that is known to be a power of 2. | [
"Gives",
"the",
"log2",
"of",
"an",
"integer",
"that",
"is",
"known",
"to",
"be",
"a",
"power",
"of",
"2",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L544-L550 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/Util.java | Util.startingSubMultiple | public static final int startingSubMultiple(final int lgTarget, final ResizeFactor rf,
final int lgMin) {
final int lgRF = rf.lg();
return (lgTarget <= lgMin) ? lgMin : (lgRF == 0) ? lgTarget : ((lgTarget - lgMin) % lgRF) + lgMin;
} | java | public static final int startingSubMultiple(final int lgTarget, final ResizeFactor rf,
final int lgMin) {
final int lgRF = rf.lg();
return (lgTarget <= lgMin) ? lgMin : (lgRF == 0) ? lgTarget : ((lgTarget - lgMin) % lgRF) + lgMin;
} | [
"public",
"static",
"final",
"int",
"startingSubMultiple",
"(",
"final",
"int",
"lgTarget",
",",
"final",
"ResizeFactor",
"rf",
",",
"final",
"int",
"lgMin",
")",
"{",
"final",
"int",
"lgRF",
"=",
"rf",
".",
"lg",
"(",
")",
";",
"return",
"(",
"lgTarget"... | Gets the smallest allowed exponent of 2 that it is a sub-multiple of the target by zero,
one or more resize factors.
@param lgTarget Log2 of the target size
@param rf <a href="{@docRoot}/resources/dictionary.html#resizeFactor">See Resize Factor</a>
@param lgMin Log2 of the minimum allowed starting size
@return The Log... | [
"Gets",
"the",
"smallest",
"allowed",
"exponent",
"of",
"2",
"that",
"it",
"is",
"a",
"sub",
"-",
"multiple",
"of",
"the",
"target",
"by",
"zero",
"one",
"or",
"more",
"resize",
"factors",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/Util.java#L561-L565 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/UpdateSketch.java | UpdateSketch.heapify | public static UpdateSketch heapify(final Memory srcMem, final long seed) {
final Family family = Family.idToFamily(srcMem.getByte(FAMILY_BYTE));
if (family.equals(Family.ALPHA)) {
return HeapAlphaSketch.heapifyInstance(srcMem, seed);
}
return HeapQuickSelectSketch.heapifyInstance(srcMem, seed);
... | java | public static UpdateSketch heapify(final Memory srcMem, final long seed) {
final Family family = Family.idToFamily(srcMem.getByte(FAMILY_BYTE));
if (family.equals(Family.ALPHA)) {
return HeapAlphaSketch.heapifyInstance(srcMem, seed);
}
return HeapQuickSelectSketch.heapifyInstance(srcMem, seed);
... | [
"public",
"static",
"UpdateSketch",
"heapify",
"(",
"final",
"Memory",
"srcMem",
",",
"final",
"long",
"seed",
")",
"{",
"final",
"Family",
"family",
"=",
"Family",
".",
"idToFamily",
"(",
"srcMem",
".",
"getByte",
"(",
"FAMILY_BYTE",
")",
")",
";",
"if",
... | Instantiates an on-heap UpdateSketch from Memory.
@param srcMem <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See Update Hash Seed</a>.
@return an UpdateSketch | [
"Instantiates",
"an",
"on",
"-",
"heap",
"UpdateSketch",
"from",
"Memory",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/UpdateSketch.java#L107-L113 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/UpdateSketch.java | UpdateSketch.update | public UpdateReturnState update(final String datum) {
if ((datum == null) || datum.isEmpty()) {
return RejectedNullOrEmpty;
}
final byte[] data = datum.getBytes(UTF_8);
return hashUpdate(hash(data, getSeed())[0] >>> 1);
} | java | public UpdateReturnState update(final String datum) {
if ((datum == null) || datum.isEmpty()) {
return RejectedNullOrEmpty;
}
final byte[] data = datum.getBytes(UTF_8);
return hashUpdate(hash(data, getSeed())[0] >>> 1);
} | [
"public",
"UpdateReturnState",
"update",
"(",
"final",
"String",
"datum",
")",
"{",
"if",
"(",
"(",
"datum",
"==",
"null",
")",
"||",
"datum",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"RejectedNullOrEmpty",
";",
"}",
"final",
"byte",
"[",
"]",
"da... | Present this sketch with the given String.
The string is converted to a byte array using UTF8 encoding.
If the string is null or empty no update attempt is made and the method returns.
<p>Note: this will not produce the same output hash values as the {@link #update(char[])}
method and will generally be a little slower... | [
"Present",
"this",
"sketch",
"with",
"the",
"given",
"String",
".",
"The",
"string",
"is",
"converted",
"to",
"a",
"byte",
"array",
"using",
"UTF8",
"encoding",
".",
"If",
"the",
"string",
"is",
"null",
"or",
"empty",
"no",
"update",
"attempt",
"is",
"ma... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/UpdateSketch.java#L229-L235 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/UpdateSketch.java | UpdateSketch.update | public UpdateReturnState update(final byte[] data) {
if ((data == null) || (data.length == 0)) {
return RejectedNullOrEmpty;
}
return hashUpdate(hash(data, getSeed())[0] >>> 1);
} | java | public UpdateReturnState update(final byte[] data) {
if ((data == null) || (data.length == 0)) {
return RejectedNullOrEmpty;
}
return hashUpdate(hash(data, getSeed())[0] >>> 1);
} | [
"public",
"UpdateReturnState",
"update",
"(",
"final",
"byte",
"[",
"]",
"data",
")",
"{",
"if",
"(",
"(",
"data",
"==",
"null",
")",
"||",
"(",
"data",
".",
"length",
"==",
"0",
")",
")",
"{",
"return",
"RejectedNullOrEmpty",
";",
"}",
"return",
"ha... | Present this sketch with the given byte array.
If the byte array is null or empty no update attempt is made and the method returns.
@param data The given byte array.
@return
<a href="{@docRoot}/resources/dictionary.html#updateReturnState">See Update Return State</a> | [
"Present",
"this",
"sketch",
"with",
"the",
"given",
"byte",
"array",
".",
"If",
"the",
"byte",
"array",
"is",
"null",
"or",
"empty",
"no",
"update",
"attempt",
"is",
"made",
"and",
"the",
"method",
"returns",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/UpdateSketch.java#L245-L250 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java | DoublesSketch.heapify | public static DoublesSketch heapify(final Memory srcMem) {
if (checkIsCompactMemory(srcMem)) {
return CompactDoublesSketch.heapify(srcMem);
}
return UpdateDoublesSketch.heapify(srcMem);
} | java | public static DoublesSketch heapify(final Memory srcMem) {
if (checkIsCompactMemory(srcMem)) {
return CompactDoublesSketch.heapify(srcMem);
}
return UpdateDoublesSketch.heapify(srcMem);
} | [
"public",
"static",
"DoublesSketch",
"heapify",
"(",
"final",
"Memory",
"srcMem",
")",
"{",
"if",
"(",
"checkIsCompactMemory",
"(",
"srcMem",
")",
")",
"{",
"return",
"CompactDoublesSketch",
".",
"heapify",
"(",
"srcMem",
")",
";",
"}",
"return",
"UpdateDouble... | Heapify takes the sketch image in Memory and instantiates an on-heap Sketch.
The resulting sketch will not retain any link to the source Memory.
@param srcMem a Memory image of a Sketch.
<a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@return a heap-based Sketch based on the given Memory | [
"Heapify",
"takes",
"the",
"sketch",
"image",
"in",
"Memory",
"and",
"instantiates",
"an",
"on",
"-",
"heap",
"Sketch",
".",
"The",
"resulting",
"sketch",
"will",
"not",
"retain",
"any",
"link",
"to",
"the",
"source",
"Memory",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java#L167-L172 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java | DoublesSketch.wrap | public static DoublesSketch wrap(final Memory srcMem) {
if (checkIsCompactMemory(srcMem)) {
return DirectCompactDoublesSketch.wrapInstance(srcMem);
}
return DirectUpdateDoublesSketchR.wrapInstance(srcMem);
} | java | public static DoublesSketch wrap(final Memory srcMem) {
if (checkIsCompactMemory(srcMem)) {
return DirectCompactDoublesSketch.wrapInstance(srcMem);
}
return DirectUpdateDoublesSketchR.wrapInstance(srcMem);
} | [
"public",
"static",
"DoublesSketch",
"wrap",
"(",
"final",
"Memory",
"srcMem",
")",
"{",
"if",
"(",
"checkIsCompactMemory",
"(",
"srcMem",
")",
")",
"{",
"return",
"DirectCompactDoublesSketch",
".",
"wrapInstance",
"(",
"srcMem",
")",
";",
"}",
"return",
"Dire... | Wrap this sketch around the given Memory image of a DoublesSketch, compact or non-compact.
@param srcMem the given Memory image of a DoublesSketch that may have data,
@return a sketch that wraps the given srcMem | [
"Wrap",
"this",
"sketch",
"around",
"the",
"given",
"Memory",
"image",
"of",
"a",
"DoublesSketch",
"compact",
"or",
"non",
"-",
"compact",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java#L180-L185 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java | DoublesSketch.downSample | public DoublesSketch downSample(final DoublesSketch srcSketch, final int smallerK,
final WritableMemory dstMem) {
return downSampleInternal(srcSketch, smallerK, dstMem);
} | java | public DoublesSketch downSample(final DoublesSketch srcSketch, final int smallerK,
final WritableMemory dstMem) {
return downSampleInternal(srcSketch, smallerK, dstMem);
} | [
"public",
"DoublesSketch",
"downSample",
"(",
"final",
"DoublesSketch",
"srcSketch",
",",
"final",
"int",
"smallerK",
",",
"final",
"WritableMemory",
"dstMem",
")",
"{",
"return",
"downSampleInternal",
"(",
"srcSketch",
",",
"smallerK",
",",
"dstMem",
")",
";",
... | From an source sketch, create a new sketch that must have a smaller value of K.
The original sketch is not modified.
@param srcSketch the sourcing sketch
@param smallerK the new sketch's value of K that must be smaller than this value of K.
It is required that this.getK() = smallerK * 2^(nonnegative integer).
@param d... | [
"From",
"an",
"source",
"sketch",
"create",
"a",
"new",
"sketch",
"that",
"must",
"have",
"a",
"smaller",
"value",
"of",
"K",
".",
"The",
"original",
"sketch",
"is",
"not",
"modified",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java#L601-L604 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java | DoublesSketch.putMemory | public void putMemory(final WritableMemory dstMem, final boolean compact) {
if (isDirect() && (isCompact() == compact)) {
final Memory srcMem = getMemory();
srcMem.copyTo(0, dstMem, 0, getStorageBytes());
} else {
final byte[] byteArr = toByteArray(compact);
final int arrLen = byteArr.le... | java | public void putMemory(final WritableMemory dstMem, final boolean compact) {
if (isDirect() && (isCompact() == compact)) {
final Memory srcMem = getMemory();
srcMem.copyTo(0, dstMem, 0, getStorageBytes());
} else {
final byte[] byteArr = toByteArray(compact);
final int arrLen = byteArr.le... | [
"public",
"void",
"putMemory",
"(",
"final",
"WritableMemory",
"dstMem",
",",
"final",
"boolean",
"compact",
")",
"{",
"if",
"(",
"isDirect",
"(",
")",
"&&",
"(",
"isCompact",
"(",
")",
"==",
"compact",
")",
")",
"{",
"final",
"Memory",
"srcMem",
"=",
... | Puts the current sketch into the given Memory if there is sufficient space, otherwise,
throws an error.
@param dstMem the given memory.
@param compact if true, compacts and sorts the base buffer, which optimizes merge
performance at the cost of slightly increased serialization time. | [
"Puts",
"the",
"current",
"sketch",
"into",
"the",
"given",
"Memory",
"if",
"there",
"is",
"sufficient",
"space",
"otherwise",
"throws",
"an",
"error",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/DoublesSketch.java#L693-L707 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/QuantilesHelper.java | QuantilesHelper.convertToPrecedingCummulative | public static long convertToPrecedingCummulative(final long[] array) {
long subtotal = 0;
for (int i = 0; i < array.length; i++) {
final long newSubtotal = subtotal + array[i];
array[i] = subtotal;
subtotal = newSubtotal;
}
return subtotal;
} | java | public static long convertToPrecedingCummulative(final long[] array) {
long subtotal = 0;
for (int i = 0; i < array.length; i++) {
final long newSubtotal = subtotal + array[i];
array[i] = subtotal;
subtotal = newSubtotal;
}
return subtotal;
} | [
"public",
"static",
"long",
"convertToPrecedingCummulative",
"(",
"final",
"long",
"[",
"]",
"array",
")",
"{",
"long",
"subtotal",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"f... | Convert the weights into totals of the weights preceding each item
@param array of weights
@return total weight | [
"Convert",
"the",
"weights",
"into",
"totals",
"of",
"the",
"weights",
"preceding",
"each",
"item"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/QuantilesHelper.java#L18-L26 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/QuantilesHelper.java | QuantilesHelper.chunkContainingPos | public static int chunkContainingPos(final long[] arr, final long pos) {
final int nominalLength = arr.length - 1; /* remember, arr contains an "extra" position */
assert nominalLength > 0;
final long n = arr[nominalLength];
assert 0 <= pos;
assert pos < n;
final int l = 0;
final int r = nom... | java | public static int chunkContainingPos(final long[] arr, final long pos) {
final int nominalLength = arr.length - 1; /* remember, arr contains an "extra" position */
assert nominalLength > 0;
final long n = arr[nominalLength];
assert 0 <= pos;
assert pos < n;
final int l = 0;
final int r = nom... | [
"public",
"static",
"int",
"chunkContainingPos",
"(",
"final",
"long",
"[",
"]",
"arr",
",",
"final",
"long",
"pos",
")",
"{",
"final",
"int",
"nominalLength",
"=",
"arr",
".",
"length",
"-",
"1",
";",
"/* remember, arr contains an \"extra\" position */",
"asser... | This is written in terms of a plain array to facilitate testing.
@param arr the chunk containing the position
@param pos the position
@return the index of the chunk containing the position | [
"This",
"is",
"written",
"in",
"terms",
"of",
"a",
"plain",
"array",
"to",
"facilitate",
"testing",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/QuantilesHelper.java#L46-L60 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/tuple/AnotB.java | AnotB.getResult | public CompactSketch<S> getResult() {
if (count_ == 0) {
return new CompactSketch<S>(null, null, theta_, isEmpty_);
}
final CompactSketch<S> result =
new CompactSketch<S>(Arrays.copyOfRange(keys_, 0, count_),
Arrays.copyOfRange(summaries_, 0, count_), theta_, isEmpty_);
reset()... | java | public CompactSketch<S> getResult() {
if (count_ == 0) {
return new CompactSketch<S>(null, null, theta_, isEmpty_);
}
final CompactSketch<S> result =
new CompactSketch<S>(Arrays.copyOfRange(keys_, 0, count_),
Arrays.copyOfRange(summaries_, 0, count_), theta_, isEmpty_);
reset()... | [
"public",
"CompactSketch",
"<",
"S",
">",
"getResult",
"(",
")",
"{",
"if",
"(",
"count_",
"==",
"0",
")",
"{",
"return",
"new",
"CompactSketch",
"<",
"S",
">",
"(",
"null",
",",
"null",
",",
"theta_",
",",
"isEmpty_",
")",
";",
"}",
"final",
"Comp... | Gets the result of this operation
@return the result of this operation as a CompactSketch | [
"Gets",
"the",
"result",
"of",
"this",
"operation"
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/tuple/AnotB.java#L74-L83 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/quantiles/ItemsUtil.java | ItemsUtil.validateValues | static final <T> void validateValues(final T[] values, final Comparator<? super T> comparator) {
final int lenM1 = values.length - 1;
for (int j = 0; j < lenM1; j++) {
if ((values[j] != null) && (values[j + 1] != null)
&& (comparator.compare(values[j], values[j + 1]) < 0)) {
continue;
... | java | static final <T> void validateValues(final T[] values, final Comparator<? super T> comparator) {
final int lenM1 = values.length - 1;
for (int j = 0; j < lenM1; j++) {
if ((values[j] != null) && (values[j + 1] != null)
&& (comparator.compare(values[j], values[j + 1]) < 0)) {
continue;
... | [
"static",
"final",
"<",
"T",
">",
"void",
"validateValues",
"(",
"final",
"T",
"[",
"]",
"values",
",",
"final",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comparator",
")",
"{",
"final",
"int",
"lenM1",
"=",
"values",
".",
"length",
"-",
"1",
";",
... | Checks the sequential validity of the given array of values.
They must be unique, monotonically increasing and not null.
@param <T> the data type
@param values given array of values
@param comparator the comparator for data type T | [
"Checks",
"the",
"sequential",
"validity",
"of",
"the",
"given",
"array",
"of",
"values",
".",
"They",
"must",
"be",
"unique",
"monotonically",
"increasing",
"and",
"not",
"null",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/quantiles/ItemsUtil.java#L49-L59 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/cpc/PairTable.java | PairTable.rebuild | PairTable rebuild(final int newLgSizeInts) {
checkLgSizeInts(newLgSizeInts);
final int newSize = 1 << newLgSizeInts;
final int oldSize = 1 << lgSizeInts;
rtAssert(newSize > numPairs);
final int[] oldSlotsArr = slotsArr;
slotsArr = new int[newSize];
Arrays.fill(slotsArr, -1);
lgSizeInts =... | java | PairTable rebuild(final int newLgSizeInts) {
checkLgSizeInts(newLgSizeInts);
final int newSize = 1 << newLgSizeInts;
final int oldSize = 1 << lgSizeInts;
rtAssert(newSize > numPairs);
final int[] oldSlotsArr = slotsArr;
slotsArr = new int[newSize];
Arrays.fill(slotsArr, -1);
lgSizeInts =... | [
"PairTable",
"rebuild",
"(",
"final",
"int",
"newLgSizeInts",
")",
"{",
"checkLgSizeInts",
"(",
"newLgSizeInts",
")",
";",
"final",
"int",
"newSize",
"=",
"1",
"<<",
"newLgSizeInts",
";",
"final",
"int",
"oldSize",
"=",
"1",
"<<",
"lgSizeInts",
";",
"rtAsser... | Rebuilds to a larger size. NumItems and validBits remain unchanged.
@param newLgSizeInts the new size
@return a larger PairTable | [
"Rebuilds",
"to",
"a",
"larger",
"size",
".",
"NumItems",
"and",
"validBits",
"remain",
"unchanged",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/cpc/PairTable.java#L99-L113 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/cpc/PairTable.java | PairTable.unwrappingGetItems | static int[] unwrappingGetItems(final PairTable table, final int numPairs) {
if (numPairs < 1) { return null; }
final int[] slotsArr = table.slotsArr;
final int tableSize = 1 << table.lgSizeInts;
final int[] result = new int[numPairs];
int i = 0;
int l = 0;
int r = numPairs - 1;
// Spec... | java | static int[] unwrappingGetItems(final PairTable table, final int numPairs) {
if (numPairs < 1) { return null; }
final int[] slotsArr = table.slotsArr;
final int tableSize = 1 << table.lgSizeInts;
final int[] result = new int[numPairs];
int i = 0;
int l = 0;
int r = numPairs - 1;
// Spec... | [
"static",
"int",
"[",
"]",
"unwrappingGetItems",
"(",
"final",
"PairTable",
"table",
",",
"final",
"int",
"numPairs",
")",
"{",
"if",
"(",
"numPairs",
"<",
"1",
")",
"{",
"return",
"null",
";",
"}",
"final",
"int",
"[",
"]",
"slotsArr",
"=",
"table",
... | While extracting the items from a linear probing hashtable,
this will usually undo the wrap-around provided that the table
isn't too full. Experiments suggest that for sufficiently large tables
the load factor would have to be over 90 percent before this would fail frequently,
and even then the subsequent sort would fi... | [
"While",
"extracting",
"the",
"items",
"from",
"a",
"linear",
"probing",
"hashtable",
"this",
"will",
"usually",
"undo",
"the",
"wrap",
"-",
"around",
"provided",
"that",
"the",
"table",
"isn",
"t",
"too",
"full",
".",
"Experiments",
"suggest",
"that",
"for"... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/cpc/PairTable.java#L222-L246 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/cpc/PairTable.java | PairTable.introspectiveInsertionSort | static void introspectiveInsertionSort(final int[] a, final int l, final int r) {
final int length = (r - l) + 1;
long cost = 0;
final long costLimit = 8L * length;
for (int i = l + 1; i <= r; i++) {
int j = i;
final long v = a[i] & 0XFFFF_FFFFL; //v must be long
while ((j >= (l + 1)) ... | java | static void introspectiveInsertionSort(final int[] a, final int l, final int r) {
final int length = (r - l) + 1;
long cost = 0;
final long costLimit = 8L * length;
for (int i = l + 1; i <= r; i++) {
int j = i;
final long v = a[i] & 0XFFFF_FFFFL; //v must be long
while ((j >= (l + 1)) ... | [
"static",
"void",
"introspectiveInsertionSort",
"(",
"final",
"int",
"[",
"]",
"a",
",",
"final",
"int",
"l",
",",
"final",
"int",
"r",
")",
"{",
"final",
"int",
"length",
"=",
"(",
"r",
"-",
"l",
")",
"+",
"1",
";",
"long",
"cost",
"=",
"0",
";"... | In applications where the input array is already nearly sorted,
insertion sort runs in linear time with a very small constant.
This introspective version of insertion sort protects against
the quadratic cost of sorting bad input arrays.
It keeps track of how much work has been done, and if that exceeds a
constant times... | [
"In",
"applications",
"where",
"the",
"input",
"array",
"is",
"already",
"nearly",
"sorted",
"insertion",
"sort",
"runs",
"in",
"linear",
"time",
"with",
"a",
"very",
"small",
"constant",
".",
"This",
"introspective",
"version",
"of",
"insertion",
"sort",
"pro... | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/cpc/PairTable.java#L259-L298 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hllmap/UniqueCountMap.java | UniqueCountMap.update | public double update(final byte[] key, final byte[] identifier) {
if (key == null) { return Double.NaN; }
checkMethodKeySize(key);
if (identifier == null) { return getEstimate(key); }
final short coupon = (short) Map.coupon16(identifier);
final int baseMapIndex = maps_[0].findOrInsertKey(key);
... | java | public double update(final byte[] key, final byte[] identifier) {
if (key == null) { return Double.NaN; }
checkMethodKeySize(key);
if (identifier == null) { return getEstimate(key); }
final short coupon = (short) Map.coupon16(identifier);
final int baseMapIndex = maps_[0].findOrInsertKey(key);
... | [
"public",
"double",
"update",
"(",
"final",
"byte",
"[",
"]",
"key",
",",
"final",
"byte",
"[",
"]",
"identifier",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
"Double",
".",
"NaN",
";",
"}",
"checkMethodKeySize",
"(",
"key",
")",
... | Updates the map with a given key and identifier and returns the estimate of the number of
unique identifiers encountered so far for the given key.
@param key the given key
@param identifier the given identifier for unique counting associated with the key
@return the estimate of the number of unique identifiers encounte... | [
"Updates",
"the",
"map",
"with",
"a",
"given",
"key",
"and",
"identifier",
"and",
"returns",
"the",
"estimate",
"of",
"the",
"number",
"of",
"unique",
"identifiers",
"encountered",
"so",
"far",
"for",
"the",
"given",
"key",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hllmap/UniqueCountMap.java#L111-L130 | train |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hllmap/UniqueCountMap.java | UniqueCountMap.getEstimate | public double getEstimate(final byte[] key) {
if (key == null) { return Double.NaN; }
checkMethodKeySize(key);
final double est = maps_[0].getEstimate(key);
if (est >= 0.0) { return est; }
//key has been promoted
final int level = -(int)est;
final Map map = maps_[level];
return map.getEs... | java | public double getEstimate(final byte[] key) {
if (key == null) { return Double.NaN; }
checkMethodKeySize(key);
final double est = maps_[0].getEstimate(key);
if (est >= 0.0) { return est; }
//key has been promoted
final int level = -(int)est;
final Map map = maps_[level];
return map.getEs... | [
"public",
"double",
"getEstimate",
"(",
"final",
"byte",
"[",
"]",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
"Double",
".",
"NaN",
";",
"}",
"checkMethodKeySize",
"(",
"key",
")",
";",
"final",
"double",
"est",
"=",
"maps_"... | Retrieves the current estimate of unique count for a given key.
@param key given key
@return estimate of unique count so far | [
"Retrieves",
"the",
"current",
"estimate",
"of",
"unique",
"count",
"for",
"a",
"given",
"key",
"."
] | 900c8c9668a1e2f1d54d453e956caad54702e540 | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hllmap/UniqueCountMap.java#L137-L146 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.