org.apache.hadoop.hive.conf
Class LoopingByteArrayInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.hadoop.hive.conf.LoopingByteArrayInputStream
All Implemented Interfaces:
Closeable

public class LoopingByteArrayInputStream
extends InputStream

LoopingByteArrayInputStream. This was designed specifically to handle the problem in Hadoop's Configuration object that it tries to read the entire contents of the same InputStream repeatedly without resetting it. The Configuration object does attempt to close the InputStream though, so, since close does nothing for the ByteArrayInputStream object, override it to reset it. It also uses a thread local ByteArrayInputStream for method calls. This is because Configuration's copy constructor does a shallow copy of the resources, meaning that when the copy constructor is used to generate HiveConfs in different threads, they all share the same LoopingByteArrayInputStream. ByteArrayInputStreams are not thread safe in such situations.


Constructor Summary
LoopingByteArrayInputStream(byte[] buf)
           
 
Method Summary
 int available()
           
 void close()
           
 void mark(int arg0)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] arg0)
           
 int read(byte[] arg0, int arg1, int arg2)
           
 void reset()
           
 long skip(long arg0)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoopingByteArrayInputStream

public LoopingByteArrayInputStream(byte[] buf)
Method Detail

available

public int available()
Overrides:
available in class InputStream

mark

public void mark(int arg0)
Overrides:
mark in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStream

read

public int read()
Specified by:
read in class InputStream

read

public int read(byte[] arg0,
                int arg1,
                int arg2)
Overrides:
read in class InputStream

reset

public void reset()
Overrides:
reset in class InputStream

skip

public long skip(long arg0)
Overrides:
skip in class InputStream

read

public int read(byte[] arg0)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException


Copyright © 2012 The Apache Software Foundation