ankitsultana commented on code in PR #14048: URL: https://github.com/apache/pinot/pull/14048#discussion_r1772526805
########## pinot-plugins/pinot-timeseries-lang/pinot-timeseries-m3ql/src/main/java/org/apache/pinot/tsdb/m3ql/time/TimeBucketComputer.java: ########## @@ -0,0 +1,79 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.tsdb.m3ql.time; + +import java.time.Duration; +import java.util.Collection; +import org.apache.pinot.tsdb.spi.RangeTimeSeriesRequest; +import org.apache.pinot.tsdb.spi.TimeBuckets; +import org.apache.pinot.tsdb.spi.plan.BaseTimeSeriesPlanNode; +import org.apache.pinot.tsdb.spi.plan.ScanFilterAndProjectPlanNode; + + +public class TimeBucketComputer { + private TimeBucketComputer() { + } + + public static TimeBuckets compute(BaseTimeSeriesPlanNode planNode, RangeTimeSeriesRequest request) { + QueryTimeBoundaryConstraints constraints = process(planNode, request); + long newStartTime = request.getStartSeconds() - constraints.getLeftExtensionSeconds(); Review Comment: So M3 has functions like "moving 10m sum", "summarize 1h sum", etc. For the moving case, say the time range the user requested was (now() - 5 minutes, now()). To make sure the results are correct, we actually need to create time-buckets from (now() - 15 minutes, now()), and we can then trim the time-buckets again before returning the response to the user. That's the role of "left extension seconds". Additionally, I have some divisibility logic which makes sures that the range the time buckets represent can be quantized into the lcm of the time-range the query is computing at. e.g. if I am doing a "summarize 1h sum", then the total time range in the generated time buckets should be divisible by 1h, otherwise our results will be partial at the edges and in some cases the query could even fail. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org