Package org.apache.datasketches.theta

# Class SetOperationBuilder

java.lang.Object
org.apache.datasketches.theta.SetOperationBuilder

public class SetOperationBuilder extends Object
For building a new SetOperation.

Author:
  Lee Rhodes

## Constructor Summary

Constructors
Constructor
Description
`SetOperationBuilder()`
Constructor for building a new SetOperation.

## Method Summary

Modifier and Type
Method
Description
`SetOperation`
`build(Family family)`
Returns a SetOperation with the current configuration of this Builder and the given Family.
`SetOperation`
`build(Family family, org.apache.datasketches.memory.WritableMemory dstMem)`
Returns a SetOperation with the current configuration of this Builder, the given Family and the given destination memory.
`AnotB`
`buildANotB()`
Convenience method, returns a configured SetOperation ANotB with Default Update Seed
`Intersection`
`buildIntersection()`
Convenience method, returns a configured SetOperation Intersection with Default Nominal Entries
`Intersection`
`buildIntersection(org.apache.datasketches.memory.WritableMemory dstMem)`
Convenience method, returns a configured SetOperation Intersection with Default Nominal Entries and the given destination memory.
`Union`
`buildUnion()`
Convenience method, returns a configured SetOperation Union with Default Nominal Entries
`Union`
`buildUnion(org.apache.datasketches.memory.WritableMemory dstMem)`
Convenience method, returns a configured SetOperation Union with Default Nominal Entries and the given destination memory.
`int`
`getLgNominalEntries()`
Returns Log-base 2 Nominal Entries
`org.apache.datasketches.memory.MemoryRequestServer`
`getMemoryRequestServer()`
Returns the MemoryRequestServer
`float`
`getP()`
Returns the pre-sampling probability p
`ResizeFactor`
`getResizeFactor()`
Returns the Resize Factor
`long`
`getSeed()`
Returns the seed
`SetOperationBuilder`
`setLogNominalEntries(int lgNomEntries)`
Alternative method of setting the Nominal Entries for this set operation from the log_base2 value.
`SetOperationBuilder`
`setMemoryRequestServer(org.apache.datasketches.memory.MemoryRequestServer memReqSvr)`
Set the MemoryRequestServer
`SetOperationBuilder`
`setNominalEntries(int nomEntries)`
Sets the Maximum Nominal Entries (max K) for this set operation.
`SetOperationBuilder`
`setP(float p)`
Sets the upfront uniform sampling probability, p.
`SetOperationBuilder`
`setResizeFactor(ResizeFactor rf)`
Sets the cache Resize Factor
`SetOperationBuilder`
`setSeed(long seed)`
Sets the long seed value that is require by the hashing function.
`String`
`toString()`

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

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

## Constructor Details

### SetOperationBuilder

public SetOperationBuilder()
Constructor for building a new SetOperation. The default configuration is

- Max Nominal Entries (max K): 4096
- Seed: 9001L
- `ResizeFactor.X8`
- Input Sampling Probability: 1.0
- Memory: null

## Method Details

### setNominalEntries

public SetOperationBuilder setNominalEntries(int nomEntries)
Sets the Maximum Nominal Entries (max K) for this set operation. The effective value of K of the result of a Set Operation can be less than max K, but never greater. The minimum value is 16 and the maximum value is 67,108,864, which is 2^26.

Parameters:
  `nomEntries` - Nominal Entries This will become the ceiling power of 2 if it is not a power of 2.
Returns:
  this SetOperationBuilder

### setLogNominalEntries

public SetOperationBuilder setLogNominalEntries(int lgNomEntries)
Alternative method of setting the Nominal Entries for this set operation from the log_base2 value. The minimum value is 4 and the maximum value is 26. Be aware that set operations as large as this maximum value may not have been thoroughly characterized for performance.

Parameters:
  `lgNomEntries` - the log_base2 Nominal Entries.
Returns:
  this SetOperationBuilder

### getLgNominalEntries

public int getLgNominalEntries()
Returns Log-base 2 Nominal Entries

Returns:
  Log-base 2 Nominal Entries

### setSeed

public SetOperationBuilder setSeed(long seed)
Sets the long seed value that is require by the hashing function.

Parameters:
  `seed` - See seed
Returns:
  this SetOperationBuilder

### getSeed

public long getSeed()
Returns the seed

Returns:
  the seed

### setP

public SetOperationBuilder setP(float p)
Sets the upfront uniform sampling probability, p. Although this functionality is implemented for Unions only, it rarely makes sense to use it. The proper use of upfront sampling is when building the sketches.

Parameters:
  `p` - See Sampling Probability, p
Returns:
  this SetOperationBuilder

### getP

public float getP()
Returns the pre-sampling probability p

Returns:
  the pre-sampling probability p

### setResizeFactor

public SetOperationBuilder setResizeFactor(ResizeFactor rf)
Sets the cache Resize Factor

Parameters:
  `rf` - See Resize Factor
Returns:
  this SetOperationBuilder

### getResizeFactor

public ResizeFactor getResizeFactor()
Returns the Resize Factor

Returns:
  the Resize Factor

### setMemoryRequestServer

public SetOperationBuilder setMemoryRequestServer(org.apache.datasketches.memory.MemoryRequestServer memReqSvr)
Set the MemoryRequestServer

Parameters:
  `memReqSvr` - the given MemoryRequestServer
Returns:
  this SetOperationBuilder

### getMemoryRequestServer

public org.apache.datasketches.memory.MemoryRequestServer getMemoryRequestServer()
Returns the MemoryRequestServer

Returns:
  the MemoryRequestServer

### build

public SetOperation build(Family family)
Returns a SetOperation with the current configuration of this Builder and the given Family.

Parameters:
  `family` - the chosen SetOperation family
Returns:
  a SetOperation

### build

public SetOperation build(Family family, org.apache.datasketches.memory.WritableMemory dstMem)
Returns a SetOperation with the current configuration of this Builder, the given Family and the given destination memory. Note that the destination memory cannot be used with AnotB.

Parameters:
  `family` - the chosen SetOperation family
  `dstMem` - The destination Memory.
Returns:
  a SetOperation

### buildUnion

public Union buildUnion()
Convenience method, returns a configured SetOperation Union with Default Nominal Entries

Returns:
  a Union object

### buildUnion

public Union buildUnion(org.apache.datasketches.memory.WritableMemory dstMem)
Convenience method, returns a configured SetOperation Union with Default Nominal Entries and the given destination memory.

Parameters:
  `dstMem` - The destination Memory.
Returns:
  a Union object

### buildIntersection

public Intersection buildIntersection()
Convenience method, returns a configured SetOperation Intersection with Default Nominal Entries

Returns:
  an Intersection object

### buildIntersection

public Intersection buildIntersection(org.apache.datasketches.memory.WritableMemory dstMem)
Convenience method, returns a configured SetOperation Intersection with Default Nominal Entries and the given destination memory.

Parameters:
  `dstMem` - The destination Memory.
Returns:
  an Intersection object

### buildANotB

public AnotB buildANotB()
Convenience method, returns a configured SetOperation ANotB with Default Update Seed

Returns:
  an ANotB object

### toString

public String toString()

Overrides:
  `toString` in class `Object`