Querying for multiple records following a pattern via java client

Suppose I have a set that is organized as follows


                                             Value
Mango_17-09-2015                17
Mango_18-09-2015                17
Mango_19-09-2015                20
Mango_20-09-2015                21
Apple_20-09-2015                21
Orange_20-09-2015                21

and I wish to know the number of mangoes I had between 18th and 20th of September. Is it possible to solve this problem in a single retrieval without the usage of UDFs?

Since your keys have a canonical naming scheme (but for the love of dog, use YYYY-MM-DD) you can batch-read Mango_2015-09-18, Mango_2015-09-19, Mango_2015-09-20 with the ‘Value’ bin selected as the only one you want, then sum the returned records ‘Value’ bins on the client-side. No need for a UDF or secondary index query.

See the Java API: BatchRead with specified binNames.

1 Like

Thanks @rbotzer. That was exactly what I was searching for :smile:

1 Like