Articles in this section

FAQ - Can I estimate the size of a bin in Java"

Detail

Depending on the use case, certain bins can start to grow in size over time such as when bins are using maps. In these cases, it may be useful to track this kind of growth for capacity planning or for monitoring purposes. Here we have an example of how to estimate the size of a bin in Java.

Note: This method produces an estimate size as it does not account for overhead.

Answer

Key key = new Key(params.namespace, params.set, "putgetkey");
Bin bin1 = new Bin("bin1", 1234567890);

client.put(params.writePolicy, key, bin1);

Record record = client.get(params.policy, key);
		
Value value1 = new Value.IntegerValue( record.getInt("bin1") );
console.info("%s estimateSize: %d", bin1, value1.estimateSize());

Notes

https://www.javadoc.io/static/com.aerospike/aerospike-client/8.0.0/com/aerospike/client/Bin.html
https://www.javadoc.io/static/com.aerospike/aerospike-client/8.0.0/com/aerospike/client/Value.html

Applies To Earliest Version

Pre 4.9

Applies To Latest Version

Current Version
Was this article helpful?
0 out of 0 found this helpful