public final class EWAHCompressedBitmap32 extends Object implements Cloneable, Externalizable, Iterable<Integer>, BitmapStorage32, LogicalElement<EWAHCompressedBitmap32>
This implements the patent-free EWAH scheme. Roughly speaking, it is a 32-bit variant of the BBC compression scheme used by Oracle for its bitmap indexes.
In contrast with the 64-bit EWAH scheme (javaewah.EWAHCompressedBitmap), you can expect this class to compress better, but to be slower at processing the data. In effect, there is a trade-off between memory usage and performances.
The objective of this compression type is to provide some compression,
while reducing as much as possible the CPU cycle usage.
For more details, see the following paper:
- Daniel Lemire, Owen Kaser, Kamel Aouiche, Sorting improves
word-aligned bitmap indexes. Data & Knowledge Engineering 69 (1), pages
3-28, 2010. http://arxiv.org/abs/0901.3751
,
Serialized FormModifier and Type | Field and Description |
---|---|
static boolean |
adjustContainerSizeWhenAggregating
whether we adjust after some aggregation by adding in zeroes
|
static boolean |
usetrailingzeros
optimization option
|
static int |
wordinbits
The Constant wordinbits represents the number of bits in a int.
|
Constructor and Description |
---|
EWAHCompressedBitmap32()
Creates an empty bitmap (no bit set to true).
|
EWAHCompressedBitmap32(int buffersize)
Sets explicitly the buffer size (in 32-bit words).
|
Modifier and Type | Method and Description |
---|---|
void |
add(int newdata)
Adding words directly to the bitmap (for expert use).
|
void |
add(int newdata,
int bitsthatmatter)
Adding words directly to the bitmap (for expert use).
|
void |
addStreamOfEmptyWords(boolean v,
int number)
For experts: You want to add many zeroes or ones? This is the method you
use.
|
void |
addStreamOfLiteralWords(int[] data,
int start,
int number)
if you have several literal words to copy over, this might be faster.
|
void |
addStreamOfNegatedLiteralWords(int[] data,
int start,
int number)
Same as addStreamOfLiteralWords, but the words are negated.
|
static EWAHCompressedBitmap32 |
and(EWAHCompressedBitmap32... bitmaps)
Returns a new compressed bitmap containing the bitwise AND values of the
provided bitmaps.
|
EWAHCompressedBitmap32 |
and(EWAHCompressedBitmap32 a)
Returns a new compressed bitmap containing the bitwise AND values of the
current bitmap with some other bitmap.
|
static int |
andCardinality(EWAHCompressedBitmap32... bitmaps)
Returns the cardinality of the result of a bitwise AND of the values of the
provided bitmaps.
|
int |
andCardinality(EWAHCompressedBitmap32 a)
Returns the cardinality of the result of a bitwise AND of the values of the
current bitmap with some other bitmap.
|
EWAHCompressedBitmap32 |
andNot(EWAHCompressedBitmap32 a)
Returns a new compressed bitmap containing the bitwise AND NOT values of
the current bitmap with some other bitmap.
|
int |
andNotCardinality(EWAHCompressedBitmap32 a)
Returns the cardinality of the result of a bitwise AND NOT of the values of
the current bitmap with some other bitmap.
|
void |
andNotToContainer(EWAHCompressedBitmap32 a,
BitmapStorage32 container)
Returns a new compressed bitmap containing the bitwise AND NOT values of
the current bitmap with some other bitmap.
|
void |
andToContainer(EWAHCompressedBitmap32 a,
BitmapStorage32 container)
Computes new compressed bitmap containing the bitwise AND values of the
current bitmap with some other bitmap.
|
static void |
andWithContainer(BitmapStorage32 container,
EWAHCompressedBitmap32... bitmaps)
For internal use.
|
static EWAHCompressedBitmap32 |
bitmapOf(int... setbits)
Return a bitmap with the bit set to true at the given
positions.
|
int |
cardinality()
reports the number of bits set to true.
|
void |
clear()
Clear any set bits and set size in bits back to 0
|
EWAHCompressedBitmap32 |
clone() |
void |
deserialize(DataInput in)
Deserialize.
|
boolean |
equals(Object o)
Check to see whether the two compressed bitmaps contain the same set bits.
|
boolean |
get(int i)
Query the value of a single bit.
|
EWAHIterator32 |
getEWAHIterator()
Gets an EWAHIterator over the data.
|
IteratingRLW32 |
getIteratingRLW() |
List<Integer> |
getPositions()
get the locations of the true values as one vector.
|
int |
hashCode()
Returns a customized hash code (based on Karp-Rabin).
|
boolean |
intersects(EWAHCompressedBitmap32 a)
Return true if the two EWAHCompressedBitmap have both at least one true bit
in the same position.
|
IntIterator |
intIterator()
Iterator over the set bits (this is what most people will want to use to
browse the content if they want an iterator).
|
Iterator<Integer> |
iterator()
iterate over the positions of the true values.
|
void |
not()
Negate (bitwise) the current bitmap.
|
static EWAHCompressedBitmap32 |
or(EWAHCompressedBitmap32... bitmaps)
Returns a new compressed bitmap containing the bitwise OR values of the
provided bitmaps.
|
EWAHCompressedBitmap32 |
or(EWAHCompressedBitmap32 a)
Returns a new compressed bitmap containing the bitwise OR values of the
current bitmap with some other bitmap.
|
static int |
orCardinality(EWAHCompressedBitmap32... bitmaps)
Returns the cardinality of the result of a bitwise OR of the values of the
provided bitmaps.
|
int |
orCardinality(EWAHCompressedBitmap32 a)
Returns the cardinality of the result of a bitwise OR of the values of the
current bitmap with some other bitmap.
|
void |
orToContainer(EWAHCompressedBitmap32 a,
BitmapStorage32 container)
Computes the bitwise or between the current bitmap and the bitmap "a".
|
static void |
orWithContainer(BitmapStorage32 container,
EWAHCompressedBitmap32... bitmaps)
For internal use.
|
void |
readExternal(ObjectInput in) |
void |
serialize(DataOutput out)
Serialize.
|
int |
serializedSizeInBytes()
Report the size required to serialize this bitmap
|
boolean |
set(int i)
Set the bit at position i to true, the bits must be set in (strictly) increasing
order.
|
void |
setSizeInBits(int size)
Set the size in bits.
|
boolean |
setSizeInBits(int size,
boolean defaultvalue)
Change the reported size in bits of the *uncompressed* bitmap represented
by this compressed bitmap.
|
int |
sizeInBits()
Returns the size in bits of the *uncompressed* bitmap represented by this
compressed bitmap.
|
int |
sizeInBytes()
Report the *compressed* size of the bitmap (equivalent to memory usage,
after accounting for some overhead).
|
void |
swap(EWAHCompressedBitmap32 other)
swap the content of the bitmap with another.
|
int[] |
toArray()
Populate an array of (sorted integers) corresponding to the location of the
set bits.
|
String |
toDebugString()
A more detailed string describing the bitmap (useful for debugging).
|
String |
toString()
A string describing the bitmap.
|
void |
trim()
Reduce the internal buffer to its minimal allowable size (given
by this.actualsizeinwords).
|
void |
writeExternal(ObjectOutput out) |
static EWAHCompressedBitmap32 |
xor(EWAHCompressedBitmap32... bitmaps)
Returns a new compressed bitmap containing the bitwise XOR values of the
provided bitmaps.
|
EWAHCompressedBitmap32 |
xor(EWAHCompressedBitmap32 a)
Returns a new compressed bitmap containing the bitwise XOR values of the
current bitmap with some other bitmap.
|
int |
xorCardinality(EWAHCompressedBitmap32 a)
Returns the cardinality of the result of a bitwise XOR of the values of the
current bitmap with some other bitmap.
|
void |
xorToContainer(EWAHCompressedBitmap32 a,
BitmapStorage32 container)
Computes a new compressed bitmap containing the bitwise XOR values of the
current bitmap with some other bitmap.
|
static void |
xorWithContainer(BitmapStorage32 container,
EWAHCompressedBitmap32... bitmaps)
For internal use.
|
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static final boolean usetrailingzeros
public static final boolean adjustContainerSizeWhenAggregating
public static final int wordinbits
public EWAHCompressedBitmap32()
public EWAHCompressedBitmap32(int buffersize)
buffersize
- number of 32-bit words reserved when the object is created)public void add(int newdata)
add
in interface BitmapStorage32
newdata
- the wordpublic void add(int newdata, int bitsthatmatter)
newdata
- the wordbitsthatmatter
- the number of significant bits (by default it should be 32)public void addStreamOfLiteralWords(int[] data, int start, int number)
addStreamOfLiteralWords
in interface BitmapStorage32
data
- the literal wordsstart
- the starting point in the arraynumber
- the number of literal words to addpublic void addStreamOfEmptyWords(boolean v, int number)
addStreamOfEmptyWords
in interface BitmapStorage32
v
- the boolean valuenumber
- the numberpublic void addStreamOfNegatedLiteralWords(int[] data, int start, int number)
addStreamOfNegatedLiteralWords
in interface BitmapStorage32
data
- the literal wordsstart
- the starting point in the arraynumber
- the number of literal words to addpublic EWAHCompressedBitmap32 and(EWAHCompressedBitmap32 a)
and
in interface LogicalElement<EWAHCompressedBitmap32>
a
- the other bitmappublic void andToContainer(EWAHCompressedBitmap32 a, BitmapStorage32 container)
a
- the other bitmapcontainer
- where we store the resultpublic int andCardinality(EWAHCompressedBitmap32 a)
a
- the other bitmappublic EWAHCompressedBitmap32 andNot(EWAHCompressedBitmap32 a)
andNot
in interface LogicalElement<EWAHCompressedBitmap32>
a
- the other bitmappublic void andNotToContainer(EWAHCompressedBitmap32 a, BitmapStorage32 container)
a
- the other bitmapcontainer
- where we store the resultpublic int andNotCardinality(EWAHCompressedBitmap32 a)
a
- the other bitmappublic int cardinality()
public void clear()
public EWAHCompressedBitmap32 clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public void deserialize(DataInput in) throws IOException
in
- the DataInput streamIOException
- Signals that an I/O exception has occurred.public boolean equals(Object o)
equals
in class Object
Object.equals(java.lang.Object)
public EWAHIterator32 getEWAHIterator()
public IteratingRLW32 getIteratingRLW()
public List<Integer> getPositions()
public int hashCode()
public boolean intersects(EWAHCompressedBitmap32 a)
a
- the other bitmappublic IntIterator intIterator()
public Iterator<Integer> iterator()
public void not()
not
in interface LogicalElement<EWAHCompressedBitmap32>
public EWAHCompressedBitmap32 or(EWAHCompressedBitmap32 a)
or
in interface LogicalElement<EWAHCompressedBitmap32>
a
- the other bitmappublic void orToContainer(EWAHCompressedBitmap32 a, BitmapStorage32 container)
a
- the other bitmapcontainer
- where we store the resultpublic int orCardinality(EWAHCompressedBitmap32 a)
a
- the other bitmappublic void readExternal(ObjectInput in) throws IOException
readExternal
in interface Externalizable
IOException
public void serialize(DataOutput out) throws IOException
out
- the DataOutput streamIOException
- Signals that an I/O exception has occurred.public int serializedSizeInBytes()
public boolean get(int i)
i
- the bit we are interested inpublic boolean set(int i)
i
- the indexIndexOutOfBoundsException
- if i is negative or greater than Integer.MAX_VALUE - 32public void setSizeInBits(int size)
setSizeInBits
in interface BitmapStorage32
size
- number of bitspublic boolean setSizeInBits(int size, boolean defaultvalue)
size
- the size in bitsdefaultvalue
- the default boolean valuepublic int sizeInBits()
sizeInBits
in interface LogicalElement<EWAHCompressedBitmap32>
public int sizeInBytes()
sizeInBytes
in interface LogicalElement<EWAHCompressedBitmap32>
public int[] toArray()
public String toDebugString()
public String toString()
public void swap(EWAHCompressedBitmap32 other)
other
- bitmap to swap withpublic void trim()
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public EWAHCompressedBitmap32 xor(EWAHCompressedBitmap32 a)
xor
in interface LogicalElement<EWAHCompressedBitmap32>
a
- the other bitmappublic void xorToContainer(EWAHCompressedBitmap32 a, BitmapStorage32 container)
a
- the other bitmapcontainer
- where we store the resultpublic int xorCardinality(EWAHCompressedBitmap32 a)
a
- the other bitmappublic static void andWithContainer(BitmapStorage32 container, EWAHCompressedBitmap32... bitmaps)
container
- where the result is storedbitmaps
- bitmaps to ANDpublic static EWAHCompressedBitmap32 and(EWAHCompressedBitmap32... bitmaps)
bitmaps
- bitmaps to AND togetherpublic static int andCardinality(EWAHCompressedBitmap32... bitmaps)
bitmaps
- bitmaps to ANDpublic static EWAHCompressedBitmap32 bitmapOf(int... setbits)
setbits
- list of set bit positionspublic static void orWithContainer(BitmapStorage32 container, EWAHCompressedBitmap32... bitmaps)
container
- where store the resultbitmaps
- to be aggregatedpublic static void xorWithContainer(BitmapStorage32 container, EWAHCompressedBitmap32... bitmaps)
container
- where store the resultbitmaps
- to be aggregatedpublic static EWAHCompressedBitmap32 or(EWAHCompressedBitmap32... bitmaps)
bitmaps
- bitmaps to OR togetherpublic static EWAHCompressedBitmap32 xor(EWAHCompressedBitmap32... bitmaps)
bitmaps
- bitmaps to XOR togetherpublic static int orCardinality(EWAHCompressedBitmap32... bitmaps)
bitmaps
- bitmaps to ORCopyright © 2018. All rights reserved.