com.googlecode.javaewah32
Class EWAHCompressedBitmap32

java.lang.Object
  extended by com.googlecode.javaewah32.EWAHCompressedBitmap32
All Implemented Interfaces:
LogicalElement<EWAHCompressedBitmap32>, BitmapStorage32, Externalizable, Serializable, Cloneable, Iterable<Integer>

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.

Here is a code sample to illustrate usage:

 EWAHCompressedBitmap32 ewahBitmap1 = EWAHCompressedBitmap32.bitmapOf(0, 2, 55, 64,
         1 << 30);
 EWAHCompressedBitmap32 ewahBitmap2 = EWAHCompressedBitmap32.bitmapOf(1, 3, 64,
         1 << 30);
 EWAHCompressedBitmap32 ewahBitmap3 = EWAHCompressedBitmap32
         .bitmapOf(5, 55, 1 << 30);
 EWAHCompressedBitmap32 ewahBitmap4 = EWAHCompressedBitmap32
         .bitmapOf(4, 66, 1 << 30);
 EWAHCompressedBitmap32 orbitmap = ewahBitmap1.or(ewahBitmap2);
 EWAHCompressedBitmap32 andbitmap = ewahBitmap1.and(ewahBitmap2);
 EWAHCompressedBitmap32 xorbitmap = ewahBitmap1.xor(ewahBitmap2);
 andbitmap = EWAHCompressedBitmap32.and(ewahBitmap1, ewahBitmap2, ewahBitmap3,
         ewahBitmap4);
 ByteArrayOutputStream bos = new ByteArrayOutputStream();
 ObjectOutputStream oo = new ObjectOutputStream(bos);
 ewahBitmap1.writeExternal(oo);
 oo.close();
 ewahBitmap1 = null;
 ewahBitmap1 = new EWAHCompressedBitmap32();
 ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
 ewahBitmap1.readExternal(new ObjectInputStream(bis));
 EWAHCompressedBitmap32 threshold2 = EWAHCompressedBitmap32.threshold(2,
         ewahBitmap1, ewahBitmap2, ewahBitmap3, ewahBitmap4);
 

The objective of this compression type is to provide some compression, while reducing as much as possible the CPU cycle usage.

Once constructed, the bitmap is essentially immutable (unless you call the "set" or "add" methods). Thus, it can be safely used in multi-threaded programs.

For more details, see the following papers:

Since:
0.5.0
See Also:
EWAHCompressedBitmap, Serialized Form

Field Summary
static boolean adjustContainerSizeWhenAggregating
          whether we adjust after some aggregation by adding in zeroes
static int wordinbits
          The Constant wordinbits represents the number of bits in a int.
 
Constructor Summary
EWAHCompressedBitmap32()
          Creates an empty bitmap (no bit set to true).
EWAHCompressedBitmap32(int buffersize)
          Sets explicitly the buffer size (in 32-bit words).
 
Method Summary
 void add(int newdata)
          Deprecated. use addWord() instead.
 void add(int newdata, int bitsthatmatter)
          Deprecated. use addWord() instead.
 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.
 void addWord(int newdata)
          Adding words directly to the bitmap (for expert use).
 void addWord(int newdata, int bitsthatmatter)
          Adding words directly to the bitmap (for expert use).
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
 IntIterator clearIntIterator()
          Iterator over the clear bits.
 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()
          Gets an IteratingRLW to iterate over the data.
 List<Integer> getPositions()
          Deprecated. use toList() instead.
 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()
          Iterates 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.
static EWAHCompressedBitmap32 threshold(int T, EWAHCompressedBitmap32... bitmaps)
          Compute a Boolean threshold function: bits are true where at least T bitmaps have a true bit.
static void thresholdWithContainer(BitmapStorage32 container, int T, EWAHCompressedBitmap32... bitmaps)
          Compute a Boolean threshold function: bits are true where at least T bitmaps have a true bit.
 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).
 List<Integer> toList()
          Gets the locations of the true values as one list.
 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.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

adjustContainerSizeWhenAggregating

public static final boolean adjustContainerSizeWhenAggregating
whether we adjust after some aggregation by adding in zeroes

See Also:
Constant Field Values

wordinbits

public static final int wordinbits
The Constant wordinbits represents the number of bits in a int.

See Also:
Constant Field Values
Constructor Detail

EWAHCompressedBitmap32

public EWAHCompressedBitmap32()
Creates an empty bitmap (no bit set to true).


EWAHCompressedBitmap32

public EWAHCompressedBitmap32(int buffersize)
Sets explicitly the buffer size (in 32-bit words). The initial memory usage will be "buffersize * 32". For large poorly compressible bitmaps, using large values may improve performance.

Parameters:
buffersize - number of 32-bit words reserved when the object is created)
Method Detail

add

@Deprecated
public void add(int newdata)
Deprecated. use addWord() instead.

Parameters:
newdata - the word

add

@Deprecated
public void add(int newdata,
                           int bitsthatmatter)
Deprecated. use addWord() instead.

Parameters:
newdata - the word
bitsthatmatter - the number of significant bits (by default it should be 64)

addWord

public void addWord(int newdata)
Adding words directly to the bitmap (for expert use). This method adds bits in words of 4*8 bits. It is not to be confused with the set method which sets individual bits. Most users will want the set method. Example: if you add word 321 to an empty bitmap, you are have added (in binary notation) 0b101000001, so you have effectively called set(0), set(6), set(8) in sequence. Since this modifies the bitmap, this method is not thread-safe. API change: prior to version 0.8.3, this method was called add.

Specified by:
addWord in interface BitmapStorage32
Parameters:
newdata - the word

addWord

public void addWord(int newdata,
                    int bitsthatmatter)
Adding words directly to the bitmap (for expert use). Since this modifies the bitmap, this method is not thread-safe. API change: prior to version 0.8.3, this method was called add.

Parameters:
newdata - the word
bitsthatmatter - the number of significant bits (by default it should be 32)

addStreamOfLiteralWords

public void addStreamOfLiteralWords(int[] data,
                                    int start,
                                    int number)
if you have several literal words to copy over, this might be faster. Since this modifies the bitmap, this method is not thread-safe.

Specified by:
addStreamOfLiteralWords in interface BitmapStorage32
Parameters:
data - the literal words
start - the starting point in the array
number - the number of literal words to add

addStreamOfEmptyWords

public void addStreamOfEmptyWords(boolean v,
                                  int number)
For experts: You want to add many zeroes or ones? This is the method you use. Since this modifies the bitmap, this method is not thread-safe.

Specified by:
addStreamOfEmptyWords in interface BitmapStorage32
Parameters:
v - the boolean value
number - the number

addStreamOfNegatedLiteralWords

public void addStreamOfNegatedLiteralWords(int[] data,
                                           int start,
                                           int number)
Same as addStreamOfLiteralWords, but the words are negated. Since this modifies the bitmap, this method is not thread-safe.

Specified by:
addStreamOfNegatedLiteralWords in interface BitmapStorage32
Parameters:
data - the literal words
start - the starting point in the array
number - the number of literal words to add

and

public EWAHCompressedBitmap32 and(EWAHCompressedBitmap32 a)
Returns a new compressed bitmap containing the bitwise AND values of the current bitmap with some other bitmap. The current bitmap is not modified. The running time is proportional to the sum of the compressed sizes (as reported by sizeInBytes()). If you are not planning on adding to the resulting bitmap, you may call the trim() method to reduce memory usage.

Specified by:
and in interface LogicalElement<EWAHCompressedBitmap32>
Parameters:
a - the other bitmap (it will not be modified)
Returns:
the EWAH compressed bitmap

andToContainer

public void andToContainer(EWAHCompressedBitmap32 a,
                           BitmapStorage32 container)
Computes new compressed bitmap containing the bitwise AND values of the current bitmap with some other bitmap. The current bitmap is not modified. The running time is proportional to the sum of the compressed sizes (as reported by sizeInBytes()). The content of the container is overwritten.

Parameters:
a - the other bitmap (it will not be modified)
container - where we store the result
Since:
0.4.0

andCardinality

public 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. Avoids allocating an intermediate bitmap to hold the result of the OR. The current bitmap is not modified.

Parameters:
a - the other bitmap (it will not be modified)
Returns:
the cardinality

andNot

public EWAHCompressedBitmap32 andNot(EWAHCompressedBitmap32 a)
Returns a new compressed bitmap containing the bitwise AND NOT values of the current bitmap with some other bitmap. The current bitmap is not modified. The running time is proportional to the sum of the compressed sizes (as reported by sizeInBytes()). If you are not planning on adding to the resulting bitmap, you may call the trim() method to reduce memory usage.

Specified by:
andNot in interface LogicalElement<EWAHCompressedBitmap32>
Parameters:
a - the other bitmap (it will not be modified)
Returns:
the EWAH compressed bitmap

andNotToContainer

public 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. The current bitmap is not modified. The running time is proportional to the sum of the compressed sizes (as reported by sizeInBytes()). The content of the container is overwritten.

Parameters:
a - the other bitmap (it will not be modified)
container - where we store the result

andNotCardinality

public 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. Avoids allocating an intermediate bitmap to hold the result of the OR. The current bitmap is not modified.

Parameters:
a - the other bitmap (it will not be modified)
Returns:
the cardinality

cardinality

public int cardinality()
reports the number of bits set to true. Running time is proportional to compressed size (as reported by sizeInBytes).

Returns:
the number of bits set to true

clear

public void clear()
Clear any set bits and set size in bits back to 0

Specified by:
clear in interface BitmapStorage32

clone

public EWAHCompressedBitmap32 clone()
Overrides:
clone in class Object

deserialize

public void deserialize(DataInput in)
                 throws IOException
Deserialize.

Parameters:
in - the DataInput stream
Throws:
IOException - Signals that an I/O exception has occurred.

equals

public boolean equals(Object o)
Check to see whether the two compressed bitmaps contain the same set bits.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

getEWAHIterator

public EWAHIterator32 getEWAHIterator()
Gets an EWAHIterator over the data. This is a customized iterator which iterates over run length words. For experts only. The current bitmap is not modified.

Returns:
the EWAHIterator

getIteratingRLW

public IteratingRLW32 getIteratingRLW()
Gets an IteratingRLW to iterate over the data. For experts only. The current bitmap is not modified.

Returns:
the IteratingRLW iterator corresponding to this bitmap

getPositions

@Deprecated
public List<Integer> getPositions()
Deprecated. use toList() instead.

Returns:
a list

toList

public List<Integer> toList()
Gets the locations of the true values as one list. (May use more memory than iterator().) The current bitmap is not modified. API change: prior to version 0.8.3, this method was called getPositions.

Returns:
the positions

hashCode

public int hashCode()
Returns a customized hash code (based on Karp-Rabin). Naturally, if the bitmaps are equal, they will hash to the same value. The current bitmap is not modified.

Overrides:
hashCode in class Object

intersects

public boolean intersects(EWAHCompressedBitmap32 a)
Return true if the two EWAHCompressedBitmap have both at least one true bit in the same position. Equivalently, you could call "and" and check whether there is a set bit, but intersects will run faster if you don't need the result of the "and" operation. The current bitmap is not modified.

Parameters:
a - the other bitmap (it will not be modified)
Returns:
whether they intersect

intIterator

public 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). The location of the set bits is returned, in increasing order. The current bitmap is not modified.

Returns:
the int iterator

clearIntIterator

public IntIterator clearIntIterator()
Iterator over the clear bits. The location of the clear bits is returned, in increasing order. The current bitmap is not modified.

Returns:
the int iterator

iterator

public Iterator<Integer> iterator()
Iterates over the positions of the true values. This is similar to intIterator(), but it uses Java generics. The current bitmap is not modified.

Specified by:
iterator in interface Iterable<Integer>
Returns:
the iterator

not

public void not()
Negate (bitwise) the current bitmap. To get a negated copy, do EWAHCompressedBitmap x= ((EWAHCompressedBitmap) mybitmap.clone()); x.not(); The running time is proportional to the compressed size (as reported by sizeInBytes()). Because this method modifies the bitmap, it is not thread-safe.

Specified by:
not in interface LogicalElement<EWAHCompressedBitmap32>

or

public EWAHCompressedBitmap32 or(EWAHCompressedBitmap32 a)
Returns a new compressed bitmap containing the bitwise OR values of the current bitmap with some other bitmap. The running time is proportional to the sum of the compressed sizes (as reported by sizeInBytes()). If you are not planning on adding to the resulting bitmap, you may call the trim() method to reduce memory usage. The current bitmap is not modified.

Specified by:
or in interface LogicalElement<EWAHCompressedBitmap32>
Parameters:
a - the other bitmap (it will not be modified)
Returns:
the EWAH compressed bitmap

orToContainer

public void orToContainer(EWAHCompressedBitmap32 a,
                          BitmapStorage32 container)
Computes the bitwise or between the current bitmap and the bitmap "a". Stores the result in the container. The current bitmap is not modified. The content of the container is overwritten.

Parameters:
a - the other bitmap (it will not be modified)
container - where we store the result

orCardinality

public 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. Avoids allocating an intermediate bitmap to hold the result of the OR. The current bitmap is not modified.

Parameters:
a - the other bitmap (it will not be modified)
Returns:
the cardinality

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Specified by:
readExternal in interface Externalizable
Throws:
IOException

serialize

public void serialize(DataOutput out)
               throws IOException
Serialize. The current bitmap is not modified.

Parameters:
out - the DataOutput stream
Throws:
IOException - Signals that an I/O exception has occurred.

serializedSizeInBytes

public int serializedSizeInBytes()
Report the size required to serialize this bitmap. The current bitmap is not modified.

Returns:
the size in bytes

get

public boolean get(int i)
Query the value of a single bit. Relying on this method when speed is needed is discouraged. The complexity is linear with the size of the bitmap. (This implementation is based on zhenjl's Go version of JavaEWAH.) The current bitmap is not modified.

Parameters:
i - the bit we are interested in
Returns:
whether the bit is set to true

set

public boolean set(int i)
Set the bit at position i to true, the bits must be set in (strictly) increasing order. For example, set(15) and then set(7) will fail. You must do set(7) and then set(15). Since this modifies the bitmap, this method is not thread-safe.

Parameters:
i - the index
Returns:
true if the value was set (always true when i is greater or equal to sizeInBits()).
Throws:
IndexOutOfBoundsException - if i is negative or greater than Integer.MAX_VALUE - 32

setSizeInBits

public void setSizeInBits(int size)
Set the size in bits. This does not change the compressed bitmap.

Specified by:
setSizeInBits in interface BitmapStorage32
Parameters:
size - number of bits

setSizeInBits

public boolean setSizeInBits(int size,
                             boolean defaultvalue)
Change the reported size in bits of the *uncompressed* bitmap represented by this compressed bitmap. It may change the underlying compressed bitmap. It is not possible to reduce the sizeInBits, but it can be extended. The new bits are set to false or true depending on the value of defaultvalue. This method is not thread-safe.

Parameters:
size - the size in bits
defaultvalue - the default boolean value
Returns:
true if the update was possible

sizeInBits

public int sizeInBits()
Returns the size in bits of the *uncompressed* bitmap represented by this compressed bitmap. Initially, the sizeInBits is zero. It is extended automatically when you set bits to true. The current bitmap is not modified.

Specified by:
sizeInBits in interface LogicalElement<EWAHCompressedBitmap32>
Returns:
the size in bits

sizeInBytes

public int sizeInBytes()
Report the *compressed* size of the bitmap (equivalent to memory usage, after accounting for some overhead).

Specified by:
sizeInBytes in interface LogicalElement<EWAHCompressedBitmap32>
Returns:
the size in bytes

threshold

public static EWAHCompressedBitmap32 threshold(int T,
                                               EWAHCompressedBitmap32... bitmaps)
Compute a Boolean threshold function: bits are true where at least T bitmaps have a true bit.

Parameters:
T - the threshold
bitmaps - input data
Returns:
the aggregated bitmap
Since:
0.8.2

thresholdWithContainer

public static void thresholdWithContainer(BitmapStorage32 container,
                                          int T,
                                          EWAHCompressedBitmap32... bitmaps)
Compute a Boolean threshold function: bits are true where at least T bitmaps have a true bit. The content of the container is overwritten.

Parameters:
T - the threshold
bitmaps - input data
container - where we write the aggregated bitmap
Since:
0.8.2

toArray

public int[] toArray()
Populate an array of (sorted integers) corresponding to the location of the set bits.

Returns:
the array containing the location of the set bits

toDebugString

public String toDebugString()
A more detailed string describing the bitmap (useful for debugging).

Returns:
the string

toString

public String toString()
A string describing the bitmap.

Overrides:
toString in class Object
Returns:
the string

swap

public void swap(EWAHCompressedBitmap32 other)
swap the content of the bitmap with another.

Parameters:
other - bitmap to swap with

trim

public void trim()
Reduce the internal buffer to its minimal allowable size (given by this.actualsizeinwords). This can free memory.


writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

xor

public EWAHCompressedBitmap32 xor(EWAHCompressedBitmap32 a)
Returns a new compressed bitmap containing the bitwise XOR values of the current bitmap with some other bitmap. The running time is proportional to the sum of the compressed sizes (as reported by sizeInBytes()). If you are not planning on adding to the resulting bitmap, you may call the trim() method to reduce memory usage. The current bitmap is not modified.

Specified by:
xor in interface LogicalElement<EWAHCompressedBitmap32>
Parameters:
a - the other bitmap (it will not be modified)
Returns:
the EWAH compressed bitmap

xorToContainer

public void xorToContainer(EWAHCompressedBitmap32 a,
                           BitmapStorage32 container)
Computes a new compressed bitmap containing the bitwise XOR values of the current bitmap with some other bitmap. The running time is proportional to the sum of the compressed sizes (as reported by sizeInBytes()). The current bitmap is not modified. The content of the container is overwritten.

Parameters:
a - the other bitmap (it will not be modified)
container - where we store the result

xorCardinality

public 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. Avoids allocating an intermediate bitmap to hold the result of the OR. The current bitmap is not modified.

Parameters:
a - the other bitmap (it will not be modified)
Returns:
the cardinality

andWithContainer

public static void andWithContainer(BitmapStorage32 container,
                                    EWAHCompressedBitmap32... bitmaps)
For internal use. Computes the bitwise and of the provided bitmaps and stores the result in the container. The content of the container is overwritten.

Parameters:
container - where the result is stored
bitmaps - bitmaps to AND

and

public static EWAHCompressedBitmap32 and(EWAHCompressedBitmap32... bitmaps)
Returns a new compressed bitmap containing the bitwise AND values of the provided bitmaps. It may or may not be faster than doing the aggregation two-by-two (A.and(B).and(C)). If only one bitmap is provided, it is returned as is. If you are not planning on adding to the resulting bitmap, you may call the trim() method to reduce memory usage.

Parameters:
bitmaps - bitmaps to AND together
Returns:
result of the AND

andCardinality

public static int andCardinality(EWAHCompressedBitmap32... bitmaps)
Returns the cardinality of the result of a bitwise AND of the values of the provided bitmaps. Avoids allocating an intermediate bitmap to hold the result of the AND.

Parameters:
bitmaps - bitmaps to AND
Returns:
the cardinality

bitmapOf

public static EWAHCompressedBitmap32 bitmapOf(int... setbits)
Return a bitmap with the bit set to true at the given positions. The positions should be given in sorted order. (This is a convenience method.)

Parameters:
setbits - list of set bit positions
Returns:
the bitmap
Since:
0.4.5

orWithContainer

public static void orWithContainer(BitmapStorage32 container,
                                   EWAHCompressedBitmap32... bitmaps)
For internal use. Computes the bitwise or of the provided bitmaps and stores the result in the container. The content of the container is overwritten.

Parameters:
container - where store the result
bitmaps - to be aggregated

xorWithContainer

public static void xorWithContainer(BitmapStorage32 container,
                                    EWAHCompressedBitmap32... bitmaps)
For internal use. Computes the bitwise xor of the provided bitmaps and stores the result in the container. The content of the container is overwritten.

Parameters:
container - where store the result
bitmaps - to be aggregated

or

public static EWAHCompressedBitmap32 or(EWAHCompressedBitmap32... bitmaps)
Returns a new compressed bitmap containing the bitwise OR values of the provided bitmaps. This is typically faster than doing the aggregation two-by-two (A.or(B).or(C).or(D)). If only one bitmap is provided, it is returned as is. If you are not planning on adding to the resulting bitmap, you may call the trim() method to reduce memory usage.

Parameters:
bitmaps - bitmaps to OR together
Returns:
result of the OR

xor

public static EWAHCompressedBitmap32 xor(EWAHCompressedBitmap32... bitmaps)
Returns a new compressed bitmap containing the bitwise XOR values of the provided bitmaps. This is typically faster than doing the aggregation two-by-two (A.xor(B).xor(C).xor(D)). If only one bitmap is provided, it is returned as is. If you are not planning on adding to the resulting bitmap, you may call the trim() method to reduce memory usage.

Parameters:
bitmaps - bitmaps to XOR together
Returns:
result of the XOR

orCardinality

public static int orCardinality(EWAHCompressedBitmap32... bitmaps)
Returns the cardinality of the result of a bitwise OR of the values of the provided bitmaps. Avoids allocating an intermediate bitmap to hold the result of the OR.

Parameters:
bitmaps - bitmaps to OR
Returns:
the cardinality


Copyright © 2014. All Rights Reserved.