Package org.apache.lucene.store
Class BufferedIndexOutput
java.lang.Object
org.apache.lucene.store.DataOutput
org.apache.lucene.store.IndexOutput
org.apache.lucene.store.BufferedIndexOutput
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
FSDirectory.FSIndexOutput
Base implementation class for buffered
IndexOutput.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default buffer size in bytes (16384). -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newBufferedIndexOutputwith the default buffer size (16384 bytes seeDEFAULT_BUFFER_SIZE)BufferedIndexOutput(int bufferSize) Creates a newBufferedIndexOutputwith the given buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this stream to further operations.voidflush()Forces any buffered output to be written.protected abstract voidflushBuffer(byte[] b, int offset, int len) Expert: implements buffer write.final intReturns size of the used output buffer in bytes.longReturns the current position in this file, where the next write will occur.abstract longlength()The number of bytes in the file.voidseek(long pos) Sets current position in this file, where the next write will occur.voidwriteByte(byte b) Writes a single byte.voidwriteBytes(byte[] b, int offset, int length) Writes an array of bytes.Methods inherited from class org.apache.lucene.store.IndexOutput
setLengthMethods inherited from class org.apache.lucene.store.DataOutput
copyBytes, writeBytes, writeInt, writeLong, writeShort, writeString, writeStringSet, writeStringStringMap, writeVInt, writeVLong
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEThe default buffer size in bytes (16384).- See Also:
-
-
Constructor Details
-
BufferedIndexOutput
public BufferedIndexOutput()Creates a newBufferedIndexOutputwith the default buffer size (16384 bytes seeDEFAULT_BUFFER_SIZE) -
BufferedIndexOutput
public BufferedIndexOutput(int bufferSize) Creates a newBufferedIndexOutputwith the given buffer size.- Parameters:
bufferSize- the buffer size in bytes used to buffer writes internally.- Throws:
IllegalArgumentException- if the given buffer size is less or equal to 0
-
-
Method Details
-
writeByte
Description copied from class:DataOutputWrites a single byte.The most primitive data type is an eight-bit byte. Files are accessed as sequences of bytes. All other data types are defined as sequences of bytes, so file formats are byte-order independent.
- Specified by:
writeBytein classDataOutput- Throws:
IOException- See Also:
-
writeBytes
Description copied from class:DataOutputWrites an array of bytes.- Specified by:
writeBytesin classDataOutput- Parameters:
b- the bytes to writeoffset- the offset in the byte arraylength- the number of bytes to write- Throws:
IOException- See Also:
-
flush
Description copied from class:IndexOutputForces any buffered output to be written.- Specified by:
flushin classIndexOutput- Throws:
IOException
-
flushBuffer
Expert: implements buffer write. Writes bytes at the current position in the output.- Parameters:
b- the bytes to writeoffset- the offset in the byte arraylen- the number of bytes to write- Throws:
IOException
-
close
Description copied from class:IndexOutputCloses this stream to further operations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classIndexOutput- Throws:
IOException
-
getFilePointer
public long getFilePointer()Description copied from class:IndexOutputReturns the current position in this file, where the next write will occur.- Specified by:
getFilePointerin classIndexOutput- See Also:
-
seek
Description copied from class:IndexOutputSets current position in this file, where the next write will occur.- Specified by:
seekin classIndexOutput- Throws:
IOException- See Also:
-
length
Description copied from class:IndexOutputThe number of bytes in the file.- Specified by:
lengthin classIndexOutput- Throws:
IOException
-
getBufferSize
public final int getBufferSize()Returns size of the used output buffer in bytes.
-