edu.umd.cloud9.collection
Class XMLInputFormat.XMLRecordReader

java.lang.Object
  extended by org.apache.hadoop.mapreduce.RecordReader<LongWritable,Text>
      extended by edu.umd.cloud9.collection.XMLInputFormat.XMLRecordReader
All Implemented Interfaces:
Closeable
Enclosing class:
XMLInputFormat

public static class XMLInputFormat.XMLRecordReader
extends RecordReader<LongWritable,Text>

Simple RecordReader for XML documents (org.apache.hadoop.mapreduce API). Recognizes begin-of-document and end-of-document tags only: everything between those delimiting tags is returned in a Text object.

Author:
Jimmy Lin

Constructor Summary
XMLInputFormat.XMLRecordReader()
           
 
Method Summary
 void close()
          Closes the record reader.
 LongWritable getCurrentKey()
          Returns the current key.
 Text getCurrentValue()
          Returns the current value.
 float getProgress()
          The current progress of the record reader through its data.
 void initialize(InputSplit input, 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

XMLInputFormat.XMLRecordReader

public XMLInputFormat.XMLRecordReader()
Method Detail

initialize

public void initialize(InputSplit input,
                       TaskAttemptContext context)
                throws IOException,
                       InterruptedException
Called once at initialization.

Specified by:
initialize in class RecordReader<LongWritable,Text>
Parameters:
input - the split that defines the range of records to read
context - the information about the task
Throws:
IOException
InterruptedException

nextKeyValue

public boolean nextKeyValue()
                     throws IOException,
                            InterruptedException
Read the next key, value pair.

Specified by:
nextKeyValue in class RecordReader<LongWritable,Text>
Returns:
true if a key/value pair was read
Throws:
IOException
InterruptedException

getCurrentKey

public LongWritable getCurrentKey()
                           throws IOException,
                                  InterruptedException
Returns the current key.

Specified by:
getCurrentKey in class RecordReader<LongWritable,Text>
Returns:
the current key or null if there is no current key
Throws:
IOException
InterruptedException

getCurrentValue

public Text getCurrentValue()
                     throws IOException,
                            InterruptedException
Returns the current value.

Specified by:
getCurrentValue in class RecordReader<LongWritable,Text>
Returns:
current value
Throws:
IOException
InterruptedException

close

public void close()
           throws IOException
Closes the record reader.

Specified by:
close in interface Closeable
Specified by:
close in class RecordReader<LongWritable,Text>
Throws:
IOException

getProgress

public float getProgress()
                  throws IOException
The current progress of the record reader through its data.

Specified by:
getProgress in class RecordReader<LongWritable,Text>
Returns:
a number between 0.0 and 1.0 that is the fraction of the data read
Throws:
IOException
InterruptedException