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 Object
clone()
Returns a clone of this stream.void
close()
Closes the stream to further operations.void
copyBytes(IndexOutput out, long numBytes)
CopiesnumBytes
bytes to the givenIndexOutput
.long
getFilePointer()
Returns the current position in this file, where the next read will occur.long
length()
The number of bytes in the file.byte
readByte()
Reads and returns a single byte.void
readBytes(byte[] b, int offset, int len)
Reads a specified number of bytes into an array at the specified offset.void
readBytes(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).void
readChars(char[] buffer, int start, int length)
Reads Lucene's old "modified UTF-8" encoded characters into an array.int
readInt()
Reads four bytes and returns an int.long
readLong()
Reads eight bytes and returns a long.String
readString()
Reads a string.Map<String,String>
readStringStringMap()
int
readVInt()
Reads an int stored in variable-length format.long
readVLong()
Reads a long stored in variable-length format.void
seek(long pos)
Sets current position in this file, where the next read will occur.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).void
skipChars(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 IOException
Description copied from class:IndexInput
Closes the stream to further operations.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classIndexInput
- Throws:
IOException
-
clone
public Object clone()
Description copied from class:DataInput
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.
-
getFilePointer
public long getFilePointer()
Description copied from class:IndexInput
Returns the current position in this file, where the next read will occur.- Specified by:
getFilePointer
in classIndexInput
- See Also:
IndexInput.seek(long)
-
seek
public void seek(long pos) throws IOException
Description copied from class:IndexInput
Sets current position in this file, where the next read will occur.- Specified by:
seek
in classIndexInput
- Throws:
IOException
- See Also:
IndexInput.getFilePointer()
-
length
public long length()
Description copied from class:IndexInput
The number of bytes in the file.- Specified by:
length
in classIndexInput
-
readByte
public byte readByte() throws IOException
Description copied from class:DataInput
Reads and returns a single byte.- Specified by:
readByte
in classDataInput
- Throws:
IOException
- See Also:
DataOutput.writeByte(byte)
-
readBytes
public void readBytes(byte[] b, int offset, int len) throws IOException
Description copied from class:DataInput
Reads a specified number of bytes into an array at the specified offset.- Specified by:
readBytes
in 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:IndexInput
CopiesnumBytes
bytes 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:
copyBytes
in classIndexInput
- Throws:
IOException
-
readBytes
public void readBytes(byte[] b, int offset, int len, boolean useBuffer) throws IOException
Description copied from class:DataInput
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). Currently onlyBufferedIndexInput
respects this parameter.- Overrides:
readBytes
in 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 IOException
Description copied from class:DataInput
Reads four bytes and returns an int.- Overrides:
readInt
in classDataInput
- Throws:
IOException
- See Also:
DataOutput.writeInt(int)
-
readVInt
public int readVInt() throws IOException
Description copied from class:DataInput
Reads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Overrides:
readVInt
in classDataInput
- Throws:
IOException
- See Also:
DataOutput.writeVInt(int)
-
readLong
public long readLong() throws IOException
Description copied from class:DataInput
Reads eight bytes and returns a long.- Overrides:
readLong
in classDataInput
- Throws:
IOException
- See Also:
DataOutput.writeLong(long)
-
readVLong
public long readVLong() throws IOException
Description copied from class:DataInput
Reads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Overrides:
readVLong
in classDataInput
- Throws:
IOException
-
readString
public String readString() throws IOException
Description copied from class:DataInput
Reads a string.- Overrides:
readString
in classDataInput
- Throws:
IOException
- See Also:
DataOutput.writeString(String)
-
readStringStringMap
public Map<String,String> readStringStringMap() throws IOException
- Overrides:
readStringStringMap
in classDataInput
- Throws:
IOException
-
setModifiedUTF8StringsMode
public void setModifiedUTF8StringsMode()
Description copied from class:DataInput
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.- Overrides:
setModifiedUTF8StringsMode
in classDataInput
-
readChars
public void readChars(char[] buffer, int start, int length) throws IOException
Description copied from class:DataInput
Reads Lucene's old "modified UTF-8" encoded characters into an array.- Overrides:
readChars
in 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 IOException
Description copied from class:IndexInput
Expert 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:
skipChars
in classIndexInput
- Parameters:
length
- The number of chars to read- Throws:
IOException
-
-