Search code examples
javaaerospike

How to get the size of a bin in Aerospike?


In aerospike, when we do show sets we see something like:

+------------------+--------+---------+-------------------+------------+-------------------+-------------------+----------------+------------+
| disable-eviction | ns     | objects | stop-writes-count | set        | memory_data_bytes | device_data_bytes | truncate_lut   | tombstones |
+------------------+--------+---------+-------------------+------------+-------------------+-------------------+----------------+------------+
| "false"          | "test" | "310"   | "0"               | "byteData" | "25663706"        | "25680736"        | "358239062044" | "0"        |
| "false"          | "test" | "310"   | "0"               | "kwString" | "1076835"         | "1092352"         | "0"            | "0"        |
+------------------+--------+---------+-------------------+------------+-------------------+-------------------+----------------+------------+

This gives us an idea that the set byteData occupies around 25MB. Now, assume that the set byteData has two bins viz. binA and binB, then how can I get the sizes of the two bins?


Solution

  • Aerospike stores records - each record can have set name as a tag or metadata, and it can store bins. Schema is at record level and it will be whatever the user creates on a per record basis. So estimating "size of a bin in a set" is kind of a wrong ask. For example, in namespace n1, in set s1, I can add two records r1 and r2. r1 can have bins b1 and c1 and r2 can have bins b2 and c2. b1, c1, b2, c2 can be completely different datatypes from each other. Now, practically speaking, in a given set, a user will follow some kind of like schema across all records.

    You can calculate the size of any record, including overhead, based on the data you are storing. See this link for details: https://docs.aerospike.com/docs/operations/plan/capacity/index.html but directly getting "size of a bin in a set" from Aerospike is not possible.