Record storage
Record storage expressions read user data from bins and from the primary key as typed values: integers, floats, strings, blobs, GeoJSON, lists, maps, HyperLogLogs, and particle types. They are the building blocks for comparison and logic filters, for list, map, and HLL CDT expressions (where you pass a typed bin into ListExp / MapExp / HLLExp), and for path-based filters on nested data.
If the bin is missing or the type does not match, the expression evaluates to unknown (see the expressions overview execution model). For record keys, use the key-type expression that matches how the key was written (integer, string, or blob).
Typed bin readers (bin_int, bin_list, …) pair naturally with the same naming and scenarios as the bookstore / catalog examples elsewhere in this guide.
Ops
bin_blob(name)Retrieve the bin with the name indicated by name as a blob_bin. Return unknown if the bin does not exist or the bin is a different type.
| Name | Type |
|---|---|
name | string_value |
blob_bin Records where blob bin checksum matches a 3-byte prefix (example digest bytes).
Expression exp = Exp.build( Exp.eq( Exp.blobBin("checksum"), Exp.val(new byte[] { 0x01, 0x02, 0x03 })));from aerospike_helpers.expressions import BlobBin, Eq
exp = Eq(BlobBin("checksum"), bytearray([0x01, 0x02, 0x03])).compile()uint8_t chk[] = { 0x01, 0x02, 0x03 };as_exp_build(predexp, as_exp_cmp_eq( as_exp_bin_blob("checksum"), as_exp_bytes(chk, sizeof(chk))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpBlobBin("checksum"), as.ExpBlobVal([]byte{0x01, 0x02, 0x03}),)Expression exp = Exp.Build( Exp.EQ(Exp.BlobBin("checksum"), Exp.Val(new byte[] { 0x01, 0x02, 0x03 })));const exp = Aerospike.exp
const filterExp = exp.eq( exp.binBlob('checksum'), exp.bytes(Buffer.from([0x01, 0x02, 0x03])),)bin_exists(name)Returns true if a bin exists on the record with the name indicated by name, otherwise returns unknown.
| Name | Type |
|---|---|
name | string_value |
boolean_value Filter to records that have a quantity bin (any type).
Expression exp = Exp.build(Exp.binExists("quantity"));from aerospike_helpers.expressions import BinExists
exp = BinExists("quantity").compile()as_exp_build(predexp, as_exp_bin_exists("quantity"));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpBinExists("quantity")Expression exp = Exp.Build(Exp.BinExists("quantity"));const exp = Aerospike.exp
const filterExp = exp.binExists('quantity')bin_float(name)Retrieve the bin with the name indicated by name as a float_bin. Return unknown if the bin does not exist or the bin is a different type.
| Name | Type |
|---|---|
name | string_value |
float_bin Records where float bin list_price is under 15 (bookstore-style pricing).
Expression exp = Exp.build( Exp.lt(Exp.floatBin("list_price"), Exp.val(15.0)));from aerospike_helpers.expressions import FloatBin, LT
exp = LT(FloatBin("list_price"), 15.0).compile()as_exp_build(predexp, as_exp_cmp_lt(as_exp_bin_float("list_price"), as_exp_float(15.0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpLess(as.ExpFloatBin("list_price"), as.ExpFloatVal(15.0))Expression exp = Exp.Build( Exp.LT(Exp.FloatBin("list_price"), Exp.Val(15.0)));const exp = Aerospike.exp
const filterExp = exp.lt(exp.binFloat('list_price'), exp.float(15.0))bin_geo(name)Retrieve the bin with the name indicated by name as a geojson_bin. Return unknown if the bin does not exist or the bin is a different type.
| Name | Type |
|---|---|
name | string_value |
geojson_bin Records whose GeoJSON bin region contains the given point (same pattern as cmp_geo).
String point = "{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}";Expression exp = Exp.build( Exp.geoCompare(Exp.geo(point), Exp.geoBin("region")));import aerospikefrom aerospike_helpers.expressions import CmpGeo, GeoBin
point = aerospike.GeoJSON( '{"type":"Point","coordinates":[-122.4,37.8]}')exp = CmpGeo(point, GeoBin("region")).compile()as_exp_build(predexp, as_exp_cmp_geo( as_exp_geo("{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}"), as_exp_bin_geo("region")));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"point := "{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}"_ = as.ExpGeoCompare(as.ExpGeoVal(point), as.ExpGeoBin("region"))string point = "{\"type\":\"Point\",\"coordinates\":[-122.4,37.8]}";Expression exp = Exp.Build( Exp.GeoCompare(Exp.Geo(point), Exp.GeoBin("region")));const exp = Aerospike.exp
const filterExp = exp.cmpGeo( exp.geo({ type: 'Point', coordinates: [-122.4, 37.8] }), exp.binGeo('region'),)bin_hll(name)Retrieve the bin with the name indicated by name as a hll_bin. Return unknown if the bin does not exist or the bin is a different type.
| Name | Type |
|---|---|
name | string_value |
hll_bin Records where HLL bin visitors has a non-zero estimated cardinality, using HLLExp.getCount on the typed HLL bin.
import com.aerospike.client.exp.HLLExp;
Expression exp = Exp.build( Exp.gt(HLLExp.getCount(Exp.hllBin("visitors")), Exp.val(0)));from aerospike_helpers.expressions import GT, HLLBinfrom aerospike_helpers.expressions.hll import HLLGetCount
exp = GT(HLLGetCount(HLLBin("visitors")), 0).compile()as_exp_build(predexp, as_exp_cmp_gt( as_exp_hll_get_count(as_exp_bin_hll("visitors")), as_exp_int(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpGreater( as.ExpHLLGetCount(as.ExpHLLBin("visitors")), as.ExpIntVal(0),)Expression exp = Exp.Build( Exp.GT(HLLExp.GetCount(Exp.HLLBin("visitors")), Exp.Val(0)));const exp = Aerospike.exp
const filterExp = exp.gt( exp.hll.getCount(exp.binHll('visitors')), exp.int(0),)bin_int(name)Retrieve the bin with the name indicated by name as a integer_bin. Return unknown if the bin does not exist or the bin is a different type.
| Name | Type |
|---|---|
name | string_value |
integer_bin Records where integer bin quantity is in stock (greater than zero).
Expression exp = Exp.build( Exp.gt(Exp.intBin("quantity"), Exp.val(0)));from aerospike_helpers.expressions import GT, IntBin
exp = GT(IntBin("quantity"), 0).compile()as_exp_build(predexp, as_exp_cmp_gt(as_exp_bin_int("quantity"), as_exp_int(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpGreater(as.ExpIntBin("quantity"), as.ExpIntVal(0))Expression exp = Exp.Build( Exp.GT(Exp.IntBin("quantity"), Exp.Val(0)));const exp = Aerospike.exp
const filterExp = exp.gt(exp.binInt('quantity'), exp.int(0))bin_list(name)Retrieve the bin with the name indicated by name as a list_bin. Return unknown if the bin does not exist or the bin is a different type.
| Name | Type |
|---|---|
name | string_value |
list_bin Records where list bin tags is non-empty, using the list bin value with a list read expression (size).
import com.aerospike.client.exp.ListExp;
Expression exp = Exp.build( Exp.gt(ListExp.size(Exp.listBin("tags")), Exp.val(0)));from aerospike_helpers.expressions import GT, ListBinfrom aerospike_helpers.expressions.list import ListSize
exp = GT(ListSize(None, ListBin("tags")), 0).compile()as_exp_build(predexp, as_exp_cmp_gt( as_exp_list_size(NULL, as_exp_bin_list("tags")), as_exp_int(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpGreater( as.ExpListSize(as.ExpListBin("tags")), as.ExpIntVal(0),)Expression exp = Exp.Build( Exp.GT(ListExp.Size(Exp.ListBin("tags")), Exp.Val(0)));const exp = Aerospike.exp
const filterExp = exp.gt( exp.lists.size(exp.binList('tags')), exp.int(0),)bin_map(name)Retrieve the bin with the name indicated by name as a map_bin. Return unknown if the bin does not exist or the bin is a different type.
| Name | Type |
|---|---|
name | string_value |
map_bin Records where map bin attrs has at least one entry, using MapExp.size on the typed map bin.
import com.aerospike.client.exp.MapExp;
Expression exp = Exp.build( Exp.gt(MapExp.size(Exp.mapBin("attrs")), Exp.val(0)));from aerospike_helpers.expressions import GT, MapBinfrom aerospike_helpers.expressions.map import MapSize
exp = GT(MapSize(None, MapBin("attrs")), 0).compile()as_exp_build(predexp, as_exp_cmp_gt( as_exp_map_size(NULL, as_exp_bin_map("attrs")), as_exp_int(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpGreater( as.ExpMapSize(as.ExpMapBin("attrs")), as.ExpIntVal(0),)Expression exp = Exp.Build( Exp.GT(MapExp.Size(Exp.MapBin("attrs")), Exp.Val(0)));const exp = Aerospike.exp
const filterExp = exp.gt( exp.maps.size(exp.binMap('attrs')), exp.int(0),)bin_str(name)Retrieve the bin with the name indicated by name as a string_bin. Return unknown if the bin does not exist or the bin is a different type.
| Name | Type |
|---|---|
name | string_value |
string_bin Records in the fiction category (string bin category).
Expression exp = Exp.build( Exp.eq(Exp.stringBin("category"), Exp.val("fiction")));from aerospike_helpers.expressions import Eq, StrBin
exp = Eq(StrBin("category"), "fiction").compile()as_exp_build(predexp, as_exp_cmp_eq(as_exp_bin_str("category"), as_exp_str("fiction")));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq(as.ExpStringBin("category"), as.ExpStringVal("fiction"))Expression exp = Exp.Build( Exp.EQ(Exp.StringBin("category"), Exp.Val("fiction")));const exp = Aerospike.exp
const filterExp = exp.eq(exp.binStr('category'), exp.str('fiction'))bin_type(name)Retrieve the data type of the bin with the name indicated by name in ParticleType format. Return unknown if the bin does not exist.
The following list shows each bin ParticleType and its associated integer value:
NULL: 0
INTEGER: 1
DOUBLE: 2
STRING: 3
BLOB: 4
JBLOB: 7
BOOL: 17
HLL: 18
MAP: 19
LIST: 20
GEOJSON: 23
| Name | Type |
|---|---|
name | string_value |
ParticleType Filter to records whose sku bin is stored as a string (see ParticleType).
import com.aerospike.client.command.ParticleType;
Expression exp = Exp.build( Exp.eq(Exp.binType("sku"), Exp.val(ParticleType.STRING)));import aerospikefrom aerospike_helpers.expressions import BinType, Eq
exp = Eq(BinType("sku"), aerospike.AS_BYTES_STRING).compile()as_exp_build(predexp, as_exp_cmp_eq(as_exp_bin_type("sku"), as_exp_int(AS_BYTES_STRING)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"// ParticleType.STRING == 3 (see ExpBinType godoc)._ = as.ExpEq(as.ExpBinType("sku"), as.ExpIntVal(3))Expression exp = Exp.Build( Exp.EQ(Exp.BinType("sku"), Exp.Val((long)ParticleType.STRING)));const exp = Aerospike.exp
const filterExp = exp.eq(exp.binType('sku'), exp.int(3))key_blob()Retrieve the key as a blob/bytes. Return unknown if the key does not exist or the key is a different type.
blob_value Records whose blob user key matches a short byte sequence (for example a binary id).
Expression exp = Exp.build( Exp.eq(Exp.key(Exp.Type.BLOB), Exp.val(new byte[] { 0x10, 0x20 })));from aerospike_helpers.expressions import Eq, KeyBlob
exp = Eq(KeyBlob(), bytearray([0x10, 0x20])).compile()uint8_t id[] = { 0x10, 0x20 };as_exp_build(predexp, as_exp_cmp_eq(as_exp_key_blob(), as_exp_bytes(id, sizeof(id))));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq( as.ExpKey(as.ExpTypeBLOB), as.ExpBlobVal([]byte{0x10, 0x20}),)Expression exp = Exp.Build( Exp.EQ(Exp.Key(Exp.Type.BLOB), Exp.Val(new byte[] { 0x10, 0x20 })));const exp = Aerospike.exp
const filterExp = exp.eq( exp.keyBlob(), exp.bytes(Buffer.from([0x10, 0x20])),)key_int()Retrieve the key as a integer. Return unknown if the key does not exist or the key is a different type.
integer_value Records whose integer user key is at least 1000 (same units as the key type).
Expression exp = Exp.build( Exp.ge(Exp.key(Exp.Type.INT), Exp.val(1000)));from aerospike_helpers.expressions import GE, KeyInt
exp = GE(KeyInt(), 1000).compile()as_exp_build(predexp, as_exp_cmp_ge(as_exp_key_int(), as_exp_int(1000)));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpGreaterEq(as.ExpKey(as.ExpTypeINT), as.ExpIntVal(1000))Expression exp = Exp.Build( Exp.GE(Exp.Key(Exp.Type.INT), Exp.Val(1000)));const exp = Aerospike.exp
const filterExp = exp.ge(exp.keyInt(), exp.int(1000))key_str()Retrieve the key as a string. Return unknown if the key does not exist or the key is a different type.
string_value Records whose string user key is order-42.
Expression exp = Exp.build( Exp.eq(Exp.key(Exp.Type.STRING), Exp.val("order-42")));from aerospike_helpers.expressions import Eq, KeyStr
exp = Eq(KeyStr(), "order-42").compile()as_exp_build(predexp, as_exp_cmp_eq(as_exp_key_str(), as_exp_str("order-42")));// Requires: import as "github.com/aerospike/aerospike-client-go/v6"_ = as.ExpEq(as.ExpKey(as.ExpTypeSTRING), as.ExpStringVal("order-42"))Expression exp = Exp.Build( Exp.EQ(Exp.Key(Exp.Type.STRING), Exp.Val("order-42")));const exp = Aerospike.exp
const filterExp = exp.eq(exp.keyStr(), exp.str('order-42'))