org.apache.lucene.store
Class IndexInput
- java.lang.Object
-
- org.apache.lucene.store.IndexInput
-
- All Implemented Interfaces:
- java.lang.Cloneable
- Direct Known Subclasses:
- BufferedIndexInput
public abstract class IndexInput extends java.lang.Object implements java.lang.CloneableAbstract base class for input from a file in aDirectory. A random-access input stream. Used for all Lucene index input operations.- See Also:
Directory
-
-
Constructor Summary
Constructors Constructor and Description IndexInput()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description java.lang.Objectclone()Returns a clone of this stream.abstract voidclose()Closes the stream to futher operations.abstract longgetFilePointer()Returns the current position in this file, where the next read will occur.abstract longlength()The number of bytes in the file.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)Reads UTF-8 encoded characters into an array.intreadInt()Reads four bytes and returns an int.longreadLong()Reads eight bytes and returns a long.java.lang.StringreadString()Reads a string.intreadVInt()Reads an int stored in variable-length format.longreadVLong()Reads a long stored in variable-length format.abstract voidseek(long pos)Sets current position in this file, where the next read will occur.voidskipChars(int length)Expert Similar toreadChars(char[], int, int)but does not do any conversion operations on the bytes it is reading in.
-
-
-
Method Detail
-
readByte
public abstract byte readByte() throws java.io.IOExceptionReads and returns a single byte.- Throws:
java.io.IOException- See Also:
IndexOutput.writeByte(byte)
-
readBytes
public abstract void readBytes(byte[] b, int offset, int len) throws java.io.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:
java.io.IOException- See Also:
IndexOutput.writeBytes(byte[],int)
-
readBytes
public void readBytes(byte[] b, int offset, int len, boolean useBuffer) throws java.io.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:
java.io.IOException- See Also:
IndexOutput.writeBytes(byte[],int)
-
readInt
public int readInt() throws java.io.IOExceptionReads four bytes and returns an int.- Throws:
java.io.IOException- See Also:
IndexOutput.writeInt(int)
-
readVInt
public int readVInt() throws java.io.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:
java.io.IOException- See Also:
IndexOutput.writeVInt(int)
-
readLong
public long readLong() throws java.io.IOExceptionReads eight bytes and returns a long.- Throws:
java.io.IOException- See Also:
IndexOutput.writeLong(long)
-
readVLong
public long readVLong() throws java.io.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:
java.io.IOException
-
readString
public java.lang.String readString() throws java.io.IOExceptionReads a string.- Throws:
java.io.IOException- See Also:
IndexOutput.writeString(String)
-
readChars
public void readChars(char[] buffer, int start, int length) throws java.io.IOExceptionReads 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:
java.io.IOException- See Also:
IndexOutput.writeChars(String,int,int)
-
skipChars
public void skipChars(int length) throws java.io.IOExceptionExpert Similar toreadChars(char[], int, int)but does not do any conversion operations on the bytes it is reading in. It still has to invokereadByte()just asreadChars(char[], int, int)does, but it does not need a buffer to store anything and it does not have to do any of the bitwise operations, since we don't actually care what is in the byte except to determine how many more bytes to read- Parameters:
length- The number of chars to read- Throws:
java.io.IOException
-
close
public abstract void close() throws java.io.IOExceptionCloses the stream to futher operations.- Throws:
java.io.IOException
-
getFilePointer
public abstract long getFilePointer()
Returns the current position in this file, where the next read will occur.- See Also:
seek(long)
-
seek
public abstract void seek(long pos) throws java.io.IOExceptionSets current position in this file, where the next read will occur.- Throws:
java.io.IOException- See Also:
getFilePointer()
-
length
public abstract long length()
The number of bytes in the file.
-
clone
public java.lang.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.
- Overrides:
clonein classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG