MCPcopy Index your code
hub / github.com/aggregateknowledge/java-hll / addRaw

Method addRaw

src/main/java/net/agkn/hll/HLL.java:327–383  ·  view source on GitHub ↗

Adds rawValue directly to the HLL. @param rawValue the value to be added. It is very important that this value already be hashed with a strong (but not necessarily cryptographic) hash function. For instance, the Murmur3 implementation in <a hre

(final long rawValue)

Source from the content-addressed store, hash-verified

325 * of the hash provided in the PostgreSQL implementation.
326 */
327 public void addRaw(final long rawValue) {
328 switch(type) {
329 case EMPTY: {
330 // NOTE: EMPTY type is always promoted on #addRaw()
331 if(explicitThreshold > 0) {
332 initializeStorage(HLLType.EXPLICIT);
333 explicitStorage.add(rawValue);
334 } else if(!sparseOff) {
335 initializeStorage(HLLType.SPARSE);
336 addRawSparseProbabilistic(rawValue);
337 } else {
338 initializeStorage(HLLType.FULL);
339 addRawProbabilistic(rawValue);
340 }
341 return;
342 }
343 case EXPLICIT: {
344 explicitStorage.add(rawValue);
345
346 // promotion, if necessary
347 if(explicitStorage.size() > explicitThreshold) {
348 if(!sparseOff) {
349 initializeStorage(HLLType.SPARSE);
350 for(final long value : explicitStorage) {
351 addRawSparseProbabilistic(value);
352 }
353 } else {
354 initializeStorage(HLLType.FULL);
355 for(final long value : explicitStorage) {
356 addRawProbabilistic(value);
357 }
358 }
359 explicitStorage = null;
360 }
361 return;
362 }
363 case SPARSE: {
364 addRawSparseProbabilistic(rawValue);
365
366 // promotion, if necessary
367 if(sparseProbabilisticStorage.size() > sparseThreshold) {
368 initializeStorage(HLLType.FULL);
369 for(final int registerIndex : sparseProbabilisticStorage.keySet()) {
370 final byte registerValue = sparseProbabilisticStorage.get(registerIndex);
371 probabilisticStorage.setMaxRegister(registerIndex, registerValue);
372 }
373 sparseProbabilisticStorage = null;
374 }
375 return;
376 }
377 case FULL:
378 addRawProbabilistic(rawValue);
379 return;
380 default:
381 throw new RuntimeException("Unsupported HLL type " + type);
382 }
383 }
384

Callers 15

addTestMethod · 0.95
smallRangeSmokeTestMethod · 0.95
normalRangeSmokeTestMethod · 0.95
largeRangeSmokeTestMethod · 0.95
unionTestMethod · 0.95
clearTestMethod · 0.95
toFromBytesTestMethod · 0.95
randomValuesTestMethod · 0.95
smallRangeSmokeTestMethod · 0.95
normalRangeSmokeTestMethod · 0.95
largeRangeSmokeTestMethod · 0.95
registerValueTestMethod · 0.95

Calls 4

initializeStorageMethod · 0.95
addRawProbabilisticMethod · 0.95
setMaxRegisterMethod · 0.80

Tested by 15

addTestMethod · 0.76
smallRangeSmokeTestMethod · 0.76
normalRangeSmokeTestMethod · 0.76
largeRangeSmokeTestMethod · 0.76
unionTestMethod · 0.76
clearTestMethod · 0.76
toFromBytesTestMethod · 0.76
randomValuesTestMethod · 0.76
smallRangeSmokeTestMethod · 0.76
normalRangeSmokeTestMethod · 0.76
largeRangeSmokeTestMethod · 0.76
registerValueTestMethod · 0.76