Using > TicTac AAE Fold:
Count Keys
Counts keys that meet the filter parameters.
See the TicTac AAE aae_folds documentation for configuration, tuning and troubleshootings help.
This function allows you to count how many keys would be deleted in a single pass based on the supplied filters. It does not actually delete the keys. Manual dev ops intervention using this function is required.
Use the erase_keys function to count the keys that would be deleted.
If you need to find keys with more specific properties, you can also use the Object Statistics function.
The erase_keys function
Run this using riak attach.
This function has three available operational methods that are selected via the method value. The count method for counting keys is detailed below. The general format for the function is:
riak_client:aae_fold({
erase_keys,
bucket_filter,
key_range_filter,
segment_filter
modified_filter,
method
}, Client).
Please see the list of available filters below.
methodsThere are two other methods, local and job:
localis used to delete the keys (see Erase Keys for more information).jobis used internally by TicTac AAE. Do not use it unless you know what you are doing.
How to get the value for Client is detailed in The Riak Client.
The count method
Returns a count of keys that meet the filter parameters. Does NOT delete the keys.
riak_client:aae_fold({
erase_keys,
bucket_filter,
key_range_filter,
segment_filter
modified_filter,
count
}, Client).
Please see the list of available filters below.
For example, the following snippet will count all keys that would be deleted with the filters:
- in the bucket “dogs” of bucket type “animals”
- whose keys are between “A” and “N”
- which were modified in January 2022
riak_client:aae_fold({
erase_keys,
{<<"animals">>,<<"dogs">>},
{<<"A">>,<<"N">>},
all,
{date,{{2022,1,1},{0,0,0}},{{2022,2,1},{0,0,0}}},
count
}, Client).
The response for the count method
The response will look something like this:
{ok,5}
This indicates that 5 keys were found meeting the filter parameters.
Available filters
These filters are detailed in the Filters documentation and can be used to limit the keys considered for counting.
These filters will reduce the number of keys to be searched:
These filters will reduce the number of keys considered for counting:
