|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavaewah.EWAHCompressedBitmap
public final class EWAHCompressedBitmap
This implements the patent-free(1) EWAH scheme. Roughly speaking, it is a 64-bit variant of the BBC compression scheme used by Oracle for its bitmap indexes.
The objective of this compression type is to provide some compression, while reducing as much as possible the CPU cycle usage.
This implementation being 64-bit, it assumes a 64-bit CPU together with a 64-bit Java Virtual Machine. This same code on a 32-bit machine may not be as fast.
For more details, see the following paper:
It was first described by Wu et al. and named WBC:
We can view this scheme as a 64-bit equivalent to the Oracle bitmap compression scheme:
1- The author (D. Lemire) does not know of any patent infringed by the following implementation. However, similar schemes, like WAH are covered by patents.
Field Summary | |
---|---|
static int |
wordinbits
The Constant wordinbits represents the number of bits in a long. |
Constructor Summary | |
---|---|
EWAHCompressedBitmap()
Creates an empty bitmap (no bit set to true). |
|
EWAHCompressedBitmap(int buffersize)
Sets explicitly the buffer size (in 64-bit words). |
Method Summary | |
---|---|
int |
add(long newdata)
Adding words directly to the bitmap (for expert use). |
int |
add(long newdata,
int bitsthatmatter)
Adding words directly to the bitmap (for expert use). |
int |
addStreamOfEmptyWords(boolean v,
long number)
For experts: You want to add many zeroes or ones? This is the method you use. |
EWAHCompressedBitmap |
and(EWAHCompressedBitmap a)
Returns a new compressed bitmap containing the bitwise AND values of the current bitmap with some other bitmap. |
EWAHCompressedBitmap |
andNot(EWAHCompressedBitmap a)
Returns a new compressed bitmap containing the bitwise AND NOT values of the current bitmap with some other bitmap. |
int |
cardinality()
reports the number of bits set to true. |
void |
clear()
Clear any set bits and set size in bits back to 0 |
Object |
clone()
|
void |
deserialize(DataInput in)
Deserialize. |
boolean |
equals(Object o)
Check to see whether the two compressed bitmaps contain the same data. |
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(EWAHCompressedBitmap 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). |
Iterator<Integer> |
iterator()
iterate over the positions of the true values. |
void |
not()
Negate (bitwise) the current bitmap. |
EWAHCompressedBitmap |
or(EWAHCompressedBitmap a)
Returns a new compressed bitmap containing the bitwise OR values of the current bitmap with some other bitmap. |
void |
readExternal(ObjectInput in)
|
void |
serialize(DataOutput out)
Serialize. |
boolean |
set(int i)
set the bit at position i to true, the bits must be set in increasing order. |
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). |
String |
toDebugString()
A more detailed string describing the bitmap (useful for debugging). |
String |
toString()
A string describing the bitmap. |
void |
writeExternal(ObjectOutput out)
|
EWAHCompressedBitmap |
xor(EWAHCompressedBitmap a)
Returns a new compressed bitmap containing the bitwise XOR values of the current bitmap with some other bitmap. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int wordinbits
Constructor Detail |
---|
public EWAHCompressedBitmap()
public EWAHCompressedBitmap(int buffersize)
buffersize
- number of 64-bit words reserved when the object is created)Method Detail |
---|
public EWAHCompressedBitmap xor(EWAHCompressedBitmap a)
a
- the other bitmap
public EWAHCompressedBitmap and(EWAHCompressedBitmap a)
a
- the other bitmap
public boolean intersects(EWAHCompressedBitmap a)
a
- the other bitmap
public EWAHCompressedBitmap andNot(EWAHCompressedBitmap a)
a
- the other bitmap
public void not()
public EWAHCompressedBitmap or(EWAHCompressedBitmap a)
a
- the other bitmap
public boolean set(int i)
i
- the index
public int add(long newdata)
newdata
- the word
public int addStreamOfEmptyWords(boolean v, long number)
v
- the boolean valuenumber
- the number
public int add(long newdata, int bitsthatmatter)
newdata
- the wordbitsthatmatter
- the number of significant bits (by default it should be 64)
public int sizeInBits()
public boolean setSizeInBits(int size, boolean defaultvalue)
size
- the size in bitsdefaultvalue
- the default boolean value
public int sizeInBytes()
public int cardinality()
public String toString()
toString
in class Object
public String toDebugString()
public IntIterator intIterator()
public Iterator<Integer> iterator()
iterator
in interface Iterable<Integer>
public List<Integer> getPositions()
public boolean equals(Object o)
equals
in class Object
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class Object
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public void readExternal(ObjectInput in) throws IOException
readExternal
in interface Externalizable
IOException
public void deserialize(DataInput in) throws IOException
in
- the DataInput stream
IOException
- Signals that an I/O exception has occurred.public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void serialize(DataOutput out) throws IOException
out
- the DataOutput stream
IOException
- Signals that an I/O exception has occurred.public void clear()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |