diff --git a/memory/src/main/scala/filodb.memory/format/vectors/Histogram.scala b/memory/src/main/scala/filodb.memory/format/vectors/Histogram.scala index 53a803a0c..d1ba20463 100644 --- a/memory/src/main/scala/filodb.memory/format/vectors/Histogram.scala +++ b/memory/src/main/scala/filodb.memory/format/vectors/Histogram.scala @@ -83,7 +83,7 @@ trait Histogram extends Ordered[Histogram] { // now calculate quantile. If bucket is last one and last bucket is +Inf then return second-to-last bucket top // as we cannot interpolate to +Inf. - if (bucket == numBuckets-1 && bucketTop(numBuckets - 1).isPosInfinity) { + if (bucket == numBuckets-1 && bucketEnd.isPosInfinity) { return bucketTop(numBuckets-2) } else if (bucket == 0 && bucketTop(0) <= 0) { return bucketTop(0) // zero or negative bucket diff --git a/query/src/main/scala/filodb/query/exec/rangefn/AggrOverTimeFunctions.scala b/query/src/main/scala/filodb/query/exec/rangefn/AggrOverTimeFunctions.scala index 9ee5dff50..ff39cbff2 100644 --- a/query/src/main/scala/filodb/query/exec/rangefn/AggrOverTimeFunctions.scala +++ b/query/src/main/scala/filodb/query/exec/rangefn/AggrOverTimeFunctions.scala @@ -390,7 +390,7 @@ class RateAndMinMaxOverTimeFuncHD(maxColId: Int, minColId: Int) extends ChunkedR def addChunks(tsVectorAcc: MemoryReader, tsVector: BinaryVectorPtr, tsReader: bv.LongVectorDataReader, valueVectorAcc: MemoryReader, valueVector: BinaryVectorPtr, valueReader: VectorDataReader, startTime: Long, endTime: Long, info: ChunkSetInfoReader, queryConfig: QueryConfig): Unit = { - // Do BinarySearch for start/end pos only once for both columns == WIN! + // Do BinarySearch for start/end pos only once for all columns == WIN! val startRowNum = tsReader.binarySearch(tsVectorAcc, tsVector, startTime) & 0x7fffffff val endRowNum = Math.min(tsReader.ceilingIndex(tsVectorAcc, tsVector, endTime), info.numRows - 1) @@ -403,7 +403,7 @@ class RateAndMinMaxOverTimeFuncHD(maxColId: Int, minColId: Int) extends ChunkedR val maxVectPtr = info.vectorAddress(maxColId) maxFunc.addTimeChunks(maxVectAcc, maxVectPtr, bv.DoubleVector(maxVectAcc, maxVectPtr), startRowNum, endRowNum) - // Get valueVector/reader for max column + // Get valueVector/reader for min column val minVectAcc = info.vectorAccessor(minColId) val minVectPtr = info.vectorAddress(minColId) minFunc.addTimeChunks(minVectAcc, minVectPtr, bv.DoubleVector(minVectAcc, minVectPtr), startRowNum, endRowNum)