问题
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