Skip navigation links

Oracle® Loader for Hadoop Java API Reference for Linux
Release 1.1

E20858-03


oracle.hadoop.loader.examples
Class CSVInputFormat.CSVRecordReader

java.lang.Object
  extended by org.apache.hadoop.mapreduce.RecordReader<org.apache.avro.generic.IndexedRecord,org.apache.hadoop.io.NullWritable>
      extended by oracle.hadoop.loader.examples.CSVInputFormat.CSVRecordReader

All Implemented Interfaces:
java.io.Closeable
Enclosing class:
CSVInputFormat

public static class CSVInputFormat.CSVRecordReader
extends org.apache.hadoop.mapreduce.RecordReader<org.apache.avro.generic.IndexedRecord,org.apache.hadoop.io.NullWritable>

The record reader parses the input data into key/value pairs which are read by OraLoaderMapper. It produces an org.apache.avro.generic.IndexedRecord for the key and a org.apache.hadoop.io.NullWritable for the value.


Constructor Summary
CSVInputFormat.CSVRecordReader(org.apache.hadoop.mapreduce.RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text> textRecordReader)
           

 

Method Summary
 void close()
          Close the record reader.
 org.apache.avro.generic.IndexedRecord getCurrentKey()
          Get the current key.
 org.apache.hadoop.io.NullWritable getCurrentValue()
          Get the current value, always a NullWritable object.
 float getProgress()
          The current progress of the record reader through its data.
 void initialize(org.apache.hadoop.mapreduce.InputSplit split, org.apache.hadoop.mapreduce.TaskAttemptContext context)
          Called once at initialization.
 boolean nextKeyValue()
          Read the next key, value pair.

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

CSVInputFormat.CSVRecordReader

public CSVInputFormat.CSVRecordReader(org.apache.hadoop.mapreduce.RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text> textRecordReader)

Method Detail

getCurrentKey

public org.apache.avro.generic.IndexedRecord getCurrentKey()
                                                    throws java.io.IOException,
                                                           java.lang.InterruptedException
Get the current key. The next line of text is read from the input and split into tokens using the ',' delimiter. Token values are put into an Avro IndexedRecord which is returned as the key value.
Specified by:
getCurrentKey in class org.apache.hadoop.mapreduce.RecordReader<org.apache.avro.generic.IndexedRecord,org.apache.hadoop.io.NullWritable>
Returns:
the current key or null if there is no current key
Throws:
java.io.IOException
java.lang.InterruptedException

getCurrentValue

public org.apache.hadoop.io.NullWritable getCurrentValue()
                                                  throws java.io.IOException,
                                                         java.lang.InterruptedException
Get the current value, always a NullWritable object.
Specified by:
getCurrentValue in class org.apache.hadoop.mapreduce.RecordReader<org.apache.avro.generic.IndexedRecord,org.apache.hadoop.io.NullWritable>
Returns:
a NullWritable object.
Throws:
java.io.IOException
java.lang.InterruptedException

initialize

public void initialize(org.apache.hadoop.mapreduce.InputSplit split,
                       org.apache.hadoop.mapreduce.TaskAttemptContext context)
                throws java.io.IOException,
                       java.lang.InterruptedException
Called once at initialization.
Specified by:
initialize in class org.apache.hadoop.mapreduce.RecordReader<org.apache.avro.generic.IndexedRecord,org.apache.hadoop.io.NullWritable>
Parameters:
split - the split that defines the range of records to read
context - the information about the task
Throws:
java.io.IOException
java.lang.InterruptedException

close

public void close()
           throws java.io.IOException
Close the record reader.
Specified by:
close in interface java.io.Closeable
Specified by:
close in class org.apache.hadoop.mapreduce.RecordReader<org.apache.avro.generic.IndexedRecord,org.apache.hadoop.io.NullWritable>
Throws:
java.io.IOException

nextKeyValue

public boolean nextKeyValue()
                     throws java.io.IOException,
                            java.lang.InterruptedException
Read the next key, value pair.
Specified by:
nextKeyValue in class org.apache.hadoop.mapreduce.RecordReader<org.apache.avro.generic.IndexedRecord,org.apache.hadoop.io.NullWritable>
Returns:
true if a key/value pair was read
Throws:
java.io.IOException
java.lang.InterruptedException

getProgress

public float getProgress()
                  throws java.io.IOException,
                         java.lang.InterruptedException
The current progress of the record reader through its data.
Specified by:
getProgress in class org.apache.hadoop.mapreduce.RecordReader<org.apache.avro.generic.IndexedRecord,org.apache.hadoop.io.NullWritable>
Returns:
a number between 0.0 and 1.0 that is the fraction of the data read
Throws:
java.io.IOException
java.lang.InterruptedException

Skip navigation links

Oracle® Loader for Hadoop Java API Reference for Linux
Release 1.1

E20858-03


Copyright © 2011, Oracle and/or its affiliates. All rights reserved.