Package org.roaringbitmap.art
Class Containers
- java.lang.Object
-
- org.roaringbitmap.art.Containers
-
public class Containers extends java.lang.Object
To support the largest 2^48 different keys,we almost need 2^18 Container arrays which holds 2^31 - 8 Container
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Container[]>
containerArrays
private long
containerSize
private int
firstLevelIdx
private static int
MAX_JVM_ARRAY_LENGTH
private static int
MAX_JVM_ARRAY_OFFSET
private static byte
NOT_NULL_MARK
private static byte
NOT_TRIMMED_MARK
private static byte
NULL_MARK
private int
secondLevelIdx
private static byte
TRIMMED_MARK
-
Constructor Summary
Constructors Constructor Description Containers()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
addContainer(Container container)
add a Containerprivate byte
containerType(Container container)
void
deserialize(java.io.DataInput dataInput)
Deserialize the byte stream to init this Containersvoid
deserialize(java.nio.ByteBuffer byteBuffer)
Deserialize the byte stream to init this ContainersContainer
getContainer(long idx)
get the Container with the corresponding container index(package private) java.util.List<Container[]>
getContainerArrays()
long
getContainerSize()
the number of all the holding containersprivate void
grow(int minCapacity, int firstLevelIdx)
increases the capacity to ensure that it can hold at least the number of elements specified by the minimum capacity argument.private static int
hugeCapacity(int minCapacity)
private Container
instanceContainer(byte containerType, int cardinality, java.io.DataInput dataInput)
private Container
instanceContainer(byte containerType, int cardinality, java.nio.ByteBuffer byteBuffer)
ContainerIterator
iterator()
a iterator of the Containersvoid
remove(long containerIdx)
remove the container index Containervoid
replace(int firstLevelIdx, int secondLevelIdx, Container freshContainer)
replace with a fresh Containervoid
replace(long containerIdx, Container freshContainer)
replace the container index one with a fresh Containerprivate void
reset()
void
serialize(java.io.DataOutput dataOutput)
Serialize the Containersvoid
serialize(java.nio.ByteBuffer byteBuffer)
Serialize the Containerslong
serializedSizeInBytes()
Report the number of bytes required for serialization.(package private) static long
toContainerIdx(int firstLevelIdx, int secondLevelIdx)
-
-
-
Field Detail
-
containerArrays
private java.util.List<Container[]> containerArrays
-
containerSize
private long containerSize
-
firstLevelIdx
private int firstLevelIdx
-
secondLevelIdx
private int secondLevelIdx
-
MAX_JVM_ARRAY_LENGTH
private static final int MAX_JVM_ARRAY_LENGTH
- See Also:
- Constant Field Values
-
MAX_JVM_ARRAY_OFFSET
private static final int MAX_JVM_ARRAY_OFFSET
- See Also:
- Constant Field Values
-
NULL_MARK
private static final byte NULL_MARK
- See Also:
- Constant Field Values
-
NOT_NULL_MARK
private static final byte NOT_NULL_MARK
- See Also:
- Constant Field Values
-
TRIMMED_MARK
private static final byte TRIMMED_MARK
- See Also:
- Constant Field Values
-
NOT_TRIMMED_MARK
private static final byte NOT_TRIMMED_MARK
- See Also:
- Constant Field Values
-
-
Method Detail
-
reset
private void reset()
-
remove
public void remove(long containerIdx)
remove the container index Container- Parameters:
containerIdx
- the container index
-
getContainer
public Container getContainer(long idx)
get the Container with the corresponding container index- Parameters:
idx
- the container index- Returns:
- the corresponding Container
-
addContainer
public long addContainer(Container container)
add a Container- Parameters:
container
- a Container- Returns:
- the container index
-
iterator
public ContainerIterator iterator()
a iterator of the Containers- Returns:
- a iterator
-
replace
public void replace(long containerIdx, Container freshContainer)
replace the container index one with a fresh Container- Parameters:
containerIdx
- the container index to replacefreshContainer
- the fresh one
-
replace
public void replace(int firstLevelIdx, int secondLevelIdx, Container freshContainer)
replace with a fresh Container- Parameters:
firstLevelIdx
- the first level array indexsecondLevelIdx
- the second level array indexfreshContainer
- a fresh container
-
getContainerSize
public long getContainerSize()
the number of all the holding containers- Returns:
- the container number
-
getContainerArrays
java.util.List<Container[]> getContainerArrays()
-
toContainerIdx
static long toContainerIdx(int firstLevelIdx, int secondLevelIdx)
-
grow
private void grow(int minCapacity, int firstLevelIdx)
increases the capacity to ensure that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity
-
hugeCapacity
private static int hugeCapacity(int minCapacity)
-
serializedSizeInBytes
public long serializedSizeInBytes()
Report the number of bytes required for serialization.- Returns:
- The size in bytes
-
serialize
public void serialize(java.io.DataOutput dataOutput) throws java.io.IOException
Serialize the Containers- Parameters:
dataOutput
- The destination DataOutput- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
serialize
public void serialize(java.nio.ByteBuffer byteBuffer) throws java.io.IOException
Serialize the Containers- Parameters:
byteBuffer
- The destination ByteBuffer- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
deserialize
public void deserialize(java.io.DataInput dataInput) throws java.io.IOException
Deserialize the byte stream to init this Containers- Parameters:
dataInput
- The DataInput- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
deserialize
public void deserialize(java.nio.ByteBuffer byteBuffer) throws java.io.IOException
Deserialize the byte stream to init this Containers- Parameters:
byteBuffer
- The DataInput- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
containerType
private byte containerType(Container container)
-
instanceContainer
private Container instanceContainer(byte containerType, int cardinality, java.io.DataInput dataInput) throws java.io.IOException
- Throws:
java.io.IOException
-
instanceContainer
private Container instanceContainer(byte containerType, int cardinality, java.nio.ByteBuffer byteBuffer) throws java.io.IOException
- Throws:
java.io.IOException
-
-