Package org.apache.datasketches.tuple

# Class CompactSketch<S extends Summary>

java.lang.Object
org.apache.datasketches.tuple.Sketch<S>
org.apache.datasketches.tuple.CompactSketch<S>

Type Parameters:
  `S` - type of Summary

public final class CompactSketch<S extends Summary> extends Sketch<S>
CompactSketches are never created directly. They are created as a result of the compact() method of an UpdatableSketch or as a result of the getResult() method of a set operation like Union, Intersection or AnotB. CompactSketch consists of a compact list (i.e. no intervening spaces) of hash values, corresponding list of Summaries, and a value for theta. The lists may or may not be ordered. CompactSketch is read-only.

## Method Summary

Modifier and Type
Method
Description
`CompactSketch<S>`
`compact()`
Converts this sketch to a CompactSketch on the Java heap.
`int`
`getCountLessThanThetaLong(long thetaLong)`
Gets the number of hash values less than the given theta expressed as a long.
`int`
`getRetainedEntries()`
`TupleSketchIterator<S>`
`iterator()`
Returns a SketchIterator
`byte[]`
`toByteArray()`
This is to serialize a sketch instance to a byte array.

### Methods inherited from class org.apache.datasketches.tuple.Sketch

`getEstimate, getEstimate, getLowerBound, getLowerBound, getSummaryFactory, getTheta, getThetaLong, getUpperBound, getUpperBound, isEmpty, isEstimationMode, toString`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Method Details

### compact

public CompactSketch<S> compact()
Description copied from class: `Sketch`
Converts this sketch to a CompactSketch on the Java heap.

If this sketch is already in compact form this operation returns this.

Specified by:
  `compact` in class `Sketch<S extends Summary>`
Returns:
  this sketch as a CompactSketch on the Java heap.

### getRetainedEntries

public int getRetainedEntries()

Specified by:
  `getRetainedEntries` in class `Sketch<S extends Summary>`
Returns:
  number of retained entries

### getCountLessThanThetaLong

public int getCountLessThanThetaLong(long thetaLong)
Description copied from class: `Sketch`
Gets the number of hash values less than the given theta expressed as a long.

Specified by:
  `getCountLessThanThetaLong` in class `Sketch<S extends Summary>`
Parameters:
  `thetaLong` - the given theta as a long between zero and Long.MAX_VALUE.
Returns:
  the number of hash values less than the given thetaLong.

### toByteArray

public byte[] toByteArray()
Description copied from class: `Sketch`
This is to serialize a sketch instance to a byte array.

As of 3.0.0, serializing an UpdatableSketch is deprecated. This capability will be removed in a future release. Serializing a CompactSketch is not deprecated.

Specified by:
  `toByteArray` in class `Sketch<S extends Summary>`
Returns:
  serialized representation of the sketch

### iterator

public TupleSketchIterator<S> iterator()
Description copied from class: `Sketch`
Returns a SketchIterator

Specified by:
  `iterator` in class `Sketch<S extends Summary>`
Returns:
  a SketchIterator