Package org.apache.lucene.store
Class IndexOutput
java.lang.Object
org.apache.lucene.store.DataOutput
org.apache.lucene.store.IndexOutput
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
BufferedIndexOutput
,ChecksumIndexOutput
,RAMOutputStream
Abstract base class for output to a file in a Directory. A random-access
output stream. Used for all Lucene index output operations.
IndexOutput
may only be used from one thread, because it is not
thread safe (it keeps internal state like file position).
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
Closes this stream to further operations.abstract void
flush()
Forces any buffered output to be written.abstract long
Returns the current position in this file, where the next write will occur.abstract long
length()
The number of bytes in the file.abstract void
seek
(long pos) Deprecated.(4.1) This method will be removed in Lucene 5.0void
setLength
(long length) Set the file length.Methods inherited from class org.apache.lucene.store.DataOutput
copyBytes, writeByte, writeBytes, writeBytes, writeInt, writeLong, writeShort, writeString, writeStringSet, writeStringStringMap, writeVInt, writeVLong
-
Constructor Details
-
IndexOutput
public IndexOutput()
-
-
Method Details
-
flush
Forces any buffered output to be written.- Throws:
IOException
-
close
Closes this stream to further operations.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getFilePointer
public abstract long getFilePointer()Returns the current position in this file, where the next write will occur.- See Also:
-
seek
Deprecated.(4.1) This method will be removed in Lucene 5.0Sets current position in this file, where the next write will occur.- Throws:
IOException
- See Also:
-
length
The number of bytes in the file.- Throws:
IOException
-
setLength
Set the file length. By default, this method does nothing (it's optional for a Directory to implement it). But, certain Directory implementations (for example @see FSDirectory) can use this to inform the underlying IO system to pre-allocate the file to the specified size. If the length is longer than the current file length, the bytes added to the file are undefined. Otherwise the file is truncated.- Parameters:
length
- file length- Throws:
IOException
-