/** * Updates the internal set by adding entries from the given sketch * @param sketchIn input sketch to add to the internal set */ 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_); } }
while (it.next()) { final S summary = it.getSummary().copy(); sketch_.insert(it.getKey(), summary); final SketchIterator<S> it = sketchIn.iterator(); while (it.next()) { final S summary = sketch_.find(it.getKey()); if (summary != null) { matchKeys[matchCount] = it.getKey(); if (matchSummaries == null) { matchSummaries = (S[]) Array.newInstance(summary.getClass(), matchSize);
/** * Filters elements on the provided {@link Sketch} * * @param sketchIn The sketch against which apply the {@link Predicate} * @return A new Sketch with some of the entries filtered out based on the {@link Predicate} */ public CompactSketch<T> filter(final Sketch<T> sketchIn) { if (sketchIn == null) { return new CompactSketch<>(null, null, Long.MAX_VALUE, true); } final QuickSelectSketch<T> sketch = new QuickSelectSketch<>(sketchIn.getRetainedEntries(), ResizeFactor.X1.lg(), null); final SketchIterator<T> it = sketchIn.iterator(); while (it.next()) { final T summary = it.getSummary(); if (predicate.test(summary)) { sketch.insert(it.getKey(), summary.copy()); } } sketch.setThetaLong(sketchIn.getThetaLong()); if (!sketchIn.isEmpty()) { sketch.setNotEmpty(); } return sketch.compact(); } }
/** * Updates the internal set by adding entries from the given sketch * @param sketchIn input sketch to add to the internal set */ 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_); } }
while (it.next()) { final S summary = it.getSummary().copy(); sketch_.insert(it.getKey(), summary); final SketchIterator<S> it = sketchIn.iterator(); while (it.next()) { final S summary = sketch_.find(it.getKey()); if (summary != null) { matchKeys[matchCount] = it.getKey(); if (matchSummaries == null) { matchSummaries = (S[]) Array.newInstance(summary.getClass(), matchSize);
/** * Filters elements on the provided {@link Sketch} * * @param sketchIn The sketch against which apply the {@link Predicate} * @return A new Sketch with some of the entries filtered out based on the {@link Predicate} */ public CompactSketch<T> filter(final Sketch<T> sketchIn) { if (sketchIn == null) { return new CompactSketch<>(null, null, Long.MAX_VALUE, true); } final QuickSelectSketch<T> sketch = new QuickSelectSketch<>(sketchIn.getRetainedEntries(), ResizeFactor.X1.lg(), null); final SketchIterator<T> it = sketchIn.iterator(); while (it.next()) { final T summary = it.getSummary(); if (predicate.test(summary)) { sketch.insert(it.getKey(), summary.copy()); } } sketch.setThetaLong(sketchIn.getThetaLong()); if (!sketchIn.isEmpty()) { sketch.setNotEmpty(); } return sketch.compact(); } }