Using > TicTac AAE Fold:
Get Object Statistics

Returns a count of objects that meet the filter parameters.

See the TicTac AAE aae_folds documentation for configuration, tuning and troubleshootings help.

The object_stats function

Run this using riak attach.

riak_client:aae_fold({
    object_stats,
    bucket_filter,
    key_range_filter,
    modified_filter
    }, Client).

Please see the list of available filters below.

For example, the following snippet will count all objects 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({
    object_stats,
    {<<"animals">>,<<"dogs">>},
    {<<"A">>,<<"N">>},
    {date,{{2022,1,1},{0,0,0}},{{2022,2,1},{0,0,0}}}
    }, Client).

How to get the value for Client is detailed in The Riak Client.

The response

The response will look something like this:

{ok,[{total_count,100},
     {total_size,500000},
     {sizes,[{1,91},{2,5},{3,4}]},
     {siblings,[{1,90},{2,6},{3,4}]}]}
Field Example Description
total_count {total_count,100} The total number of objects. In the example, 100 objects were found.
total_size {total_size,500000} The total size of all objects found in bytes. In the example, all found objects came to a total size of 500,000 bytes.
sizes {sizes,[{1,90},{2,5},{3,4}]} A set of tuples giving a histogram of object size. The first number in each tuple is the order of magnitude starting at 1=1KB (1024 bytes x 10^N). The second number is the number of objects of that magnitude. In the example, there are 90 objects under 1KB, 5 objects between 1KB and 10KB, and 4 objects between 10KB and 100KB.
siblings {siblings,[{1,90},{2,6},{3,4}]} A set of tuples giving the sibling count of objects. The first number in each tuple is the number of siblings. The second number in each tuple is the number of objects that have that many siblings. A sibling count of 1 means that there are no siblings (there is only 1 value). In the example, there are 90 objects with no siblings, 6 objects with 2 siblings, and 4 objects with 3 siblings.
object_size reference table

For quick reference, here is a table of magnitude and object size range for the first 10 orders of magnitude:

Magnitude Minimum (bytes) Maximum (bytes)
1 0 1024
2 1,025 10,240
3 10,241 102,400
4 102,401 1,024,000
5 1,024,001 10,240,000
6 10,240,001 102,400,000
7 102,400,001 1,024,000,000
8 1,024,000,001 10,240,000,000
9 10,240,000,001 102,400,000,000
10 102,400,000,001 1,024,000,000,000

Available filters

These filters are detailed in the Filters documentation and can be used to limit the keys counted.

These filters will reduce the keys to be searched:

These filters will reduce the number of objects included in the statistics: