jackjlli commented on a change in pull request #7062: URL: https://github.com/apache/incubator-pinot/pull/7062#discussion_r656424804
########## File path: pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/mappers/OrcDataPreprocessingMapper.java ########## @@ -0,0 +1,87 @@ +/** + * 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.hadoop.job.mappers; + +import com.google.common.base.Preconditions; +import java.io.IOException; +import java.util.List; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.io.NullWritable; +import org.apache.hadoop.io.WritableComparable; +import org.apache.hadoop.mapreduce.Mapper; +import org.apache.orc.mapred.OrcStruct; +import org.apache.orc.mapred.OrcValue; +import org.apache.pinot.hadoop.job.InternalConfigConstants; +import org.apache.pinot.hadoop.utils.preprocess.DataPreprocessingUtils; +import org.apache.pinot.hadoop.utils.preprocess.OrcUtils; +import org.apache.pinot.spi.data.FieldSpec; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class OrcDataPreprocessingMapper extends Mapper<NullWritable, OrcStruct, WritableComparable, OrcValue> { + private static final Logger LOGGER = LoggerFactory.getLogger(OrcDataPreprocessingMapper.class); + + private final OrcValue _valueWrapper = new OrcValue(); + private String _sortingColumn = null; + private FieldSpec.DataType _sortingColumnType = null; + private int _sortingColumnId = -1; + + @Override + public void setup(Context context) { + Configuration configuration = context.getConfiguration(); + String sortingColumnConfig = configuration.get(InternalConfigConstants.SORTING_COLUMN_CONFIG); + if (sortingColumnConfig != null) { + _sortingColumn = sortingColumnConfig; + _sortingColumnType = FieldSpec.DataType.valueOf(configuration.get(InternalConfigConstants.SORTING_COLUMN_TYPE)); + LOGGER.info("Initialized OrcDataPreprocessingMapper with sortingColumn: {} of type: {}", _sortingColumn, + _sortingColumnType); + } else { + LOGGER.info("Initialized OrcDataPreprocessingMapper without sorting column"); + } + } + + @Override + public void map(NullWritable key, OrcStruct value, Context context) + throws IOException, InterruptedException { + _valueWrapper.value = value; + if (_sortingColumn != null) { + if (_sortingColumnId == -1) { + List<String> fieldNames = value.getSchema().getFieldNames(); + _sortingColumnId = fieldNames.indexOf(_sortingColumn); + Preconditions.checkState(_sortingColumnId != -1, "Failed to find sorting column: %s in the ORC fields: %s", + _sortingColumn, fieldNames); + LOGGER.info("Field id for sorting column: {} is: {}", _sortingColumn, _sortingColumnId); Review comment: This is to find out the index of sorting column and will be called only once. -- 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. 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