diff --git a/grpc/src/main/protobuf/range_vector.proto b/grpc/src/main/protobuf/range_vector.proto index fc0a3272bc..376c515f6d 100644 --- a/grpc/src/main/protobuf/range_vector.proto +++ b/grpc/src/main/protobuf/range_vector.proto @@ -17,9 +17,9 @@ message SerializedRangeVector { message RepeatValueVector { RangeVectorKey key = 1; - repeated bytes recordContainers = 3; - RecordSchema recordSchema = 4; - optional RvRange rvRange = 5; + repeated bytes recordContainers = 2; + RecordSchema recordSchema = 3; + optional RvRange rvRange = 4; } diff --git a/query/src/test/scala/filodb/query/ProtoConvertersSpec.scala b/query/src/test/scala/filodb/query/ProtoConvertersSpec.scala index e7245e5ae8..30f0efb384 100644 --- a/query/src/test/scala/filodb/query/ProtoConvertersSpec.scala +++ b/query/src/test/scala/filodb/query/ProtoConvertersSpec.scala @@ -12,6 +12,7 @@ import filodb.core.metadata.Column import filodb.core.metadata.Column.ColumnType import filodb.grpc.{GrpcMultiPartitionQueryService, ProtoRangeVector} import filodb.memory.format.ZeroCopyUTF8String._ +import filodb.memory.format.vectors.{CustomBuckets, LongHistogram} class ProtoConvertersSpec extends AnyFunSpec with Matchers { @@ -733,4 +734,45 @@ class ProtoConvertersSpec extends AnyFunSpec with Matchers { deserializedise.getCause shouldEqual isecause } + + it("should convert RepeatValueVector double to proto and back") {2 + val recSchema = new RecordSchema(Seq(ColumnInfo("time", ColumnType.TimestampColumn), + ColumnInfo("value", ColumnType.DoubleColumn))) + val keysMap = Map("key1".utf8 -> "val1".utf8, + "key2".utf8 -> "val2".utf8) + val key = CustomRangeVectorKey(keysMap) + + val repeatValueVector = new RepeatValueVector(key, 100, 10, 600, + Some(new TransientRow(100, 599)), recSchema) + + val proto = repeatValueVector.toProto.fromProto + proto.key shouldEqual repeatValueVector.key + proto.numRows shouldEqual repeatValueVector.numRows + proto.outputRange shouldEqual repeatValueVector.outputRange + proto.rows().map(r => (r.getLong(0), r.getDouble(1))).toList shouldEqual + repeatValueVector.rows().map(r => (r.getLong(0), r.getDouble(1))).toList + proto.recordSchema shouldEqual repeatValueVector.recordSchema + } + + it("should convert RepeatValueVector histogram to proto and back") { + val recSchema = new RecordSchema(Seq(ColumnInfo("time", ColumnType.TimestampColumn), + ColumnInfo("value", ColumnType.HistogramColumn))) + + val customScheme = CustomBuckets(Array(0.25, 0.5, 1.0, 2.5, 5.0, 10, Double.PositiveInfinity)) + val longHist = LongHistogram(customScheme, Array[Long](10, 15, 17, 20, 25, 34, 76)) + + val keysMap = Map("key1".utf8 -> "val1".utf8, + "key2".utf8 -> "val2".utf8) + val key = CustomRangeVectorKey(keysMap) + + val repeatValueVector = new RepeatValueVector(key, 100, 10, 600, + Some(new TransientHistRow(40, longHist)), recSchema) + val proto = repeatValueVector.toProto.fromProto + proto.key shouldEqual repeatValueVector.key + proto.numRows shouldEqual repeatValueVector.numRows + proto.outputRange shouldEqual repeatValueVector.outputRange + proto.rows().map(r => (r.getLong(0), r.getHistogram(1))).toList shouldEqual + repeatValueVector.rows().map(r => (r.getLong(0), r.getHistogram(1))).toList + proto.recordSchema shouldEqual repeatValueVector.recordSchema + } }