/** * Returns the resulting union in the form of a compact sketch * @param dstMem memory for the result (can be null) * @return compact sketch representing the union (off-heap if memory is provided) */ public ArrayOfDoublesCompactSketch getResult(final WritableMemory dstMem) { if (sketch_.getRetainedEntries() > sketch_.getNominalEntries()) { theta_ = Math.min(theta_, sketch_.getNewTheta()); } if (dstMem == null) { return new HeapArrayOfDoublesCompactSketch(sketch_, theta_); } return new DirectArrayOfDoublesCompactSketch(sketch_, theta_, dstMem); }
void setRebuildThreshold() { if (getCurrentCapacity() > getNominalEntries()) { rebuildThreshold_ = (int) (getCurrentCapacity() * REBUILD_THRESHOLD); } else { rebuildThreshold_ = (int) (getCurrentCapacity() * RESIZE_THRESHOLD); } }
@Override public void trim() { if (getRetainedEntries() > getNominalEntries()) { setThetaLong(getNewTheta()); rebuild(); } }
ArrayOfDoublesUnion(final ArrayOfDoublesQuickSelectSketch sketch) { nomEntries_ = sketch.getNominalEntries(); numValues_ = sketch.getNumValues(); seed_ = sketch.getSeed(); seedHash_ = Util.computeSeedHash(seed_); sketch_ = sketch; theta_ = sketch.getThetaLong(); }
long getNewTheta() { final long[] keys = new long[getRetainedEntries()]; int i = 0; for (int j = 0; j < getCurrentCapacity(); j++) { final long key = getKey(j); if (key != 0) { keys[i++] = key; } } return QuickSelect.select(keys, 0, getRetainedEntries() - 1, getNominalEntries()); }
void rebuildIfNeeded() { if (getRetainedEntries() < rebuildThreshold_) { return; } if (getCurrentCapacity() > getNominalEntries()) { setThetaLong(getNewTheta()); rebuild(); } else { rebuild(getCurrentCapacity() * getResizeFactor().getValue()); } }
void setRebuildThreshold() { if (getCurrentCapacity() > getNominalEntries()) { rebuildThreshold_ = (int) (getCurrentCapacity() * REBUILD_THRESHOLD); } else { rebuildThreshold_ = (int) (getCurrentCapacity() * RESIZE_THRESHOLD); } }
/** * Returns the resulting union in the form of a compact sketch * @param dstMem memory for the result (can be null) * @return compact sketch representing the union (off-heap if memory is provided) */ public ArrayOfDoublesCompactSketch getResult(final WritableMemory dstMem) { if (sketch_.getRetainedEntries() > sketch_.getNominalEntries()) { theta_ = Math.min(theta_, sketch_.getNewTheta()); } if (dstMem == null) { return new HeapArrayOfDoublesCompactSketch(sketch_, theta_); } return new DirectArrayOfDoublesCompactSketch(sketch_, theta_, dstMem); }
ArrayOfDoublesUnion(final ArrayOfDoublesQuickSelectSketch sketch) { nomEntries_ = sketch.getNominalEntries(); numValues_ = sketch.getNumValues(); seed_ = sketch.getSeed(); seedHash_ = Util.computeSeedHash(seed_); sketch_ = sketch; theta_ = sketch.getThetaLong(); }
@Override public void trim() { if (getRetainedEntries() > getNominalEntries()) { setThetaLong(getNewTheta()); rebuild(); } }
long getNewTheta() { final long[] keys = new long[getRetainedEntries()]; int i = 0; for (int j = 0; j < getCurrentCapacity(); j++) { final long key = getKey(j); if (key != 0) { keys[i++] = key; } } return QuickSelect.select(keys, 0, getRetainedEntries() - 1, getNominalEntries()); }
void rebuildIfNeeded() { if (getRetainedEntries() < rebuildThreshold_) { return; } if (getCurrentCapacity() > getNominalEntries()) { setThetaLong(getNewTheta()); rebuild(); } else { rebuild(getCurrentCapacity() * getResizeFactor().getValue()); } }