Package org.roaringbitmap
Class RoaringBitmapWriter.Wizard<C extends WordStorage<C>,T extends BitmapDataProvider & AppendableStorage<C>>
- java.lang.Object
-
- org.roaringbitmap.RoaringBitmapWriter.Wizard<C,T>
-
- All Implemented Interfaces:
Supplier<RoaringBitmapWriter<T>>
- Direct Known Subclasses:
RoaringBitmapWriter.BufferWizard
,RoaringBitmapWriter.RoaringWizard
- Enclosing interface:
- RoaringBitmapWriter<T extends BitmapDataProvider>
public abstract static class RoaringBitmapWriter.Wizard<C extends WordStorage<C>,T extends BitmapDataProvider & AppendableStorage<C>> extends Object implements Supplier<RoaringBitmapWriter<T>>
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
constantMemory
protected Supplier<C>
containerSupplier
protected int
expectedContainerSize
protected int
initialCapacity
protected boolean
partiallySortValues
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Supplier<C>
arraySupplier()
RoaringBitmapWriter.Wizard<C,T>
constantMemory()
All writes are buffered into the same buffer of 8kB, before converting to the best container representation and appending to the bitmap.protected abstract T
createUnderlying(int initialCapacity)
RoaringBitmapWriter.Wizard<C,T>
doPartialRadixSort()
Will partially sort values, which can allocate O(n) temporary memory but can significantly speed up adding unsorted values to a bitmap.RoaringBitmapWriter.Wizard<C,T>
expectedDensity(double density)
Influence default container choice by how dense the bitmap is expected to be.RoaringBitmapWriter.Wizard<C,T>
expectedRange(long min, long max)
Guesses the number of prefices required based on an estimate of the range the bitmap will contain, assumes that all prefices in the range will be required.RoaringBitmapWriter.Wizard<C,T>
expectedValuesPerContainer(int count)
RoaringBitmapWriter.Wizard<Container,FastRankRoaringBitmap>
fastRank()
RoaringBitmapWriter<T>
get()
Builds a bitmap writer based on the supplied options.RoaringBitmapWriter.Wizard<C,T>
initialCapacity(int count)
Takes control of the size of the prefix array, in case it can be precalculated or estimated.RoaringBitmapWriter.Wizard<C,T>
optimiseForArrays()
Choose this option if it is known that most containers will be sparse.RoaringBitmapWriter.Wizard<C,T>
optimiseForRuns()
Choose this option if the bitmap is expected to be RLE compressible.protected abstract Supplier<C>
runSupplier()
-
-
-
Field Detail
-
initialCapacity
protected int initialCapacity
-
constantMemory
protected boolean constantMemory
-
partiallySortValues
protected boolean partiallySortValues
-
containerSupplier
protected Supplier<C extends WordStorage<C>> containerSupplier
-
expectedContainerSize
protected int expectedContainerSize
-
-
Method Detail
-
optimiseForArrays
public RoaringBitmapWriter.Wizard<C,T> optimiseForArrays()
Choose this option if it is known that most containers will be sparse.- Returns:
- this
-
optimiseForRuns
public RoaringBitmapWriter.Wizard<C,T> optimiseForRuns()
Choose this option if the bitmap is expected to be RLE compressible. Will buffer additions into a RunContainer.- Returns:
- this
-
expectedValuesPerContainer
public RoaringBitmapWriter.Wizard<C,T> expectedValuesPerContainer(int count)
- Parameters:
count
- how many values are expected to fall within any 65536 bit range.- Returns:
- this
-
fastRank
public RoaringBitmapWriter.Wizard<Container,FastRankRoaringBitmap> fastRank()
-
constantMemory
public RoaringBitmapWriter.Wizard<C,T> constantMemory()
All writes are buffered into the same buffer of 8kB, before converting to the best container representation and appending to the bitmap. This option overrides any optimiseForArrays, optimiseForRuns and optimiseForBitmaps settings.- Returns:
- this
-
expectedDensity
public RoaringBitmapWriter.Wizard<C,T> expectedDensity(double density)
Influence default container choice by how dense the bitmap is expected to be.- Parameters:
density
- value in [0.0, 1.0], density of the bitmap- Returns:
- this
-
expectedRange
public RoaringBitmapWriter.Wizard<C,T> expectedRange(long min, long max)
Guesses the number of prefices required based on an estimate of the range the bitmap will contain, assumes that all prefices in the range will be required. This is a good heuristic for a contiguous bitmap, and, for instance, a very bad heuristic for a bitmap with just two values far apart.- Parameters:
min
- the inclusive min valuemax
- the exclusive max value- Returns:
- this
-
initialCapacity
public RoaringBitmapWriter.Wizard<C,T> initialCapacity(int count)
Takes control of the size of the prefix array, in case it can be precalculated or estimated. This can potentially save many array allocations during building the bitmap.- Parameters:
count
- an estimate of the number of prefix keys required.- Returns:
- this
-
doPartialRadixSort
public RoaringBitmapWriter.Wizard<C,T> doPartialRadixSort()
Will partially sort values, which can allocate O(n) temporary memory but can significantly speed up adding unsorted values to a bitmap.- Returns:
- this
-
createUnderlying
protected abstract T createUnderlying(int initialCapacity)
-
get
public RoaringBitmapWriter<T> get()
Builds a bitmap writer based on the supplied options. A call to this method is repeatable, and will not fail because the wizard should already be in a valid state.- Specified by:
get
in interfaceSupplier<C extends WordStorage<C>>
- Returns:
- a new RoaringBitmapWriter
-
-