gonedays50
gonedays50

Reputation: 3

java.lang.IllegalStateException: Must specify a valid bucketing strategy while requesting aggregation

I get this error while I am creating a read request object DataReadRequest class. I tried to look for the documentation but it is unclear. Here is my code:

 DataReadRequest readRequest = new DataReadRequest.Builder()
            .read(DataType.TYPE_LOCATION_SAMPLE)
            .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
            .bucketByTime(1, TimeUnit.HOURS)
            .build();

The error is in bucketByTime method and I don't know how to proceed.

Upvotes: 0

Views: 1467

Answers (1)

Matthew Woo
Matthew Woo

Reputation: 1378

I had this error before. The short answer is to remove the line

    .bucketByTime(1, TimeUnit.HOURS)

The reason why this does not work with your request is that the bucketByTime method aggregates data according to the period of time you're asking for, but the data you're requesting can't be aggregated (what does it mean to add together location samples??). In fact all the bucketing methods expect an aggregate data type because bucketing implies that you're trying to represent a number of data points as one data point.

Upvotes: 5

Related Questions