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

ぐ巨炮叔叔 提交于 2019-12-12 01:43:44

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/38608174/java-lang-illegalstateexception-must-specify-a-valid-bucketing-strategy-while-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!