Java tutorial
/* * Copyright 2012 - 2016 Splice Machine, Inc. * * Licensed 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 com.splicemachine.mrio.api.mapreduce; import java.io.IOException; import org.apache.hadoop.mapreduce.InputSplit; import org.apache.hadoop.mapreduce.RecordReader; import org.apache.hadoop.mapreduce.TaskAttemptContext; import org.apache.log4j.Logger; import com.splicemachine.mrio.api.core.SMRecordReaderImpl; import com.splicemachine.mrio.api.serde.ExecRowWritable; import com.splicemachine.mrio.api.serde.RowLocationWritable; import com.splicemachine.utils.SpliceLogUtils; /** * * Wrapper Class to Support Hive MR2 while deferring to Splice Machine's core MR format. * * */ public class SMWrappedRecordReader extends RecordReader<RowLocationWritable, ExecRowWritable> { protected static final Logger LOG = Logger.getLogger(SMWrappedRecordReader.class); protected SMRecordReaderImpl delegate; protected RowLocationWritable key; protected ExecRowWritable value; public SMWrappedRecordReader(SMRecordReaderImpl reader) { if (LOG.isTraceEnabled()) SpliceLogUtils.trace(LOG, "SMWrappedRecordReader with reader=%s", reader); this.delegate = reader; this.key = new RowLocationWritable(); this.value = new ExecRowWritable(delegate.getExecRow()); } @Override public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { delegate.initialize(split, context); } @Override public boolean nextKeyValue() throws IOException, InterruptedException { return delegate.nextKeyValue(); } @Override public RowLocationWritable getCurrentKey() throws IOException, InterruptedException { key.set(delegate.getCurrentKey()); return key; } @Override public ExecRowWritable getCurrentValue() throws IOException, InterruptedException { value.set(delegate.getCurrentValue()); return value; } @Override public float getProgress() throws IOException, InterruptedException { return delegate.getProgress(); } @Override public void close() throws IOException { delegate.close(); } }