weixiangsun commented on a change in pull request #8029: URL: https://github.com/apache/pinot/pull/8029#discussion_r829478960
########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/ColumnDataToBlockValSetConverter.java ########## @@ -0,0 +1,181 @@ +/** + * 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.core.query.reduce; + +import java.util.List; +import javax.annotation.Nullable; +import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.common.utils.DataTable; +import org.apache.pinot.core.common.BlockValSet; +import org.apache.pinot.segment.spi.index.reader.Dictionary; +import org.apache.pinot.spi.data.FieldSpec; + + +/** + * As for Gapfilling Function, all raw data will be retrieved from the pinot + * server and merged on the pinot broker. The data will be in {@link DataTable} + * format. + * As part of Gapfilling Function execution plan, the aggregation function will + * work on the merged data on pinot broker. The aggregation function only takes + * the {@link BlockValSet} format. + * This is the Helper class to convert the data from {@link DataTable} to the + * block of values {@link BlockValSet} which used as input to the aggregation + * function. + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class ColumnDataToBlockValSetConverter implements BlockValSet { + + private final FieldSpec.DataType _dataType; + private final List<Object[]> _rows; + private final int _columnIndex; + + public ColumnDataToBlockValSetConverter(DataSchema.ColumnDataType columnDataType, List<Object[]> rows, + int columnIndex) { + _dataType = columnDataType.toDataType(); + _rows = rows; + _columnIndex = columnIndex; + } + + @Override + public FieldSpec.DataType getValueType() { + return _dataType; + } + + @Override + public boolean isSingleValue() { + return true; + } + + @Nullable + @Override + public Dictionary getDictionary() { + throw new UnsupportedOperationException("Not supported"); + } + + @Override + public int[] getDictionaryIdsSV() { + throw new UnsupportedOperationException("Not supported"); + } + + @Override + public int[] getIntValuesSV() { + if (_dataType == FieldSpec.DataType.INT) { + int[] result = new int[_rows.size()]; + for (int i = 0; i < result.length; i++) { + result[i] = (Integer) _rows.get(i)[_columnIndex]; + } + return result; + } + throw new UnsupportedOperationException("Not supported"); Review comment: Fixed -- 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