This module defines bitwise operations on the Bytes data type.
The operations are executed using the Client#operate
command.
Offset orientation is left-to-right. Negative offsets are supported. If the offset is negative, the offset starts backwards from end of the bitmap. If an offset is out of bounds, a parameter error will be returned.
For more information, please refer to the ⇑Bytes Data Type and ⇑Bitwise Operations documentation in the Aerospike Feature Guide.
Bitwise operations require Aerospike Server 4.6.0 or later.
- Since:
-
- v3.13.0
- Source:
- See:
Classes
Members
-
<static> overflow :Object
Bitwise overflow action.
-
Type:
- Object
- Source:
Properties:
Name Type Description FAIL
number Fail operation with error. Default.
SATURATE
number If add/subtract overflows/underflows, set to max/min value. Example: MAXINT + 1 = MAXINT.
WRAP
number If add/subtract overflows/underflows, wrap the value. Example: MAXINT + 1 = -1.
-
<static> resizeFlags :Object
Bitwise resize flags.
-
Type:
- Object
- Source:
Properties:
Name Type Description DEFAULT
number Default.
FROM_FRONT
number Add/remove bytes from the beginning instead of the end.
GROW_ONLY
number Only allow the bitmap size to increase.
SHRINK_ONLY
number Only allow the bitmap size to decrease.
-
<static> writeFlags :Object
Bitwise write flags.
-
Type:
- Object
- Source:
- See:
Properties:
Name Type Description DEFAULT
number Allow create or update. Default.
CREATE_ONLY
number If the bin already exists, the operation will be denied. If the bin does not exist, a new bin will be created.
UPDATE_ONLY
number If the bin already exists, the bin will be overwritten. If the bin does not exist, the operation will be denied.
NO_FAIL
number Do not raise error if operation is denied.
PARTIAL
number Allow other valid operations to be committed if this operations is denied due to flag constraints.
Methods
-
<static> add(bin, bitOffset, bitSize, value, sign)
Create bit "add" operation.
-
Server adds value to bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits; must be <= 64.
value
number Value to add.
sign
boolean Sign indicates if bits should be treated as a signed number.
- Source:
- See:
-
OverflowableBitwiseOp#onOverflow
can used to control how the operation executes, when the addition results in an overflow/underflow.
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- OverflowableBitwiseOp
-
<static> and(bin, bitOffset, bitSize, value)
Create bit "and" operation.
-
Server performs bitwise "and" on value and bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits.
value
Buffer Value.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> get(bin, bitOffset, bitSize)
Create bit "get" operation.
-
Server returns bits from bitmap.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits to return.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> getInt(bin, bitOffset, bitSize, sign)
Create bit "get integer" operation.
-
Server returns integer from bitmap.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits to return.
sign
boolean Sign indicates if bits should be treated as a signed.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> insert(bin, offset, value)
Create byte "insert" operation.
-
Server inserts value bytes into bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
offset
number Offset in bytes.
value
Buffer Bytes to insert.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> lscan(bin, bitOffset, bitSize, value)
Create bit "left scan" operation.
-
Server returns integer bit offset of the first specified value bit in bitmap.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits.
value
boolean value to scan for, "0" (false) or "1" (true).
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> lshift(bin, bitOffset, bitSize, shift)
Create bit "left shift" operation.
-
Server shifts left bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits to shift.
shift
number Distance to shift bits.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> not(bin, bitOffset, bitSize)
Create bit "not" operation.
-
Server negates bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> or(bin, bitOffset, bitSize, value)
Create bit "or" operation.
-
Server performs bitwise "or" on value and bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits.
value
Buffer Value.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> remove(bin, byteOffset, byteSize)
Create byte "remove" operation.
-
Server removes bytes from bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
byteOffset
number Offset in bytes.
byteSize
number Number of bytes to remove
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> resize(bin, size [, flags])
Create byte "resize" operation.
-
Server resizes bitmap to byte size according to flags. Server does not return a value.
Parameters:
Name Type Argument Default Description bin
string The name of the bin. The bin must contain a byte value.
size
number Number of bytes to resize the byte value to.
flags
number <optional>
bitwise.resizeFlags.DEFAULT Optional
resize flags
.- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> rscan(bin, bitOffset, bitSize, value)
Create bit "right scan" operation.
-
Server returns integer bit offset of the last specified value bit in bitmap.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits.
value
boolean value to scan for, "0" (false) or "1" (true).
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> rshift(bin, bitOffset, bitSize, shift)
Create bit "right shift" operation.
-
Server shifts right bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits to shift.
shift
number Distance to shift bits.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> set(bin, bitOffset, bitSize, value)
Create bit "set" operation.
-
Server sets value on bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits to set.
value
number | Buffer Value to set.
- Source:
Throws:
TypeError unless value is an integer or a Buffer.
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation
-
<static> subtract(bin, bitOffset, bitSize, value, sign)
Create bit "subtract" operation.
-
Server subtracts value from bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits; must be <= 64.
value
number Value to subtract.
sign
boolean Sign indicates if bits should be treated as a signed number.
- Source:
- See:
-
OverflowableBitwiseOp#onOverflow
can used to control how the operation executes, when the addition results in an overflow/underflow.
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- OverflowableBitwiseOp
-
<static> xor(bin, bitOffset, bitSize, value)
Create bit "exclusive or" operation.
-
Server performs bitwise "xor" on value and bitmap. Server does not return a value.
Parameters:
Name Type Description bin
string The name of the bin. The bin must contain a byte value.
bitOffset
number Offset in bits.
bitSize
number Number of bits.
value
Buffer Value.
- Source:
Returns:
Operation that can be passed to the
Client#operate
command.- Type
- BitwiseOperation