Aerospike.Op.Bit (Aerospike Driver v0.3.1)

Copy Markdown View Source

Bit operations on a byte-array bin for Aerospike.operate/4.

Bit operations require an Aerospike blob bin. When seeding a bit bin through this client, write an explicit blob such as {:blob, <<0>>} because plain Elixir binaries are encoded as Aerospike strings.

Offsets are read left to right within the bin. Negative bit or byte offsets count backward from the end of the bitmap. Out-of-bounds offsets produce a server parameter error.

Offsets are in bits for set/5, bw_or/5, bw_xor/5, bw_and/5, bw_not/4, lshift/5, rshift/5, add/5, subtract/5, set_int/5, get/4, count/4, lscan/5, rscan/5, and get_int/5. resize/4, insert/4, and remove/4 use byte offsets and sizes.

Pass ctx: for nested bitmaps and flags: for write policy flags.

Summary

Types

Bit operation write policy flags.

Common bit operation options.

Overflow action for bit add/subtract operations.

Resize flags for bit resize operations.

t()

Opaque bit operation for Aerospike.operate/4.

Functions

Adds value to a sub-integer in the bitmap.

Applies bitwise AND of value into [bit_offset, bit_offset + bit_size).

Inverts [bit_offset, bit_offset + bit_size).

Applies bitwise OR of value into [bit_offset, bit_offset + bit_size).

Applies bitwise XOR of value into [bit_offset, bit_offset + bit_size).

Returns the count of bits set to 1 in [bit_offset, bit_offset + bit_size).

Returns bit_size bits starting at bit_offset as a binary.

Reads an integer from [bit_offset, bit_offset + bit_size).

Inserts bytes at byte_offset in the bin.

Returns the offset of the first bit matching value when scanning left to right.

Left shifts [bit_offset, bit_offset + bit_size) by shift bits.

Fail bit add/subtract on overflow or underflow.

Saturate bit add/subtract to min/max on overflow or underflow.

Wrap bit add/subtract on overflow or underflow.

Removes byte_size bytes starting at byte_offset.

Resizes the bin to byte_size bytes using resize_flags.

Returns the offset of the first bit matching value when scanning right to left.

Right shifts [bit_offset, bit_offset + bit_size) by shift bits.

Overwrites the bit region [bit_offset, bit_offset + bit_size) with bits from value.

Writes integer value into [bit_offset, bit_offset + bit_size).

Subtracts value from a sub-integer in the bitmap.

Only create the bit bin when it does not already exist.

Use default bit write behavior.

Do not fail the command when a bit operation is denied by write flags.

Commit other valid operations when this bit operation is denied by write flags.

Only update the bit bin when it already exists.

Types

flags()

@type flags() :: atom() | [atom()] | non_neg_integer() | {:raw, non_neg_integer()}

Bit operation write policy flags.

Accepts :default, :create_only, :update_only, :no_fail, :partial, or a list of those atoms. Compatibility callers may pass a non-negative integer; use {:raw, integer} when deliberately sending an unnamed server value.

opts()

@type opts() :: [
  ctx: Aerospike.Ctx.t(),
  flags: flags(),
  overflow_action: overflow_action(),
  signed: boolean()
]

Common bit operation options.

Supported keys:

  • :ctx - nested CDT context path from Aerospike.Ctx.
  • :flags - bit-operation write flags. Defaults to :default.
  • :overflow_action - overflow behavior for add/5 and subtract/5.
  • :signed - when true, adds the signed flag to :overflow_action.

overflow_action()

@type overflow_action() :: atom() | non_neg_integer() | {:raw, non_neg_integer()}

Overflow action for bit add/subtract operations.

Accepts :fail, :saturate, or :wrap. Compatibility callers may pass a non-negative integer; use {:raw, integer} when deliberately sending an unnamed server value. signed: true adds the signed flag before encoding.

resize_flags()

@type resize_flags() ::
  atom() | [atom()] | non_neg_integer() | {:raw, non_neg_integer()}

Resize flags for bit resize operations.

Accepts :default, :from_front, :grow_only, :shrink_only, or a list of those atoms. Compatibility callers may pass a non-negative integer; use {:raw, integer} when deliberately sending an unnamed server value.

t()

@opaque t()

Opaque bit operation for Aerospike.operate/4.

Functions

add(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec add(String.t(), integer(), integer(), integer(), opts()) :: t()

Adds value to a sub-integer in the bitmap.

Supports flags:, overflow_action:, and signed:. Use signed: true to OR the signed flag into overflow_action:.

bw_and(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec bw_and(String.t(), integer(), integer(), binary(), opts()) :: t()

Applies bitwise AND of value into [bit_offset, bit_offset + bit_size).

bw_not(bin_name, bit_offset, bit_size, opts \\ [])

@spec bw_not(String.t(), integer(), integer(), opts()) :: t()

Inverts [bit_offset, bit_offset + bit_size).

bw_or(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec bw_or(String.t(), integer(), integer(), binary(), opts()) :: t()

Applies bitwise OR of value into [bit_offset, bit_offset + bit_size).

bw_xor(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec bw_xor(String.t(), integer(), integer(), binary(), opts()) :: t()

Applies bitwise XOR of value into [bit_offset, bit_offset + bit_size).

count(bin_name, bit_offset, bit_size, opts \\ [])

@spec count(String.t(), integer(), integer(), opts()) :: t()

Returns the count of bits set to 1 in [bit_offset, bit_offset + bit_size).

get(bin_name, bit_offset, bit_size, opts \\ [])

@spec get(String.t(), integer(), integer(), opts()) :: t()

Returns bit_size bits starting at bit_offset as a binary.

get_int(bin_name, bit_offset, bit_size, signed \\ false, opts \\ [])

@spec get_int(String.t(), integer(), integer(), boolean(), opts()) :: t()

Reads an integer from [bit_offset, bit_offset + bit_size).

Pass true for signed to interpret the field as signed.

insert(bin_name, byte_offset, bytes, opts \\ [])

@spec insert(String.t(), integer(), binary(), opts()) :: t()

Inserts bytes at byte_offset in the bin.

lscan(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec lscan(String.t(), integer(), integer(), boolean(), opts()) :: t()

Returns the offset of the first bit matching value when scanning left to right.

lshift(bin_name, bit_offset, bit_size, shift, opts \\ [])

@spec lshift(String.t(), integer(), integer(), integer(), opts()) :: t()

Left shifts [bit_offset, bit_offset + bit_size) by shift bits.

overflow_fail()

@spec overflow_fail() :: 0

Fail bit add/subtract on overflow or underflow.

overflow_saturate()

@spec overflow_saturate() :: 2

Saturate bit add/subtract to min/max on overflow or underflow.

overflow_wrap()

@spec overflow_wrap() :: 4

Wrap bit add/subtract on overflow or underflow.

remove(bin_name, byte_offset, byte_size, opts \\ [])

@spec remove(String.t(), integer(), integer(), opts()) :: t()

Removes byte_size bytes starting at byte_offset.

resize(bin_name, byte_size, resize_flags \\ :default, opts \\ [])

@spec resize(String.t(), integer(), resize_flags(), opts()) :: t()

Resizes the bin to byte_size bytes using resize_flags.

rscan(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec rscan(String.t(), integer(), integer(), boolean(), opts()) :: t()

Returns the offset of the first bit matching value when scanning right to left.

rshift(bin_name, bit_offset, bit_size, shift, opts \\ [])

@spec rshift(String.t(), integer(), integer(), integer(), opts()) :: t()

Right shifts [bit_offset, bit_offset + bit_size) by shift bits.

set(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec set(String.t(), integer(), integer(), binary(), opts()) :: t()

Overwrites the bit region [bit_offset, bit_offset + bit_size) with bits from value.

set_int(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec set_int(String.t(), integer(), integer(), integer(), opts()) :: t()

Writes integer value into [bit_offset, bit_offset + bit_size).

subtract(bin_name, bit_offset, bit_size, value, opts \\ [])

@spec subtract(String.t(), integer(), integer(), integer(), opts()) :: t()

Subtracts value from a sub-integer in the bitmap.

Supports flags:, overflow_action:, and signed:. Use signed: true to OR the signed flag into overflow_action:.

write_create_only()

@spec write_create_only() :: 1

Only create the bit bin when it does not already exist.

write_default()

@spec write_default() :: 0

Use default bit write behavior.

write_no_fail()

@spec write_no_fail() :: 4

Do not fail the command when a bit operation is denied by write flags.

write_partial()

@spec write_partial() :: 8

Commit other valid operations when this bit operation is denied by write flags.

write_update_only()

@spec write_update_only() :: 2

Only update the bit bin when it already exists.