Package org.apache.lucene.store
Class MockIndexInputWrapper
- java.lang.Object
-
- org.apache.lucene.store.DataInput
-
- org.apache.lucene.store.IndexInput
-
- org.apache.lucene.store.MockIndexInputWrapper
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Cloneable
public class MockIndexInputWrapper extends IndexInput
Used by MockDirectoryWrapper to create an input stream that keeps track of when it's been closed.
-
-
Constructor Summary
Constructors Constructor Description MockIndexInputWrapper(MockDirectoryWrapper dir, String name, IndexInput delegate)Construct an empty output buffer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Returns a clone of this stream.voidclose()Closes the stream to further operations.voidcopyBytes(IndexOutput out, long numBytes)CopiesnumBytesbytes to the givenIndexOutput.longgetFilePointer()Returns the current position in this file, where the next read will occur.longlength()The number of bytes in the file.bytereadByte()Reads and returns a single byte.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 Lucene's old "modified 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.Map<String,String>readStringStringMap()intreadVInt()Reads an int stored in variable-length format.longreadVLong()Reads a long stored in variable-length format.voidseek(long pos)Sets current position in this file, where the next read will occur.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).voidskipChars(int length)Expert Similar toDataInput.readChars(char[], int, int)but does not do any conversion operations on the bytes it is reading in.-
Methods inherited from class org.apache.lucene.store.IndexInput
toString
-
-
-
-
Constructor Detail
-
MockIndexInputWrapper
public MockIndexInputWrapper(MockDirectoryWrapper dir, String name, IndexInput delegate)
Construct an empty output buffer.
-
-
Method Detail
-
close
public void close() throws IOExceptionDescription copied from class:IndexInputCloses the stream to further operations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classIndexInput- Throws:
IOException
-
clone
public Object clone()
Description copied from class:DataInputReturns 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.
-
getFilePointer
public long getFilePointer()
Description copied from class:IndexInputReturns the current position in this file, where the next read will occur.- Specified by:
getFilePointerin classIndexInput- See Also:
IndexInput.seek(long)
-
seek
public void seek(long pos) throws IOExceptionDescription copied from class:IndexInputSets current position in this file, where the next read will occur.- Specified by:
seekin classIndexInput- Throws:
IOException- See Also:
IndexInput.getFilePointer()
-
length
public long length()
Description copied from class:IndexInputThe number of bytes in the file.- Specified by:
lengthin classIndexInput
-
readByte
public byte readByte() throws IOExceptionDescription copied from class:DataInputReads and returns a single byte.- Specified by:
readBytein classDataInput- Throws:
IOException- See Also:
DataOutput.writeByte(byte)
-
readBytes
public void readBytes(byte[] b, int offset, int len) throws IOExceptionDescription copied from class:DataInputReads a specified number of bytes into an array at the specified offset.- Specified by:
readBytesin classDataInput- 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)
-
copyBytes
public void copyBytes(IndexOutput out, long numBytes) throws IOException
Description copied from class:IndexInputCopiesnumBytesbytes to the givenIndexOutput.NOTE: this method uses an intermediate buffer to copy the bytes. Consider overriding it in your implementation, if you can make a better, optimized copy.
NOTE ensure that there are enough bytes in the input to copy to output. Otherwise, different exceptions may be thrown, depending on the implementation.
- Overrides:
copyBytesin classIndexInput- Throws:
IOException
-
readBytes
public void readBytes(byte[] b, int offset, int len, boolean useBuffer) throws IOExceptionDescription copied from class:DataInputReads 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.- Overrides:
readBytesin classDataInput- 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)
-
readInt
public int readInt() throws IOExceptionDescription copied from class:DataInputReads four bytes and returns an int.- Overrides:
readIntin classDataInput- Throws:
IOException- See Also:
DataOutput.writeInt(int)
-
readVInt
public int readVInt() throws IOExceptionDescription copied from class:DataInputReads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Overrides:
readVIntin classDataInput- Throws:
IOException- See Also:
DataOutput.writeVInt(int)
-
readLong
public long readLong() throws IOExceptionDescription copied from class:DataInputReads eight bytes and returns a long.- Overrides:
readLongin classDataInput- Throws:
IOException- See Also:
DataOutput.writeLong(long)
-
readVLong
public long readVLong() throws IOExceptionDescription copied from class:DataInputReads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Overrides:
readVLongin classDataInput- Throws:
IOException
-
readString
public String readString() throws IOException
Description copied from class:DataInputReads a string.- Overrides:
readStringin classDataInput- Throws:
IOException- See Also:
DataOutput.writeString(String)
-
readStringStringMap
public Map<String,String> readStringStringMap() throws IOException
- Overrides:
readStringStringMapin classDataInput- Throws:
IOException
-
setModifiedUTF8StringsMode
public void setModifiedUTF8StringsMode()
Description copied from class:DataInputCall 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.- Overrides:
setModifiedUTF8StringsModein classDataInput
-
readChars
public void readChars(char[] buffer, int start, int length) throws IOExceptionDescription copied from class:DataInputReads Lucene's old "modified UTF-8" encoded characters into an array.- Overrides:
readCharsin classDataInput- 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)
-
skipChars
public void skipChars(int length) throws IOExceptionDescription copied from class:IndexInputExpert Similar toDataInput.readChars(char[], int, int)but does not do any conversion operations on the bytes it is reading in. It still has to invokeDataInput.readByte()just asDataInput.readChars(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- Overrides:
skipCharsin classIndexInput- Parameters:
length- The number of chars to read- Throws:
IOException
-
-