org.apache.lucene.store

Class IndexInput

public abstract class IndexInput extends Object implements Cloneable

Abstract base class for input from a file in a Directory. A random-access input stream. Used for all Lucene index input operations.

See Also: Directory

Method Summary
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.
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.
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 to (char[], int, int) but does not do any conversion operations on the bytes it is reading in.

Method Detail

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.

close

public abstract void close()
Closes the stream to futher operations.

getFilePointer

public abstract long getFilePointer()
Returns the current position in this file, where the next read will occur.

See Also: IndexInput

length

public abstract long length()
The number of bytes in the file.

readByte

public abstract byte readByte()
Reads and returns a single byte.

See Also: IndexOutput

readBytes

public abstract void readBytes(byte[] b, int offset, int len)
Reads a specified number of bytes into an array at the specified offset.

Parameters: b the array to read bytes into offset the offset in the array to start storing bytes len the number of bytes to read

See Also: (byte[],int)

readChars

public void readChars(char[] buffer, int start, int length)
Reads UTF-8 encoded characters into an array.

Parameters: buffer the array to read characters into start the offset in the array to start storing characters length the number of characters to read

See Also: IndexOutput

readInt

public int readInt()
Reads four bytes and returns an int.

See Also: IndexOutput

readLong

public long readLong()
Reads eight bytes and returns a long.

See Also: IndexOutput

readString

public String readString()
Reads a string.

See Also: writeString

readVInt

public int readVInt()
Reads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.

See Also: IndexOutput

readVLong

public long readVLong()
Reads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.

seek

public abstract void seek(long pos)
Sets current position in this file, where the next read will occur.

See Also: getFilePointer

skipChars

public void skipChars(int length)
Expert Similar to (char[], int, int) but does not do any conversion operations on the bytes it is reading in. It still has to invoke readByte just as (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

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.