org.apache.datasketches.tuple.arrayofdoubles

## Class ArrayOfDoublesSketch

- java.lang.Object
- - org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketch

Direct Known Subclasses:
  ArrayOfDoublesCompactSketch, ArrayOfDoublesUpdatableSketch

    public abstract class ArrayOfDoublesSketch
    extends Object

The base class for the tuple sketch of type ArrayOfDoubles, where an array of double values is associated with each key. A primitive array of doubles is used here, as opposed to a generic Summary object, for improved performance.

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`ArrayOfDoublesCompactSketch` `compact()`
`abstract ArrayOfDoublesCompactSketch` `compact(org.apache.datasketches.memory.WritableMemory dstMem)`
`abstract int` `getCurrentBytes()` For compact sketches this is the same as getMaxBytes().
`double` `getEstimate()` Estimates the cardinality of the set (number of unique values presented to the sketch)
`double` `getLowerBound(int numStdDev)` Gets the approximate lower error bound given the specified number of Standard Deviations.
`abstract int` `getMaxBytes()`
`int` `getNumValues()`
`abstract int` `getRetainedEntries()`
`double` `getTheta()` Gets the value of theta as a double between zero and one
`double` `getUpperBound(int numStdDev)` Gets the approximate upper error bound given the specified number of Standard Deviations.
`abstract double[][]` `getValues()`
`abstract boolean` `hasMemory()` Returns true if this sketch's data structure is backed by Memory or WritableMemory.
`static ArrayOfDoublesSketch` `heapify(org.apache.datasketches.memory.Memory mem)` Heapify the given Memory as an ArrayOfDoublesSketch
`static ArrayOfDoublesSketch` `heapify(org.apache.datasketches.memory.Memory mem, long seed)` Heapify the given Memory and seed as a ArrayOfDoublesSketch
`boolean` `isEmpty()` See Empty
`boolean` `isEstimationMode()` Returns true if the sketch is Estimation Mode (as opposed to Exact Mode).
`abstract ArrayOfDoublesSketchIterator` `iterator()`
`abstract byte[]` `toByteArray()`
`String` `toString()`
`static ArrayOfDoublesSketch` `wrap(org.apache.datasketches.memory.Memory mem)` Wrap the given Memory as an ArrayOfDoublesSketch
`static ArrayOfDoublesSketch` `wrap(org.apache.datasketches.memory.Memory mem, long seed)` Wrap the given Memory and seed as a ArrayOfDoublesSketch

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

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

### Method Detail

#### heapify

    public static ArrayOfDoublesSketch heapify(org.apache.datasketches.memory.Memory mem)

Heapify the given Memory as an ArrayOfDoublesSketch

Parameters:
  `mem` - the given Memory
Returns:
  an ArrayOfDoublesSketch

#### heapify

    public static ArrayOfDoublesSketch heapify(org.apache.datasketches.memory.Memory mem,
                                               long seed)

Heapify the given Memory and seed as a ArrayOfDoublesSketch

Parameters:
  `mem` - the given Memory
  `seed` - the given seed
Returns:
  an ArrayOfDoublesSketch

#### wrap

    public static ArrayOfDoublesSketch wrap(org.apache.datasketches.memory.Memory mem)

Wrap the given Memory as an ArrayOfDoublesSketch

Parameters:
  `mem` - the given Memory
Returns:
  an ArrayOfDoublesSketch

#### wrap

    public static ArrayOfDoublesSketch wrap(org.apache.datasketches.memory.Memory mem,
                                            long seed)

Wrap the given Memory and seed as a ArrayOfDoublesSketch

Parameters:
  `mem` - the given Memory
  `seed` - the given seed
Returns:
  an ArrayOfDoublesSketch

#### getEstimate

    public double getEstimate()

Estimates the cardinality of the set (number of unique values presented to the sketch)

Returns:
  best estimate of the number of unique values

#### getUpperBound

    public double getUpperBound(int numStdDev)

Gets the approximate upper error bound given the specified number of Standard Deviations. This will return getEstimate() if isEmpty() is true.

Parameters:
  `numStdDev` - See Number of Standard Deviations
Returns:
  the upper bound.

#### getLowerBound

    public double getLowerBound(int numStdDev)

Gets the approximate lower error bound given the specified number of Standard Deviations. This will return getEstimate() if isEmpty() is true.

Parameters:
  `numStdDev` - See Number of Standard Deviations
Returns:
  the lower bound.

#### hasMemory

    public abstract boolean hasMemory()

Returns true if this sketch's data structure is backed by Memory or WritableMemory.

Returns:
  true if this sketch's data structure is backed by Memory or WritableMemory.

#### isEmpty

    public boolean isEmpty()

See Empty

Returns:
  true if empty.

#### getNumValues

    public int getNumValues()

Returns:
  number of double values associated with each key

#### isEstimationMode

    public boolean isEstimationMode()

Returns true if the sketch is Estimation Mode (as opposed to Exact Mode). This is true if theta < 1.0 AND isEmpty() is false.

Returns:
  true if the sketch is in estimation mode.

#### getTheta

    public double getTheta()

Gets the value of theta as a double between zero and one

Returns:
  the value of theta as a double

#### getRetainedEntries

    public abstract int getRetainedEntries()

Returns:
  number of retained entries

#### getMaxBytes

    public abstract int getMaxBytes()

Returns:
  the maximum number of bytes for this sketch when serialized.

#### getCurrentBytes

    public abstract int getCurrentBytes()

For compact sketches this is the same as getMaxBytes().

Returns:
  the current number of bytes for this sketch when serialized.

#### toByteArray

    public abstract byte[] toByteArray()

Returns:
  serialized representation of the sketch

#### getValues

    public abstract double[][] getValues()

Returns:
  array of arrays of double values in the sketch

#### iterator

    public abstract ArrayOfDoublesSketchIterator iterator()

Returns:
  iterator over the sketch

#### compact

    public ArrayOfDoublesCompactSketch compact()

Returns:
  this sketch in compact form, which is immutable.

#### compact

    public abstract ArrayOfDoublesCompactSketch compact(org.apache.datasketches.memory.WritableMemory dstMem)

Parameters:
  `dstMem` - the destination WritableMemory
Returns:
  this sketch in compact form, which is immutable.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`