org.apache.cassandra.hadoop.streaming
Class AvroOutputReader

java.lang.Object
  extended by org.apache.hadoop.streaming.io.OutputReader<java.nio.ByteBuffer,java.util.List<org.apache.cassandra.avro.Mutation>>
      extended by org.apache.cassandra.hadoop.streaming.AvroOutputReader

public class AvroOutputReader
extends org.apache.hadoop.streaming.io.OutputReader<java.nio.ByteBuffer,java.util.List<org.apache.cassandra.avro.Mutation>>

An OutputReader that reads sequential StreamingMutations (from Cassandra's Avro client API), and converts them to the objects used by CassandraOutputFormat. This allows Hadoop Streaming to output efficiently to Cassandra via a familiar API. Avro requires the reader's and writer's schema: otherwise, it assumes they are the same. If the canonical schema that the Cassandra side uses changes, and somebody packaged the {{avpr}} up in their application somehow, or generated code, they'd see a runtime failure. We could allow specifying an alternate Avro schema using a Configuration property to work around this.


Constructor Summary
AvroOutputReader()
           
 
Method Summary
 java.nio.ByteBuffer getCurrentKey()
          Returns the current key.
 java.util.List<org.apache.cassandra.avro.Mutation> getCurrentValue()
          Returns the current value.
 java.lang.String getLastOutput()
          Returns the last output from the client as a String.
 void initialize(org.apache.hadoop.streaming.PipeMapRed pmr)
          Initializes the OutputReader.
 boolean readKeyValue()
          Read the next key/value pair outputted by the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AvroOutputReader

public AvroOutputReader()
Method Detail

initialize

public void initialize(org.apache.hadoop.streaming.PipeMapRed pmr)
                throws java.io.IOException
Description copied from class: org.apache.hadoop.streaming.io.OutputReader
Initializes the OutputReader. This method has to be called before calling any of the other methods.

Overrides:
initialize in class org.apache.hadoop.streaming.io.OutputReader<java.nio.ByteBuffer,java.util.List<org.apache.cassandra.avro.Mutation>>
Throws:
java.io.IOException

readKeyValue

public boolean readKeyValue()
                     throws java.io.IOException
Description copied from class: org.apache.hadoop.streaming.io.OutputReader
Read the next key/value pair outputted by the client.

Specified by:
readKeyValue in class org.apache.hadoop.streaming.io.OutputReader<java.nio.ByteBuffer,java.util.List<org.apache.cassandra.avro.Mutation>>
Returns:
true iff a key/value pair was read
Throws:
java.io.IOException

getCurrentKey

public java.nio.ByteBuffer getCurrentKey()
                                  throws java.io.IOException
Description copied from class: org.apache.hadoop.streaming.io.OutputReader
Returns the current key.

Specified by:
getCurrentKey in class org.apache.hadoop.streaming.io.OutputReader<java.nio.ByteBuffer,java.util.List<org.apache.cassandra.avro.Mutation>>
Throws:
java.io.IOException

getCurrentValue

public java.util.List<org.apache.cassandra.avro.Mutation> getCurrentValue()
                                                                   throws java.io.IOException
Description copied from class: org.apache.hadoop.streaming.io.OutputReader
Returns the current value.

Specified by:
getCurrentValue in class org.apache.hadoop.streaming.io.OutputReader<java.nio.ByteBuffer,java.util.List<org.apache.cassandra.avro.Mutation>>
Throws:
java.io.IOException

getLastOutput

public java.lang.String getLastOutput()
Description copied from class: org.apache.hadoop.streaming.io.OutputReader
Returns the last output from the client as a String.

Specified by:
getLastOutput in class org.apache.hadoop.streaming.io.OutputReader<java.nio.ByteBuffer,java.util.List<org.apache.cassandra.avro.Mutation>>


Copyright © 2011 The Apache Software Foundation