|
|||||||||
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:
A 32-bit version of the compressed format was described by Wu et al. and named WBC:
Probably, the best prior art is the Oracle bitmap compression scheme (BBC):
1- The authors do 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). |
long |
addStreamOfDirtyWords(long[] data,
long start,
long number)
if you have several dirty words to copy over, this might be faster. |
int |
addStreamOfEmptyWords(boolean v,
long number)
For experts: You want to add many zeroes or ones? This is the method you use. |
long |
addStreamOfNegatedDirtyWords(long[] data,
long start,
long number)
Same as addStreamOfDirtyWords, but the words are negated. |
static EWAHCompressedBitmap |
and(EWAHCompressedBitmap... bitmaps)
Returns a new compressed bitmap containing the bitwise AND values of the provided bitmaps. |
EWAHCompressedBitmap |
and(EWAHCompressedBitmap a)
Returns a new compressed bitmap containing the bitwise AND values of the current bitmap with some other bitmap. |
static int |
andCardinality(EWAHCompressedBitmap... bitmaps)
Returns the cardinality of the result of a bitwise AND of the values of the provided bitmaps. |
int |
andCardinality(EWAHCompressedBitmap a)
Returns the cardinality of the result of a bitwise AND of the 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 |
andNotCardinality(EWAHCompressedBitmap a)
Returns the cardinality of the result of a bitwise AND NOT of the 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. |
protected static void |
discharge(BufferedRunningLengthWord initialWord,
EWAHIterator iterator,
BitmapStorage container)
For internal use. |
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. |
static EWAHCompressedBitmap |
or(EWAHCompressedBitmap... bitmaps)
Returns a new compressed bitmap containing the bitwise OR values of the provided bitmaps. |
EWAHCompressedBitmap |
or(EWAHCompressedBitmap a)
Returns a new compressed bitmap containing the bitwise OR values of the current bitmap with some other bitmap. |
static int |
orCardinality(EWAHCompressedBitmap... bitmaps)
Returns the cardinality of the result of a bitwise OR of the values of the provided bitmaps. |
int |
orCardinality(EWAHCompressedBitmap a)
Returns the cardinality of the result of a bitwise OR of the values of the current bitmap with some other bitmap. |
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 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). |
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. |
int |
xorCardinality(EWAHCompressedBitmap a)
Returns the cardinality of the result of a bitwise XOR of the 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 static EWAHCompressedBitmap and(EWAHCompressedBitmap... bitmaps)
bitmaps
- bitmaps to AND together
public static int andCardinality(EWAHCompressedBitmap... bitmaps)
bitmaps
- bitmaps to AND
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 int orCardinality(EWAHCompressedBitmap a)
a
- the other bitmap
public int andCardinality(EWAHCompressedBitmap a)
a
- the other bitmap
public int andNotCardinality(EWAHCompressedBitmap a)
a
- the other bitmap
public int xorCardinality(EWAHCompressedBitmap a)
a
- the other bitmap
public static EWAHCompressedBitmap or(EWAHCompressedBitmap... bitmaps)
bitmaps
- bitmaps to OR together
public static int orCardinality(EWAHCompressedBitmap... bitmaps)
bitmaps
- bitmaps to OR
protected static void discharge(BufferedRunningLengthWord initialWord, EWAHIterator iterator, BitmapStorage container)
initialWord
- the initial worditerator
- the iteratorcontainer
- the containerpublic boolean set(int i)
i
- the index
public int add(long newdata)
add
in interface BitmapStorage
newdata
- the word
public int addStreamOfEmptyWords(boolean v, long number)
addStreamOfEmptyWords
in interface BitmapStorage
v
- the boolean valuenumber
- the number
public long addStreamOfNegatedDirtyWords(long[] data, long start, long number)
addStreamOfNegatedDirtyWords
in interface BitmapStorage
data
- the dirty wordsstart
- the starting point in the arraynumber
- the number of dirty words to add
public long addStreamOfDirtyWords(long[] data, long start, long number)
addStreamOfDirtyWords
in interface BitmapStorage
data
- the dirty wordsstart
- the starting point in the arraynumber
- the number of dirty words to add
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 void setSizeInBits(int size)
setSizeInBits
in interface BitmapStorage
size
- number of bitspublic 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 int serializedSizeInBytes()
public void clear()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |