aerospike/bitwise

Description:
  • 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.

Source:
Since:
  • v3.13.0
See:

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.

Classes

BitwiseOperation
OverflowableBitwiseOp

Members

(static) overflow :Object

Bitwise overflow action.

Description:
  • Action to take when a bitwise add/subtract operation results in overflow/underflow.

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.

Action to take when a bitwise add/subtract operation results in overflow/underflow.

Type:
  • Object

(static) resizeFlags :Object

Bitwise resize flags.

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.

Type:
  • Object

(static) writeFlags :Object

Bitwise write flags.

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.

Type:
  • Object

Methods

(static) add(bin, bitOffset, bitSize, value, sign) → {OverflowableBitwiseOp}

Create bit "add" operation.

Description:
  • Server adds value to bitmap. Server does not return a value.

Source:
See:
  • OverflowableBitwiseOp#onOverflow can used to control how the operation executes, when the addition results in an overflow/underflow.
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
OverflowableBitwiseOp

(static) and(bin, bitOffset, bitSize, value) → {BitwiseOperation}

Create bit "and" operation.

Description:
  • Server performs bitwise "and" on value and bitmap. Server does not return a value.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) get(bin, bitOffset, bitSize) → {BitwiseOperation}

Create bit "get" operation.

Description:
  • Server returns bits from bitmap.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) getInt(bin, bitOffset, bitSize, sign) → {BitwiseOperation}

Create bit "get integer" operation.

Description:
  • Server returns integer from bitmap.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) insert(bin, offset, value) → {BitwiseOperation}

Create byte "insert" operation.

Description:
  • Server inserts value bytes into bitmap. Server does not return a value.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) lscan(bin, bitOffset, bitSize, value) → {BitwiseOperation}

Create bit "left scan" operation.

Description:
  • Server returns integer bit offset of the first specified value bit in bitmap.

Source:
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).

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) lshift(bin, bitOffset, bitSize, shift) → {BitwiseOperation}

Create bit "left shift" operation.

Description:
  • Server shifts left bitmap. Server does not return a value.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) not(bin, bitOffset, bitSize) → {BitwiseOperation}

Create bit "not" operation.

Description:
  • Server negates bitmap. Server does not return a value.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) or(bin, bitOffset, bitSize, value) → {BitwiseOperation}

Create bit "or" operation.

Description:
  • Server performs bitwise "or" on value and bitmap. Server does not return a value.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) remove(bin, byteOffset, byteSize) → {BitwiseOperation}

Create byte "remove" operation.

Description:
  • Server removes bytes from bitmap. Server does not return a value.

Source:
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

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) resize(bin, size, flagsopt) → {BitwiseOperation}

Create byte "resize" operation.

Description:
  • Server resizes bitmap to byte size according to flags. Server does not return a value.

Source:
Parameters:
Name Type Attributes 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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) rscan(bin, bitOffset, bitSize, value) → {BitwiseOperation}

Create bit "right scan" operation.

Description:
  • Server returns integer bit offset of the last specified value bit in bitmap.

Source:
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).

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) rshift(bin, bitOffset, bitSize, shift) → {BitwiseOperation}

Create bit "right shift" operation.

Description:
  • Server shifts right bitmap. Server does not return a value.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation

(static) set(bin, bitOffset, bitSize, value) → {BitwiseOperation}

Create bit "set" operation.

Description:
  • Server sets value on bitmap. Server does not return a value.

Source:
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.

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) → {OverflowableBitwiseOp}

Create bit "subtract" operation.

Description:
  • Server subtracts value from bitmap. Server does not return a value.

Source:
See:
  • OverflowableBitwiseOp#onOverflow can used to control how the operation executes, when the addition results in an overflow/underflow.
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
OverflowableBitwiseOp

(static) xor(bin, bitOffset, bitSize, value) → {BitwiseOperation}

Create bit "exclusive or" operation.

Description:
  • Server performs bitwise "xor" on value and bitmap. Server does not return a value.

Source:
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.

Returns:

Operation that can be passed to the Client#operate command.

Type
BitwiseOperation