A set of NodeJS bindings for a compressed bitmap data structure.
Inspired by node-ewah (installation fails due to deprecated use of node-waf).
# We use node-gyp to build our binaries
npm install -g node-gyp
# Install node-bitmap-ewah
npm install node-bitmap-ewah
var Bitmap = require('node-bitmap-ewah');
var bitmap = Bitmap.createObject();
createObject()
push()
set()
unset()
toString()
length()
numberOfOnes()
map()
or()
and()
not()
write()
read()
createObject()
is the main entry point for creating a new compressed bitmap instance.
push()
appends a set bit (1) to the bitmap in position bit_pos. All bits between the last set bit and bit_pos are appended as unset bits (0).
set()
sets the bit in position bit_pos, provided it is already appended. Has no effect if bit is already set.
unset()
unsets the bit in position bit_pos, provided it is already appended. Has no effect if bit is already unset.
toString()
returns a string containing the positions of set bits, separated with the delimeter character.
length()
returns the uncopressed bitmap's size in bits.
numberOfOnes()
returns the number of set bits in the bitmap.
map()
returns an array with the results of calling the callback
function on each bit positiion that is set.
or()
applies the logical OR between two bitmaps.
and()
applies the logical AND between two bitmaps.
not()
applies the logical NOT to a bitmap.
write()
can be used to store a bitmap to persistent storage. It returns a three element array which contains
the bitmap's size in bits (1st position), the size (in words) of the underlying C++ STL vector (2nd positions) and a NodeJS
[Buffer
] (https://nodejs.org/api/buffer.html#buffer_buffer) class object representing the bitmap's content (3rd position).
read()
can be used to retriece a bitmap stored in persistent storage. It takes as argument an array of the same
format as returned from the write()
function