Querying by metadata fields without full scan

query

#1

Hi, I’m trying to understand which records are going to be expired in the next x minutes. Is there a way to do it using the java client but not with predicate filters (I don’t want to do a full scan but only get the keys)?

In general, is there a way to query metadata fields with no disk access?

Thanks, Shelly


#2

Do you just need the count of records expiring in the next x minutes or their digest? (Aerospike does not store the key by default.) If you just need the count, nsup thread does a ttl histogram that you can query using asinfo. If you need the digests, then what do you plan to do with the digests? Are you going to read those records or modify them? Depending on what you are trying to do, there could be some options.

For a single record or a list of records [keys], you can query the metadata fields in Java with getHeader(). However the only metadata exposed back to the client is record generation and record expiration (ttl remaining).


#3

I’m trying to understand which records are going to be expired, for this I need only the record keys without the actual data. I think I found a way to do it: using predicate filter on field PredExp.recVoidTime() and set
queryPolicy.includeBinData = false queryPolicy.sendKey = true

This way there is no need to read the actual record but the filtering is still being done using the predicate filter. Am I right?


#4

Exactly correct. You use predicate filtering on the void time, but tell it to not send you the data, just the metadata.

Be aware that if you don’t store the key, and by default your write operations do not store the key, because it costs extra storage, then you only get back the digest, not the human-readable key. With the digest you can do something like touching the record to extend its TTL.

Depending on what you want to do with the returned data, you may need to store the key, or not. For pushing the expiration farther into the future you only need the digest.