Blob bin operations
Aerospike blob (bytes) bins support bitwise read and modify operations inside expressions (filters, operate pipelines, and policies that accept expression filters). Use them to read bit ranges, count or scan bits, resize or patch bytes, and apply bitwise math without round-tripping the whole blob to the client.
This reference lists each bit_ expression* (for example bit_get, bit_count, bit_set, bit_add) with multi-language examples. For the underlying datatype and non-expression APIs, see Blob (bytes).
Composing expressions
In each operation, the blob bin operand (blob_bin_expr in the argument tables) can be any blob-valued expression, not only Exp.blobBin(...). The bit_set reference includes an Example that uses BitExp.get on the result of BitExp.set—a read on a temporary blob after a modify. Many other modify (and some read) operations show similar composition: their examples nest another expression as the blob bin operand.
Modify
bit_add(policy, bit_offset, bit_size, value, action_flags, bin)Invokes the add operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
value | integer_expr |
action_flags | library_specific |
bin | blob_bin_expr |
blob_bin Filter where adding 1 to the unsigned 8-bit field at bit offset 16 (overflow FAIL) matches reading the next byte at offset 24.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitOverflowAction;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(16), Exp.val(8), BitExp.add( BitPolicy.Default, Exp.val(16), Exp.val(8), Exp.val(1), false, BitOverflowAction.FAIL, Exp.blobBin("device_flags"))), BitExp.get(Exp.val(24), Exp.val(8), Exp.blobBin("device_flags"))));import aerospikefrom aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitAdd, BitGet
b = BlobBin("device_flags")exp = Eq(BitGet(16, 8, BitAdd(None, 16, 8, 1, aerospike.BIT_OVERFLOW_FAIL, b)), BitGet(24, 8, b)).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(16), as_exp_int(8), as_exp_bit_add( NULL, as_exp_int(16), as_exp_int(8), as_exp_int(1), AS_BIT_OVERFLOW_FAIL, as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(24), as_exp_int(8), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(16), as.ExpIntVal(8), as.ExpBitAdd( as.DefaultBitPolicy(), as.ExpIntVal(16), as.ExpIntVal(8), as.ExpIntVal(1), false, as.BitOverflowActionFail, bin, ), ), as.ExpBitGet(as.ExpIntVal(24), as.ExpIntVal(8), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(16), Exp.Val(8), BitExp.Add( BitPolicy.Default, Exp.Val(16), Exp.Val(8), Exp.Val(1), false, BitOverflowAction.FAIL, Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(24), Exp.Val(8), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bits = Aerospike.bitwiseconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get( exp.bit.add(bin, bits.overflow.FAIL, exp.int(1), exp.int(8), exp.int(16)), exp.int(8), exp.int(16), ), exp.bit.get(bin, exp.int(8), exp.int(24)),)bit_and(policy, bit_offset, bit_size, value, bin)Invokes the and operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
value | blob_expr |
bin | blob_bin_expr |
blob_bin Filter where AND-ing bits 16–23 with 0x01 leaves the first byte unchanged.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(0), Exp.val(8), BitExp.and( BitPolicy.Default, Exp.val(16), Exp.val(8), Exp.val(new byte[] {0x01}), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(0), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitAnd, BitGet
b = BlobBin("device_flags")exp = Eq(BitGet(0, 8, BitAnd(None, 16, 8, bytearray([0x01]), b)), BitGet(0, 8, b)).compile()uint8_t v[] = {0x01};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(8), as_exp_bit_and( NULL, as_exp_int(16), as_exp_int(8), as_exp_bytes(v, sizeof(v)), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(0), as_exp_int(8), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBitAnd(as.DefaultBitPolicy(), as.ExpIntVal(16), as.ExpIntVal(8), as.ExpBlobVal([]byte{0x01}), bin), ), as.ExpBitGet(as.ExpIntVal(0), as.ExpIntVal(8), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(0), Exp.Val(8), BitExp.And( BitPolicy.Default, Exp.Val(16), Exp.Val(8), Exp.Val(new byte[] {0x01}), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(0), Exp.Val(8), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.and(bin, exp.bytes(Buffer.from([0x01])), exp.int(8), exp.int(16)), exp.int(8), exp.int(0)), exp.bit.get(bin, exp.int(8), exp.int(0)),)bit_insert(policy, bytes_offset, blob, bin)Invokes the insert operation.
| Name | Type |
|---|---|
policy | library_specific |
bytes_offset | integer_expr |
blob | blob_expr |
bin | blob_bin_expr |
blob_bin Filter where inserting 0xFF at byte offset 1 makes the unsigned 8-bit integer at bit offset 8 equal 0xFF.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.getInt( Exp.val(8), Exp.val(8), false, BitExp.insert( BitPolicy.Default, Exp.val(1), Exp.val(new byte[] {(byte) 0xff}), Exp.blobBin("device_flags"))), Exp.val(0xff)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGetInt, BitInsert
exp = Eq( BitGetInt(8, 8, False, BitInsert(None, 1, bytearray([0xFF]), BlobBin("device_flags"))), 0xFF,).compile()uint8_t ins[] = {0xff};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get_int( as_exp_int(8), as_exp_int(8), 0, as_exp_bit_insert( NULL, as_exp_int(1), as_exp_bytes(ins, sizeof(ins)), as_exp_bin_blob("device_flags"))), as_exp_int(0xff)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpBitGetInt( as.ExpIntVal(8), as.ExpIntVal(8), false, as.ExpBitInsert(as.DefaultBitPolicy(), as.ExpIntVal(1), as.ExpBlobVal([]byte{0xff}), as.ExpBlobBin("device_flags")), ), as.ExpIntVal(0xff),)Expression exp = Exp.Build( Exp.EQ( BitExp.GetInt( Exp.Val(8), Exp.Val(8), false, BitExp.Insert(BitPolicy.Default, Exp.Val(1), Exp.Val(new byte[] {0xFF}), Exp.BlobBin("device_flags"))), Exp.Val(0xFF)));const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.getInt( exp.bit.insert(exp.binBlob('device_flags'), exp.bytes(Buffer.from([0xff])), exp.int(1)), false, exp.int(8), exp.int(8), ), exp.int(0xff),)bit_lshift(policy, bit_offset, bit_size, shift_bit_count, bin)Invokes the lshift operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
shift_bit_count | integer_expr |
bin | blob_bin_expr |
blob_bin Filter where shifting the first byte left by two bits preserves the following six bits relative to the unmodified blob (TestBitExp pattern).
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(0), Exp.val(6), BitExp.lshift( BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(2), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(2), Exp.val(6), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitLeftShift
b = BlobBin("device_flags")exp = Eq(BitGet(0, 6, BitLeftShift(None, 0, 8, 2, b)), BitGet(2, 6, b)).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(6), as_exp_bit_lshift( NULL, as_exp_int(0), as_exp_int(8), as_exp_int(2), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(2), as_exp_int(6), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(6), as.ExpBitLShift(as.DefaultBitPolicy(), as.ExpIntVal(0), as.ExpIntVal(8), as.ExpIntVal(2), bin), ), as.ExpBitGet(as.ExpIntVal(2), as.ExpIntVal(6), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(0), Exp.Val(6), BitExp.Lshift( BitPolicy.Default, Exp.Val(0), Exp.Val(8), Exp.Val(2), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(2), Exp.Val(6), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.lShift(bin, exp.int(2), exp.int(6), exp.int(0)), exp.int(6), exp.int(0)), exp.bit.get(bin, exp.int(6), exp.int(2)),)bit_not(policy, bit_offset, bit_size, bin)Invokes the not operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
bin | blob_bin_expr |
blob_bin Filter where NOT-ing one bit at offset 6 makes the first byte match the original second byte (0x42).
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(0), Exp.val(8), BitExp.not(BitPolicy.Default, Exp.val(6), Exp.val(1), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitNot
b = BlobBin("device_flags")exp = Eq(BitGet(0, 8, BitNot(None, 6, 1, b)), BitGet(16, 8, b)).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(8), as_exp_bit_not(NULL, as_exp_int(6), as_exp_int(1), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(16), as_exp_int(8), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBitNot(as.DefaultBitPolicy(), as.ExpIntVal(6), as.ExpIntVal(1), bin), ), as.ExpBitGet(as.ExpIntVal(16), as.ExpIntVal(8), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(0), Exp.Val(8), BitExp.Not(BitPolicy.Default, Exp.Val(6), Exp.Val(1), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(16), Exp.Val(8), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.not(bin, exp.int(1), exp.int(6)), exp.int(8), exp.int(0)), exp.bit.get(bin, exp.int(8), exp.int(16)),)bit_or(policy, bit_offset, bit_size, value, bin)Invokes the or operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
value | blob_expr |
bin | blob_bin_expr |
blob_bin Filter where OR-ing 0x01 into bits 24–31 makes the 8-bit slice at offset 24 match the slice at offset 32.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(24), Exp.val(8), BitExp.or( BitPolicy.Default, Exp.val(24), Exp.val(8), Exp.val(new byte[] {0x01}), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(32), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitOr
b = BlobBin("device_flags")exp = Eq(BitGet(24, 8, BitOr(None, 24, 8, bytearray([0x01]), b)), BitGet(32, 8, b)).compile()uint8_t v[] = {0x01};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(24), as_exp_int(8), as_exp_bit_or( NULL, as_exp_int(24), as_exp_int(8), as_exp_bytes(v, sizeof(v)), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(32), as_exp_int(8), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBitOr(as.DefaultBitPolicy(), as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBlobVal([]byte{0x01}), bin), ), as.ExpBitGet(as.ExpIntVal(32), as.ExpIntVal(8), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(24), Exp.Val(8), BitExp.Or( BitPolicy.Default, Exp.Val(24), Exp.Val(8), Exp.Val(new byte[] {0x01}), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(32), Exp.Val(8), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.or(bin, exp.bytes(Buffer.from([0x01])), exp.int(8), exp.int(24)), exp.int(8), exp.int(24)), exp.bit.get(bin, exp.int(8), exp.int(32)),)bit_remove(policy, bytes_offset, byte_size, bin)Invokes the remove operation.
| Name | Type |
|---|---|
policy | library_specific |
bytes_offset | integer_expr |
byte_size | integer_expr |
bin | blob_bin_expr |
blob_bin Filter where removing the first byte leaves 0x42 as the unsigned 8-bit value at bit offset 0.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.getInt( Exp.val(0), Exp.val(8), false, BitExp.remove(BitPolicy.Default, Exp.val(0), Exp.val(1), Exp.blobBin("device_flags"))), Exp.val(0x42)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGetInt, BitRemove
exp = Eq(BitGetInt(0, 8, False, BitRemove(None, 0, 1, BlobBin("device_flags"))), 0x42).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get_int( as_exp_int(0), as_exp_int(8), 0, as_exp_bit_remove(NULL, as_exp_int(0), as_exp_int(1), as_exp_bin_blob("device_flags"))), as_exp_int(0x42)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpBitGetInt( as.ExpIntVal(0), as.ExpIntVal(8), false, as.ExpBitRemove(as.DefaultBitPolicy(), as.ExpIntVal(0), as.ExpIntVal(1), as.ExpBlobBin("device_flags")), ), as.ExpIntVal(0x42),)Expression exp = Exp.Build( Exp.EQ( BitExp.GetInt( Exp.Val(0), Exp.Val(8), false, BitExp.Remove(BitPolicy.Default, Exp.Val(0), Exp.Val(1), Exp.BlobBin("device_flags"))), Exp.Val(0x42)));const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.getInt( exp.bit.remove(exp.binBlob('device_flags'), exp.int(1), exp.int(0)), false, exp.int(8), exp.int(0), ), exp.int(0x42),)bit_resize(policy, bytes_size, flags, bin)Invokes the resize operation.
| Name | Type |
|---|---|
policy | library_specific |
bytes_size | integer_expr |
flags | library_specific |
bin | blob_bin_expr |
blob_bin Filter where the first byte after resizing device_flags to six bytes (default resize flags) is still 0x01 — modify expressions evaluate on a temporary blob value.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(0), Exp.val(8), BitExp.resize(BitPolicy.Default, Exp.val(6), 0, Exp.blobBin("device_flags"))), Exp.val(new byte[] {0x01})));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitResize
exp = Eq(BitGet(0, 8, BitResize(None, 6, 0, BlobBin("device_flags"))), bytearray([0x01])).compile()uint8_t want[] = {0x01};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(8), as_exp_bit_resize(NULL, as_exp_int(6), 0, as_exp_bin_blob("device_flags"))), as_exp_bytes(want, sizeof(want))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBitResize(as.DefaultBitPolicy(), as.ExpIntVal(6), as.BitResizeFlagsDefault, as.ExpBlobBin("device_flags")), ), as.ExpBlobVal([]byte{0x01}),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(0), Exp.Val(8), BitExp.Resize(BitPolicy.Default, Exp.Val(6), 0, Exp.BlobBin("device_flags"))), Exp.Val(new byte[] {0x01})));const exp = Aerospike.expconst bits = Aerospike.bitwise
const filterExp = exp.eq( exp.bit.get( exp.bit.reSize(exp.binBlob('device_flags'), bits.resizeFlags.DEFAULT, exp.int(6)), exp.int(8), exp.int(0), ), exp.bytes(Buffer.from([0x01])),)bit_rshift(policy, bit_offset, bit_size, shift_bit_count, bin)Invokes the rshift operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
shift_bit_count | integer_expr |
bin | blob_bin_expr |
blob_bin Filter where shifting bits 24–31 right by two leaves the following six bits unchanged relative to the original blob.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(26), Exp.val(6), BitExp.rshift( BitPolicy.Default, Exp.val(24), Exp.val(8), Exp.val(2), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(24), Exp.val(6), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitRightShift
b = BlobBin("device_flags")exp = Eq(BitGet(26, 6, BitRightShift(None, 24, 8, 2, b)), BitGet(24, 6, b)).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(26), as_exp_int(6), as_exp_bit_rshift( NULL, as_exp_int(24), as_exp_int(8), as_exp_int(2), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(24), as_exp_int(6), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(26), as.ExpIntVal(6), as.ExpBitRShift(as.DefaultBitPolicy(), as.ExpIntVal(24), as.ExpIntVal(8), as.ExpIntVal(2), bin), ), as.ExpBitGet(as.ExpIntVal(24), as.ExpIntVal(6), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(26), Exp.Val(6), BitExp.Rshift( BitPolicy.Default, Exp.Val(24), Exp.Val(8), Exp.Val(2), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(24), Exp.Val(6), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.rShift(bin, exp.int(2), exp.int(6), exp.int(24)), exp.int(6), exp.int(26)), exp.bit.get(bin, exp.int(6), exp.int(24)),)bit_set(policy, bit_offset, bit_size, value, bin)Invokes the set operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
value | blob_expr |
bin | blob_bin_expr |
blob_bin Filter where setting one bit at offset 31 makes the 8-bit slice at offset 24 match the original slice at offset 32.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(24), Exp.val(8), BitExp.set( BitPolicy.Default, Exp.val(31), Exp.val(1), Exp.val(new byte[] {(byte) 0x80}), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(32), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitSet
b = BlobBin("device_flags")exp = Eq( BitGet(24, 8, BitSet(None, 31, 1, bytearray([0x80]), b)), BitGet(32, 8, b),).compile()uint8_t v[] = {0x80};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(24), as_exp_int(8), as_exp_bit_set( NULL, as_exp_int(31), as_exp_int(1), as_exp_bytes(v, sizeof(v)), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(32), as_exp_int(8), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBitSet(as.DefaultBitPolicy(), as.ExpIntVal(31), as.ExpIntVal(1), as.ExpBlobVal([]byte{0x80}), bin), ), as.ExpBitGet(as.ExpIntVal(32), as.ExpIntVal(8), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(24), Exp.Val(8), BitExp.Set( BitPolicy.Default, Exp.Val(31), Exp.Val(1), Exp.Val(new byte[] {0x80}), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(32), Exp.Val(8), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.set(bin, exp.bytes(Buffer.from([0x80])), exp.int(1), exp.int(31)), exp.int(8), exp.int(24)), exp.bit.get(bin, exp.int(8), exp.int(32)),)bit_set_int(policy, bit_offset, bit_size, value, bin)Invokes the set_integer operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
value | integer_expr |
bin | blob_bin_expr |
blob_bin Filter where writing integer 0x42 into bits 24–31 makes that 8-bit slice match the original second byte of device_flags.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(24), Exp.val(8), BitExp.setInt( BitPolicy.Default, Exp.val(24), Exp.val(8), Exp.val(0x42), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(8), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitSetInt
b = BlobBin("device_flags")exp = Eq(BitGet(24, 8, BitSetInt(None, 24, 8, 0x42, b)), BitGet(8, 8, b)).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(24), as_exp_int(8), as_exp_bit_set_int( NULL, as_exp_int(24), as_exp_int(8), as_exp_int(0x42), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(8), as_exp_int(8), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBitSetInt(as.DefaultBitPolicy(), as.ExpIntVal(24), as.ExpIntVal(8), as.ExpIntVal(0x42), bin), ), as.ExpBitGet(as.ExpIntVal(8), as.ExpIntVal(8), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(24), Exp.Val(8), BitExp.SetInt( BitPolicy.Default, Exp.Val(24), Exp.Val(8), Exp.Val(0x42), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(8), Exp.Val(8), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.setInt(bin, exp.int(0x42), exp.int(8), exp.int(24)), exp.int(8), exp.int(24)), exp.bit.get(bin, exp.int(8), exp.int(8)),)bit_subtract(policy, bit_offset, bit_size, value, action_flags, bin)Invokes the subtract operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
value | integer_expr |
action_flags | library_specific |
bin | blob_bin_expr |
blob_bin Filter where subtracting 1 from the unsigned 8-bit field at bit offset 24 (overflow FAIL) matches the field at offset 16.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitOverflowAction;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(24), Exp.val(8), BitExp.subtract( BitPolicy.Default, Exp.val(24), Exp.val(8), Exp.val(1), false, BitOverflowAction.FAIL, Exp.blobBin("device_flags"))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin("device_flags"))));import aerospikefrom aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitSubtract
b = BlobBin("device_flags")exp = Eq(BitGet(24, 8, BitSubtract(None, 24, 8, 1, aerospike.BIT_OVERFLOW_FAIL, b)), BitGet(16, 8, b)).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(24), as_exp_int(8), as_exp_bit_subtract( NULL, as_exp_int(24), as_exp_int(8), as_exp_int(1), AS_BIT_OVERFLOW_FAIL, as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(16), as_exp_int(8), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBitSubtract( as.DefaultBitPolicy(), as.ExpIntVal(24), as.ExpIntVal(8), as.ExpIntVal(1), false, as.BitOverflowActionFail, bin, ), ), as.ExpBitGet(as.ExpIntVal(16), as.ExpIntVal(8), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(24), Exp.Val(8), BitExp.Subtract( BitPolicy.Default, Exp.Val(24), Exp.Val(8), Exp.Val(1), false, BitOverflowAction.FAIL, Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(16), Exp.Val(8), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bits = Aerospike.bitwiseconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get( exp.bit.subtract(bin, bits.overflow.FAIL, exp.int(1), exp.int(8), exp.int(24)), exp.int(8), exp.int(24), ), exp.bit.get(bin, exp.int(8), exp.int(16)),)bit_xor(policy, bit_offset, bit_size, value, bin)Invokes the xor operation.
| Name | Type |
|---|---|
policy | library_specific |
bit_offset | integer_expr |
bit_size | integer_expr |
value | blob_expr |
bin | blob_bin_expr |
blob_bin Filter where XOR-ing the first byte with 0x02 yields the same 8-bit slice as bits 16–23 of the original device_flags.
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(0), Exp.val(8), BitExp.xor( BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(new byte[] {0x02}), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitXor
b = BlobBin("device_flags")exp = Eq(BitGet(0, 8, BitXor(None, 0, 8, bytearray([0x02]), b)), BitGet(16, 8, b)).compile()uint8_t v[] = {0x02};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(8), as_exp_bit_xor( NULL, as_exp_int(0), as_exp_int(8), as_exp_bytes(v, sizeof(v)), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(16), as_exp_int(8), as_exp_bin_blob("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"bin := as.ExpBlobBin("device_flags")_ = as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBitXor(as.DefaultBitPolicy(), as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBlobVal([]byte{0x02}), bin), ), as.ExpBitGet(as.ExpIntVal(16), as.ExpIntVal(8), bin),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(0), Exp.Val(8), BitExp.Xor( BitPolicy.Default, Exp.Val(0), Exp.Val(8), Exp.Val(new byte[] {0x02}), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(16), Exp.Val(8), Exp.BlobBin("device_flags"))));const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.xor(bin, exp.bytes(Buffer.from([0x02])), exp.int(8), exp.int(0)), exp.int(8), exp.int(0)), exp.bit.get(bin, exp.int(8), exp.int(16)),)Read
bit_count(offset, bit_size, bin)Invokes the count operation.
| Name | Type |
|---|---|
offset | integer_expr |
bit_size | integer_expr |
bin | blob_bin_expr |
integer_bin Filter where the second byte of device_flags (bits 8–15) has more than one bit set (0x42 in the TestBitExp example pattern).
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.gt(BitExp.count(Exp.val(8), Exp.val(8), Exp.blobBin("device_flags")), Exp.val(1)));from aerospike_helpers.expressions import BlobBin, GTfrom aerospike_helpers.expressions.bitwise import BitCount
exp = GT(BitCount(8, 8, BlobBin("device_flags")), 1).compile()as_exp_build(predexp, as_exp_cmp_gt( as_exp_bit_count(as_exp_int(8), as_exp_int(8), as_exp_bin_blob("device_flags")), as_exp_int(1)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpGreater( as.ExpBitCount(as.ExpIntVal(8), as.ExpIntVal(8), as.ExpBlobBin("device_flags")), as.ExpIntVal(1),)Expression exp = Exp.Build( Exp.GT(BitExp.Count(Exp.Val(8), Exp.Val(8), Exp.BlobBin("device_flags")), Exp.Val(1)));const exp = Aerospike.exp
const filterExp = exp.gt( exp.bit.count(exp.binBlob('device_flags'), exp.int(8), exp.int(8)), exp.int(1),)bit_get(offset, bit_size, bin)Invokes the get operation.
| Name | Type |
|---|---|
offset | integer_expr |
bit_size | integer_expr |
bin | blob_bin_expr |
blob_bin Filter where bits 16–23 of blob bin device_flags read as one byte equal 0x03 (example layout matches Aerospike client TestBitExp five-byte pattern 01 42 03 04 05).
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin("device_flags")), Exp.val(new byte[] {0x03})));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet
exp = Eq(BitGet(16, 8, BlobBin("device_flags")), bytearray([0x03])).compile()uint8_t want[] = {0x03};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get(as_exp_int(16), as_exp_int(8), as_exp_bin_blob("device_flags")), as_exp_bytes(want, sizeof(want))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpBitGet(as.ExpIntVal(16), as.ExpIntVal(8), as.ExpBlobBin("device_flags")), as.ExpBlobVal([]byte{0x03}),)Expression exp = Exp.Build( Exp.EQ( BitExp.Get(Exp.Val(16), Exp.Val(8), Exp.BlobBin("device_flags")), Exp.Val(new byte[] {0x03})));const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.get(exp.binBlob('device_flags'), exp.int(8), exp.int(16)), exp.bytes(Buffer.from([0x03])),)bit_get_int(offset, bit_size, is_signed, bin)Invokes the get_integer operation.
| Name | Type |
|---|---|
offset | integer_expr |
bit_size | integer_expr |
is_signed | boolean_value |
bin | blob_bin_expr |
integer_bin Filter where the signed 8-bit integer at bit offset 32 in device_flags equals 5 (fifth byte 0x05 in the TestBitExp pattern).
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.getInt(Exp.val(32), Exp.val(8), true, Exp.blobBin("device_flags")), Exp.val(5)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGetInt
exp = Eq(BitGetInt(32, 8, True, BlobBin("device_flags")), 5).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get_int(as_exp_int(32), as_exp_int(8), 1, as_exp_bin_blob("device_flags")), as_exp_int(5)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpBitGetInt(as.ExpIntVal(32), as.ExpIntVal(8), true, as.ExpBlobBin("device_flags")), as.ExpIntVal(5),)Expression exp = Exp.Build( Exp.EQ( BitExp.GetInt(Exp.Val(32), Exp.Val(8), true, Exp.BlobBin("device_flags")), Exp.Val(5)));const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.getInt(exp.binBlob('device_flags'), true, exp.int(8), exp.int(32)), exp.int(5),)bit_lscan(offset, bit_size, value, bin)Invokes the lscan operation.
| Name | Type |
|---|---|
offset | integer_expr |
bit_size | integer_expr |
value | boolean_expr |
bin | blob_bin_expr |
integer_bin Filter where a left scan for a set bit in the fourth byte of device_flags (bits 32–39) returns index 5 (TestBitExp pattern).
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.lscan(Exp.val(32), Exp.val(8), Exp.val(true), Exp.blobBin("device_flags")), Exp.val(5)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitLeftScan
exp = Eq(BitLeftScan(32, 8, True, BlobBin("device_flags")), 5).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_lscan( as_exp_int(32), as_exp_int(8), as_exp_bool(true), as_exp_bin_blob("device_flags")), as_exp_int(5)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpBitLScan(as.ExpIntVal(32), as.ExpIntVal(8), as.ExpBoolVal(true), as.ExpBlobBin("device_flags")), as.ExpIntVal(5),)Expression exp = Exp.Build( Exp.EQ( BitExp.Lscan(Exp.Val(32), Exp.Val(8), Exp.Val(true), Exp.BlobBin("device_flags")), Exp.Val(5)));const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.lScan(exp.binBlob('device_flags'), exp.bool(true), exp.int(8), exp.int(32)), exp.int(5),)bit_rscan(offset, bit_size, value, bin)Invokes the rscan operation.
| Name | Type |
|---|---|
offset | integer_expr |
bit_size | integer_expr |
value | boolean_expr |
bin | blob_bin_expr |
integer_bin Filter where a right scan for a set bit in the fourth byte of device_flags returns index 7 (TestBitExp pattern).
import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.rscan(Exp.val(32), Exp.val(8), Exp.val(true), Exp.blobBin("device_flags")), Exp.val(7)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitRightScan
exp = Eq(BitRightScan(32, 8, True, BlobBin("device_flags")), 7).compile()as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_rscan( as_exp_int(32), as_exp_int(8), as_exp_bool(true), as_exp_bin_blob("device_flags")), as_exp_int(7)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpBitRScan(as.ExpIntVal(32), as.ExpIntVal(8), as.ExpBoolVal(true), as.ExpBlobBin("device_flags")), as.ExpIntVal(7),)Expression exp = Exp.Build( Exp.EQ( BitExp.Rscan(Exp.Val(32), Exp.Val(8), Exp.Val(true), Exp.BlobBin("device_flags")), Exp.Val(7)));const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.rScan(exp.binBlob('device_flags'), exp.bool(true), exp.int(8), exp.int(32)), exp.int(7),)