Skip to content

Commit

Permalink
Merge pull request #646 from apache/compressed_iterator
Browse files Browse the repository at this point in the history
code cleanup
  • Loading branch information
AlexanderSaydakov authored Feb 3, 2025
2 parents 5753fbd + a0b86ee commit 2dd1d5e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ private static CompactSketch wrap(final Memory srcMem, final long seed, final bo
final short seedHash = ThetaUtil.computeSeedHash(seed);

if (serVer == 4) {
// not wrapping the compressed format since currently we cannot take advantage of
// decompression during iteration because set operations reach into memory directly
return DirectCompactCompressedSketch.wrapInstance(srcMem,
enforceSeed ? seedHash : (short) extractSeedHash(srcMem));
}
Expand Down Expand Up @@ -251,6 +249,11 @@ public boolean isCompact() {
return true;
}

@Override
public double getEstimate() {
return Sketch.estimate(getThetaLong(), getRetainedEntries());
}

/**
* gets the sketch as a compressed byte array
* @return the sketch as a compressed byte array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public boolean isOrdered() {
public HashIterator iterator() {
return new MemoryCompactCompressedHashIterator(
mem_,
(extractPreLongs(mem_) > 1 ? 16 : 8) + extractNumEntriesBytesV4(mem_),
(extractPreLongs(mem_) > 1 ? START_PACKED_DATA_ESTIMATION_MODE : START_PACKED_DATA_EXACT_MODE)
+ extractNumEntriesBytesV4(mem_),
extractEntryBitsV4(mem_),
getRetainedEntries()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ public int getCurrentBytes() {
return (preLongs + curCount) << 3;
}

@Override
public double getEstimate() {
return Sketch.estimate(getThetaLong(), getRetainedEntries());
}

@Override
public int getRetainedEntries(final boolean valid) { //compact is always valid
if (otherCheckForSingleItem(mem_)) { return 1; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ public int getCurrentBytes() {
return (preLongs_ + curCount_) << 3;
}

@Override
public double getEstimate() {
return Sketch.estimate(thetaLong_, curCount_);
}

@Override
public int getRetainedEntries(final boolean valid) {
return curCount_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

import org.apache.datasketches.memory.Memory;

/**
* @author Lee Rhodes
/*
* This is to uncompress serial version 4 sketch incrementally
*/
class MemoryCompactCompressedHashIterator implements HashIterator {
private Memory mem;
Expand Down

0 comments on commit 2dd1d5e

Please sign in to comment.