com.fasterxml.sort.std
Class RawTextLineReader

java.lang.Object
  extended by com.fasterxml.sort.DataReader<byte[]>
      extended by com.fasterxml.sort.std.RawTextLineReader

public class RawTextLineReader
extends DataReader<byte[]>

Efficient reader for data that consists of text lines, i.e. character data separated by one of standard line feeds (CR, LF or CR+LF). For efficiency no decoding is done


Nested Class Summary
static class RawTextLineReader.Factory
           
 
Field Summary
protected  boolean _closed
           
protected  boolean _hadCR
          Marker we set if the last line ended with a CR, since it may be followed by a trailing LF as part of two-byte linefeed.
protected  InputStream _in
           
protected  byte[] _inputBuffer
           
protected  int _inputEnd
           
protected  int _inputPtr
           
protected  ByteArrayOutputStream _tmpBytes
           
protected static byte BYTE_CR
           
protected static byte BYTE_LF
           
 
Constructor Summary
RawTextLineReader(InputStream in)
           
 
Method Summary
protected  boolean _loadMore()
           
protected  byte[] _readNextSlow(int start)
           
protected  boolean _skipCR()
           
 void close()
          Method for closing the reader.
 int estimateSizeInBytes(byte[] item)
          Method that should estimate memory usage of given item, for purpose of limiting amount of data kept in memory during pre-sorting phase.
static RawTextLineReader.Factory factory()
          Convenience method for instantiating factory to create instances of this DataReader.
 byte[] readNext()
          Method for reading the next data item; will return null to indicate end of input, otherwise return a non-null item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTE_CR

protected static final byte BYTE_CR
See Also:
Constant Field Values

BYTE_LF

protected static final byte BYTE_LF
See Also:
Constant Field Values

_in

protected final InputStream _in

_closed

protected boolean _closed

_inputBuffer

protected byte[] _inputBuffer

_inputPtr

protected int _inputPtr

_inputEnd

protected int _inputEnd

_hadCR

protected boolean _hadCR
Marker we set if the last line ended with a CR, since it may be followed by a trailing LF as part of two-byte linefeed.


_tmpBytes

protected ByteArrayOutputStream _tmpBytes
Constructor Detail

RawTextLineReader

public RawTextLineReader(InputStream in)
Method Detail

factory

public static RawTextLineReader.Factory factory()
Convenience method for instantiating factory to create instances of this DataReader.


close

public void close()
           throws IOException
Description copied from class: DataReader
Method for closing the reader. Note that reader needs to ensure that it is ok to call close multiple times. Reader may also close underlying resources as soon as it has reached end of input.

Specified by:
close in class DataReader<byte[]>
Throws:
IOException

estimateSizeInBytes

public int estimateSizeInBytes(byte[] item)
Description copied from class: DataReader
Method that should estimate memory usage of given item, for purpose of limiting amount of data kept in memory during pre-sorting phase.

Specified by:
estimateSizeInBytes in class DataReader<byte[]>

readNext

public byte[] readNext()
                throws IOException
Description copied from class: DataReader
Method for reading the next data item; will return null to indicate end of input, otherwise return a non-null item.

Specified by:
readNext in class DataReader<byte[]>
Throws:
IOException

_readNextSlow

protected final byte[] _readNextSlow(int start)
                              throws IOException
Throws:
IOException

_loadMore

protected boolean _loadMore()
                     throws IOException
Throws:
IOException

_skipCR

protected boolean _skipCR()
                   throws IOException
Throws:
IOException


Copyright © 2011. All Rights Reserved.