edu.stolaf.cs.wmrserver.streaming
Class StreamKeyValUtil

java.lang.Object
  extended by edu.stolaf.cs.wmrserver.streaming.StreamKeyValUtil

public class StreamKeyValUtil
extends java.lang.Object


Constructor Summary
StreamKeyValUtil()
           
 
Method Summary
static int findTab(byte[] utf)
          Find the first occured tab in a UTF-8 encoded string
static int findTab(byte[] utf, int start, int length)
          Find the first occured tab in a UTF-8 encoded string
static int readLine(org.apache.hadoop.util.LineReader lineReader, org.apache.hadoop.io.Text out)
          Read a utf8 encoded line from a data input stream.
static void splitKeyVal(byte[] utf, int start, int length, org.apache.hadoop.io.Text key, org.apache.hadoop.io.Text val, int splitPos)
          split a UTF-8 byte array into key and value assuming that the delimilator is at splitpos.
static void splitKeyVal(byte[] utf, int start, int length, org.apache.hadoop.io.Text key, org.apache.hadoop.io.Text val, int splitPos, int separatorLength)
          split a UTF-8 byte array into key and value assuming that the delimilator is at splitpos.
static void splitKeyVal(byte[] utf, org.apache.hadoop.io.Text key, org.apache.hadoop.io.Text val, int splitPos)
          split a UTF-8 byte array into key and value assuming that the delimilator is at splitpos.
static void splitKeyVal(byte[] utf, org.apache.hadoop.io.Text key, org.apache.hadoop.io.Text val, int splitPos, int separatorLength)
          split a UTF-8 byte array into key and value assuming that the delimilator is at splitpos.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamKeyValUtil

public StreamKeyValUtil()
Method Detail

findTab

public static int findTab(byte[] utf,
                          int start,
                          int length)
Find the first occured tab in a UTF-8 encoded string

Parameters:
utf - a byte array containing a UTF-8 encoded string
start - starting offset
length - no. of bytes
Returns:
position that first tab occures otherwise -1

findTab

public static int findTab(byte[] utf)
Find the first occured tab in a UTF-8 encoded string

Parameters:
utf - a byte array containing a UTF-8 encoded string
Returns:
position that first tab occures otherwise -1

splitKeyVal

public static void splitKeyVal(byte[] utf,
                               int start,
                               int length,
                               org.apache.hadoop.io.Text key,
                               org.apache.hadoop.io.Text val,
                               int splitPos,
                               int separatorLength)
                        throws java.io.IOException
split a UTF-8 byte array into key and value assuming that the delimilator is at splitpos.

Parameters:
utf - utf-8 encoded string
start - starting offset
length - no. of bytes
key - contains key upon the method is returned
val - contains value upon the method is returned
splitPos - the split pos
separatorLength - the length of the separator between key and value
Throws:
java.io.IOException

splitKeyVal

public static void splitKeyVal(byte[] utf,
                               int start,
                               int length,
                               org.apache.hadoop.io.Text key,
                               org.apache.hadoop.io.Text val,
                               int splitPos)
                        throws java.io.IOException
split a UTF-8 byte array into key and value assuming that the delimilator is at splitpos.

Parameters:
utf - utf-8 encoded string
start - starting offset
length - no. of bytes
key - contains key upon the method is returned
val - contains value upon the method is returned
splitPos - the split pos
Throws:
java.io.IOException

splitKeyVal

public static void splitKeyVal(byte[] utf,
                               org.apache.hadoop.io.Text key,
                               org.apache.hadoop.io.Text val,
                               int splitPos,
                               int separatorLength)
                        throws java.io.IOException
split a UTF-8 byte array into key and value assuming that the delimilator is at splitpos.

Parameters:
utf - utf-8 encoded string
key - contains key upon the method is returned
val - contains value upon the method is returned
splitPos - the split pos
separatorLength - the length of the separator between key and value
Throws:
java.io.IOException

splitKeyVal

public static void splitKeyVal(byte[] utf,
                               org.apache.hadoop.io.Text key,
                               org.apache.hadoop.io.Text val,
                               int splitPos)
                        throws java.io.IOException
split a UTF-8 byte array into key and value assuming that the delimilator is at splitpos.

Parameters:
utf - utf-8 encoded string
key - contains key upon the method is returned
val - contains value upon the method is returned
splitPos - the split pos
Throws:
java.io.IOException

readLine

public static int readLine(org.apache.hadoop.util.LineReader lineReader,
                           org.apache.hadoop.io.Text out)
                    throws java.io.IOException
Read a utf8 encoded line from a data input stream.

Parameters:
lineReader - LineReader to read the line from.
out - Text to read into
Returns:
number of bytes read
Throws:
java.io.IOException