Package org.apache.lucene.store
Class DataInput
- java.lang.Object
-
- org.apache.lucene.store.DataInput
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ByteArrayDataInput,FST.BytesReader,IndexInput,InputStreamDataInput,PagedBytes.PagedBytesDataInput
public abstract class DataInput extends Object implements Cloneable
Abstract base class for performing read operations of Lucene's low-level data types.
-
-
Constructor Summary
Constructors Constructor Description DataInput()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Objectclone()Returns a clone of this stream.abstract bytereadByte()Reads and returns a single byte.abstract voidreadBytes(byte[] b, int offset, int len)Reads a specified number of bytes into an array at the specified offset.voidreadBytes(byte[] b, int offset, int len, boolean useBuffer)Reads a specified number of bytes into an array at the specified offset with control over whether the read should be buffered (callers who have their own buffer should pass in "false" for useBuffer).voidreadChars(char[] buffer, int start, int length)Deprecated.-- please use readString or readBytes instead, and construct the string from those utf8 bytesintreadInt()Reads four bytes and returns an int.longreadLong()Reads eight bytes and returns a long.shortreadShort()Reads two bytes and returns a short.StringreadString()Reads a string.Map<String,String>readStringStringMap()intreadVInt()Reads an int stored in variable-length format.longreadVLong()Reads a long stored in variable-length format.voidsetModifiedUTF8StringsMode()Call this if readString should read characters stored in the old modified UTF8 format (length in java chars and java's modified UTF8 encoding).
-
-
-
Method Detail
-
setModifiedUTF8StringsMode
public void setModifiedUTF8StringsMode()
Call this if readString should read characters stored in the old modified UTF8 format (length in java chars and java's modified UTF8 encoding). This is used for indices written pre-2.4 See LUCENE-510 for details.
-
readByte
public abstract byte readByte() throws IOExceptionReads and returns a single byte.- Throws:
IOException- See Also:
DataOutput.writeByte(byte)
-
readBytes
public abstract void readBytes(byte[] b, int offset, int len) throws IOExceptionReads a specified number of bytes into an array at the specified offset.- Parameters:
b- the array to read bytes intooffset- the offset in the array to start storing byteslen- the number of bytes to read- Throws:
IOException- See Also:
DataOutput.writeBytes(byte[],int)
-
readBytes
public void readBytes(byte[] b, int offset, int len, boolean useBuffer) throws IOExceptionReads a specified number of bytes into an array at the specified offset with control over whether the read should be buffered (callers who have their own buffer should pass in "false" for useBuffer). Currently onlyBufferedIndexInputrespects this parameter.- Parameters:
b- the array to read bytes intooffset- the offset in the array to start storing byteslen- the number of bytes to readuseBuffer- set to false if the caller will handle buffering.- Throws:
IOException- See Also:
DataOutput.writeBytes(byte[],int)
-
readShort
public short readShort() throws IOExceptionReads two bytes and returns a short.- Throws:
IOException- See Also:
DataOutput.writeByte(byte)
-
readInt
public int readInt() throws IOExceptionReads four bytes and returns an int.- Throws:
IOException- See Also:
DataOutput.writeInt(int)
-
readVInt
public int readVInt() throws IOExceptionReads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Throws:
IOException- See Also:
DataOutput.writeVInt(int)
-
readLong
public long readLong() throws IOExceptionReads eight bytes and returns a long.- Throws:
IOException- See Also:
DataOutput.writeLong(long)
-
readVLong
public long readVLong() throws IOExceptionReads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Throws:
IOException
-
readString
public String readString() throws IOException
Reads a string.- Throws:
IOException- See Also:
DataOutput.writeString(String)
-
readChars
@Deprecated public void readChars(char[] buffer, int start, int length) throws IOException
Deprecated.-- please use readString or readBytes instead, and construct the string from those utf8 bytesReads Lucene's old "modified UTF-8" encoded characters into an array.- Parameters:
buffer- the array to read characters intostart- the offset in the array to start storing characterslength- the number of characters to read- Throws:
IOException- See Also:
DataOutput.writeChars(String,int,int)
-
clone
public Object clone()
Returns a clone of this stream.Clones of a stream access the same data, and are positioned at the same point as the stream they were cloned from.
Expert: Subclasses must ensure that clones may be positioned at different points in the input from each other and from the stream they were cloned from.
-
readStringStringMap
public Map<String,String> readStringStringMap() throws IOException
- Throws:
IOException
-
-