org.apache.datasketches.theta

## Class SetOperation

- java.lang.Object
- - org.apache.datasketches.theta.SetOperation

All Implemented Interfaces:
  MemoryStatus

Direct Known Subclasses:
  AnotB, Intersection, Union

    public abstract class SetOperation
    extends Object
    implements MemoryStatus

The parent API for all Set Operations

Author:
  Lee Rhodes

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`static SetOperationBuilder` `builder()` Makes a new builder
`abstract Family` `getFamily()` Gets the Family of this SetOperation
`static int` `getMaxAnotBResultBytes(int nomEntries)` Returns the maximum number of bytes for the returned CompactSketch, given the value of nomEntries of the first sketch A of AnotB.
`static int` `getMaxIntersectionBytes(int nomEntries)` Returns the maximum required storage bytes given a nomEntries parameter for Intersection operations
`static int` `getMaxUnionBytes(int nomEntries)` Returns the maximum required storage bytes given a nomEntries parameter for Union operations
`static SetOperation` `heapify(org.apache.datasketches.memory.Memory srcMem)` Heapify takes the SetOperations image in Memory and instantiates an on-heap SetOperation using the Default Update Seed.
`static SetOperation` `heapify(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)` Heapify takes the SetOperation image in Memory and instantiates an on-heap SetOperation using the given expectedSeed.
`static SetOperation` `wrap(org.apache.datasketches.memory.Memory srcMem)` Wrap takes the SetOperation image in Memory and refers to it directly.
`static SetOperation` `wrap(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)` Wrap takes the SetOperation image in Memory and refers to it directly.
`static SetOperation` `wrap(org.apache.datasketches.memory.WritableMemory srcMem)` Wrap takes the SetOperation image in Memory and refers to it directly.
`static SetOperation` `wrap(org.apache.datasketches.memory.WritableMemory srcMem, long expectedSeed)` Wrap takes the SetOperation image in Memory and refers to it directly.

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

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

### Methods inherited from interface org.apache.datasketches.common.MemoryStatus

`hasMemory, isDirect, isSameResource`

### Method Detail

#### builder

    public static final SetOperationBuilder builder()

Makes a new builder

Returns:
  a new builder

#### heapify

    public static SetOperation heapify(org.apache.datasketches.memory.Memory srcMem)

Heapify takes the SetOperations image in Memory and instantiates an on-heap SetOperation using the Default Update Seed. The resulting SetOperation will not retain any link to the source Memory.

Note: Only certain set operators during stateful operations can be serialized and thus heapified.

Parameters:
  `srcMem` - an image of a SetOperation where the image seed hash matches the default seed hash. See Memory
Returns:
  a Heap-based SetOperation from the given Memory

#### heapify

    public static SetOperation heapify(org.apache.datasketches.memory.Memory srcMem,
                                       long expectedSeed)

Heapify takes the SetOperation image in Memory and instantiates an on-heap SetOperation using the given expectedSeed. The resulting SetOperation will not retain any link to the source Memory.

Note: Only certain set operators during stateful operations can be serialized and thus heapified.

Parameters:
  `srcMem` - an image of a SetOperation where the hash of the given expectedSeed matches the image seed hash. See Memory
  `expectedSeed` - the seed used to validate the given Memory image. See Update Hash Seed.
Returns:
  a Heap-based SetOperation from the given Memory

#### wrap

    public static SetOperation wrap(org.apache.datasketches.memory.Memory srcMem)

Wrap takes the SetOperation image in Memory and refers to it directly. There is no data copying onto the java heap. This method assumes the Default Update Seed.

Note: Only certain set operators during stateful operations can be serialized and thus wrapped.

Parameters:
  `srcMem` - an image of a SetOperation where the image seed hash matches the default seed hash. See Memory
Returns:
  a SetOperation backed by the given Memory

#### wrap

    public static SetOperation wrap(org.apache.datasketches.memory.Memory srcMem,
                                    long expectedSeed)

Wrap takes the SetOperation image in Memory and refers to it directly. There is no data copying onto the java heap.

Note: Only certain set operators during stateful operations can be serialized and thus wrapped.

Parameters:
  `srcMem` - an image of a SetOperation where the hash of the given expectedSeed matches the image seed hash. See Memory
  `expectedSeed` - the seed used to validate the given Memory image. See Update Hash Seed.
Returns:
  a SetOperation backed by the given Memory

#### wrap

    public static SetOperation wrap(org.apache.datasketches.memory.WritableMemory srcMem)

Wrap takes the SetOperation image in Memory and refers to it directly. There is no data copying onto the java heap. This method assumes the Default Update Seed.

Note: Only certain set operators during stateful operations can be serialized and thus wrapped.

Parameters:
  `srcMem` - an image of a SetOperation where the image seed hash matches the default seed hash. See Memory
Returns:
  a SetOperation backed by the given Memory

#### wrap

    public static SetOperation wrap(org.apache.datasketches.memory.WritableMemory srcMem,
                                    long expectedSeed)

Wrap takes the SetOperation image in Memory and refers to it directly. There is no data copying onto the java heap.

Note: Only certain set operators during stateful operations can be serialized and thus wrapped.

Parameters:
  `srcMem` - an image of a SetOperation where the hash of the given expectedSeed matches the image seed hash. See Memory
  `expectedSeed` - the seed used to validate the given Memory image. See Update Hash Seed.
Returns:
  a SetOperation backed by the given Memory

#### getMaxUnionBytes

    public static int getMaxUnionBytes(int nomEntries)

Returns the maximum required storage bytes given a nomEntries parameter for Union operations

Parameters:
  `nomEntries` - Nominal Entries This will become the ceiling power of 2 if it is not.
Returns:
  the maximum required storage bytes given a nomEntries parameter

#### getMaxIntersectionBytes

    public static int getMaxIntersectionBytes(int nomEntries)

Returns the maximum required storage bytes given a nomEntries parameter for Intersection operations

Parameters:
  `nomEntries` - Nominal Entries This will become the ceiling power of 2 if it is not.
Returns:
  the maximum required storage bytes given a nomEntries parameter

#### getMaxAnotBResultBytes

    public static int getMaxAnotBResultBytes(int nomEntries)

Returns the maximum number of bytes for the returned CompactSketch, given the value of nomEntries of the first sketch A of AnotB.

Parameters:
  `nomEntries` - this value must be a power of 2.
Returns:
  the maximum number of bytes.

#### getFamily

    public abstract Family getFamily()

Gets the Family of this SetOperation

Returns:
  the Family of this SetOperation