ankitsultana commented on code in PR #14611: URL: https://github.com/apache/pinot/pull/14611#discussion_r1876552233
########## pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/timeseries/serde/TimeSeriesBlockSerde.java: ########## @@ -0,0 +1,203 @@ +/** + * 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.query.runtime.timeseries.serde; + +import com.google.common.base.Preconditions; +import com.google.protobuf.ByteString; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.time.Duration; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.apache.pinot.common.datablock.DataBlock; +import org.apache.pinot.common.datablock.DataBlockUtils; +import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.common.utils.DataSchema.ColumnDataType; +import org.apache.pinot.query.runtime.blocks.TransferableBlock; +import org.apache.pinot.query.runtime.blocks.TransferableBlockUtils; +import org.apache.pinot.tsdb.spi.TimeBuckets; +import org.apache.pinot.tsdb.spi.series.TimeSeries; +import org.apache.pinot.tsdb.spi.series.TimeSeriesBlock; + + +/** + * Implements a simple Serde mechanism for the Time Series Block. This is used for transferring data between servers + * and brokers. The approach is to use a {@link TransferableBlock} and rely on the existing serialization code to avoid + * re-inventing the wheel. Once the time-series engine coalesces with the Multistage Engine, we will anyway use + * TransferableBlock for data transfers. + * <p> + * The {@link TimeSeriesBlock} is converted to and from a table, where the first row contains information about the + * time-buckets. For each tag/label in the query, there's a dedicated column, and the Double values are stored in + * the last column. As an example, consider the following, where FBV represents the first bucket value of TimeBuckets. + * <pre> + * +-------------+------------+-------------+---------------------------------+ + * | tag-0 | tag-1 | tag-n | values | + * +-------------+------------+-------------+---------------------------------+ + * | null | null | null | [FBV, bucketSize, numBuckets] | + * +-------------+------------+-------------+---------------------------------+ + * | Chicago | 60607 | ... | [value-0, value-1, ... value-x] | + * +-------------+------------+-------------+---------------------------------+ + * | San Fran. | 94107 | ... | [value-0, value-1, ... value-x] | + * +-------------+------------+-------------+---------------------------------+ + * </pre> Review Comment: Using json for storage is fine. This serde is only applicable for queries. If I had to guess, you are using some JSON Transform function in the `groupByExpressions` to extract out the appropriate keys and values. That case is handled by this Serde, because each Group By Expression will become a column. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
