org.apache.datasketches.tuple.adouble

## Class DoubleSketch

- java.lang.Object
- - org.apache.datasketches.tuple.Sketch<S>
  - - org.apache.datasketches.tuple.UpdatableSketch<Double,DoubleSummary>
    - - org.apache.datasketches.tuple.adouble.DoubleSketch

    public class DoubleSketch
    extends UpdatableSketch<Double,DoubleSummary>

Author:
  Lee Rhodes

### Field Summary

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

`PREAMBLE_LONGS, summaryFactory_`

### Constructor Summary

Constructors
Constructor and Description
`DoubleSketch(int lgK, DoubleSummary.Mode mode)` Constructs this sketch with given lgK.
`DoubleSketch(int lgK, int lgResizeFactor, float samplingProbability, DoubleSummary.Mode mode)` Creates this sketch with the following parameters:
`DoubleSketch(org.apache.datasketches.memory.Memory mem, DoubleSummary.Mode mode)` Deprecated. As of 3.0.0, heapifying an UpdatableSketch is deprecated. This capability will be removed in a future release. Heapifying a CompactSketch is not deprecated.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`CompactSketch<S>` `compact()` Converts the current state of the sketch into a compact sketch
`int` `getCountLessThanThetaLong(long thetaLong)` Gets the number of hash values less than the given theta expressed as a long.
`int` `getCurrentCapacity()` Get current capacity
`int` `getLgK()` Get log_base2 of Nominal Entries
`int` `getNominalEntries()` Get configured nominal number of entries
`ResizeFactor` `getResizeFactor()` Get configured resize factor
`int` `getRetainedEntries()`
`float` `getSamplingProbability()` Get configured sampling probability
`protected void` `insertSummary(int index, S summary)`
`TupleSketchIterator<S>` `iterator()` Returns a SketchIterator
`void` `reset()` Resets this sketch an empty state.
`byte[]` `toByteArray()` Deprecated. 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.
`void` `trim()` Rebuilds reducing the actual number of entries to the nominal number of entries if needed
`void` `update(long key, Double value)` Updates this sketch with a long key and U value.
`void` `update(String key, Double value)` Updates this sketch with a String key and U value.

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

`copy, update, update, update, update, update`

### 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

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

### Constructor Detail

#### DoubleSketch

    public DoubleSketch(int lgK,
                        DoubleSummary.Mode mode)

Constructs this sketch with given lgK.

Parameters:
  `lgK` - Log_base2 of Nominal Entries. See Nominal Entries
  `mode` - The DoubleSummary mode to be used

#### DoubleSketch

    public DoubleSketch(int lgK,
                        int lgResizeFactor,
                        float samplingProbability,
                        DoubleSummary.Mode mode)

Creates this sketch with the following parameters:

Parameters:
  `lgK` - Log_base2 of Nominal Entries.
  `lgResizeFactor` - log2(resizeFactor) - value from 0 to 3:

       0 - no resizing (max size allocated),
       1 - double internal hash table each time it reaches a threshold
       2 - grow four times
       3 - grow eight times (default)

  `samplingProbability` - See Sampling Probability
  `mode` - The DoubleSummary mode to be used

#### DoubleSketch

    @Deprecated
    public DoubleSketch(org.apache.datasketches.memory.Memory mem,
                                    DoubleSummary.Mode mode)

Deprecated. As of 3.0.0, heapifying an UpdatableSketch is deprecated. This capability will be removed in a future release. Heapifying a CompactSketch is not deprecated.
Constructs this sketch from a Memory image, which must be from an DoubleSketch, and usually with data.

Parameters:
  `mem` - the given Memory
  `mode` - The DoubleSummary mode to be used

### Method Detail

#### update

    public void update(String key,
                       Double value)

Description copied from class: `UpdatableSketch`
Updates this sketch with a String key and U value. The value is passed to update() method of the Summary object associated with the key

Overrides:
  `update` in class `UpdatableSketch<Double,DoubleSummary>`
Parameters:
  `key` - The given String key
  `value` - The given U value

#### update

    public void update(long key,
                       Double value)

Description copied from class: `UpdatableSketch`
Updates this sketch with a long key and U value. The value is passed to update() method of the Summary object associated with the key

Overrides:
  `update` in class `UpdatableSketch<Double,DoubleSummary>`
Parameters:
  `key` - The given long key
  `value` - The given U value

#### 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.

#### getNominalEntries

    public int getNominalEntries()

Get configured nominal number of entries

Returns:
  nominal number of entries

#### getLgK

    public int getLgK()

Get log_base2 of Nominal Entries

Returns:
  log_base2 of Nominal Entries

#### getSamplingProbability

    public float getSamplingProbability()

Get configured sampling probability

Returns:
  sampling probability

#### getCurrentCapacity

    public int getCurrentCapacity()

Get current capacity

Returns:
  current capacity

#### getResizeFactor

    public ResizeFactor getResizeFactor()

Get configured resize factor

Returns:
  resize factor

#### trim

    public void trim()

Rebuilds reducing the actual number of entries to the nominal number of entries if needed

#### reset

    public void reset()

Resets this sketch an empty state.

#### compact

    public CompactSketch<S> compact()

Converts the current state of the sketch into a compact sketch

Specified by:
  `compact` in class `Sketch<S extends Summary>`
Returns:
  compact sketch

#### toByteArray

    @Deprecated
    public byte[] toByteArray()

Deprecated. 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.
This serializes an UpdatableSketch (QuickSelectSketch).

Specified by:
  `toByteArray` in class `Sketch<S extends Summary>`
Returns:
  serialized representation of an UpdatableSketch (QuickSelectSketch).

#### insertSummary

    protected void insertSummary(int index,
                                 S summary)

#### 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