jenniferdai commented on a change in pull request #4253: Add segment pre-processing Hadoop job URL: https://github.com/apache/incubator-pinot/pull/4253#discussion_r290436131
########## File path: pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/mapper/SegmentPreprocessingMapper.java ########## @@ -0,0 +1,85 @@ +/** + * 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.mapper; + +import java.io.IOException; +import org.apache.avro.Schema; +import org.apache.avro.generic.GenericData; +import org.apache.avro.generic.GenericRecord; +import org.apache.avro.mapred.AvroKey; +import org.apache.avro.mapred.AvroValue; +import org.apache.avro.mapreduce.AvroJob; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.io.NullWritable; +import org.apache.hadoop.mapreduce.Mapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.pinot.hadoop.job.JobConfigConstants.*; + + +public class SegmentPreprocessingMapper + extends Mapper<AvroKey<GenericRecord>, NullWritable, AvroKey<GenericRecord>, AvroValue<GenericRecord>> { + private static final Logger LOGGER = LoggerFactory.getLogger(SegmentPreprocessingMapper.class); + private String _sortedColumn = null; + private Schema _outputKeySchema; + private Schema _outputSchema; + private boolean _enablePartition = false; + + @Override + public void setup(final Context context) { + Configuration configuration = context.getConfiguration(); + + String sortedColumn = configuration.get(SORTED_COLUMN); + // Logging the configs for the mapper + LOGGER.info("Sorted Column: " + sortedColumn); + if (sortedColumn != null) { + _sortedColumn = sortedColumn; + } + _outputKeySchema = AvroJob.getMapOutputKeySchema(configuration); + _outputSchema = AvroJob.getMapOutputValueSchema(configuration); + _enablePartition = Boolean.parseBoolean(configuration.get(ENABLE_PARTITIONING)); + LOGGER.info("Enable partitioning? " + _enablePartition); + } + + @Override + public void map(AvroKey<GenericRecord> record, NullWritable value, final Context context) + throws IOException, InterruptedException { + final GenericRecord inputRecord = record.datum(); + final Schema schema = inputRecord.getSchema(); + assert _outputSchema.equals(schema); Review comment: whenever we do asserts, we should add a message for the user to help them ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
