Package org.apache.lucene.store
Class IndexOutput
- java.lang.Object
-
- org.apache.lucene.store.DataOutput
-
- org.apache.lucene.store.IndexOutput
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
ByteBuffersIndexOutput
,DirectIODirectory.DirectIOIndexOutput
,EndiannessReverserIndexOutput
,OutputStreamIndexOutput
,RateLimitedIndexOutput
public abstract class IndexOutput extends DataOutput implements java.io.Closeable
ADataOutput
for appending data to a file in aDirectory
.Instances of this class are not thread-safe.
- See Also:
Directory
,IndexInput
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
name
Just the name part fromresourceDescription
private java.lang.String
resourceDescription
Full description of this output, e.g.
-
Constructor Summary
Constructors Modifier Constructor Description protected
IndexOutput(java.lang.String resourceDescription, java.lang.String name)
Sole constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description long
alignFilePointer(int alignmentBytes)
Aligns the current file pointer to multiples ofalignmentBytes
bytes to improve reads with mmap.static long
alignOffset(long offset, int alignmentBytes)
Aligns the givenoffset
to multiples ofalignmentBytes
bytes by rounding up.abstract void
close()
Closes this stream to further operations.abstract long
getChecksum()
Returns the current checksum of bytes written so farabstract long
getFilePointer()
Returns the current position in this file, where the next write will occur.java.lang.String
getName()
Returns the name used to create thisIndexOutput
.java.lang.String
toString()
-
Methods inherited from class org.apache.lucene.store.DataOutput
copyBytes, writeByte, writeBytes, writeBytes, writeInt, writeLong, writeMapOfStrings, writeSetOfStrings, writeShort, writeString, writeVInt, writeVLong, writeZInt, writeZLong
-
-
-
-
Constructor Detail
-
IndexOutput
protected IndexOutput(java.lang.String resourceDescription, java.lang.String name)
Sole constructor. resourceDescription should be non-null, opaque string describing this resource; it's returned fromtoString()
.
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name used to create thisIndexOutput
. This is especially useful when usingDirectory.createTempOutput(java.lang.String, java.lang.String, org.apache.lucene.store.IOContext)
.
-
close
public abstract void close() throws java.io.IOException
Closes this stream to further operations.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
getFilePointer
public abstract long getFilePointer()
Returns the current position in this file, where the next write will occur.
-
getChecksum
public abstract long getChecksum() throws java.io.IOException
Returns the current checksum of bytes written so far- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
alignFilePointer
public final long alignFilePointer(int alignmentBytes) throws java.io.IOException
Aligns the current file pointer to multiples ofalignmentBytes
bytes to improve reads with mmap. This will write between 0 and(alignmentBytes-1)
zero bytes usingDataOutput.writeByte(byte)
.- Parameters:
alignmentBytes
- the alignment to which it should forward file pointer (must be a power of 2)- Returns:
- the new file pointer after alignment
- Throws:
java.io.IOException
- See Also:
alignOffset(long, int)
-
alignOffset
public static final long alignOffset(long offset, int alignmentBytes)
Aligns the givenoffset
to multiples ofalignmentBytes
bytes by rounding up. The alignment must be a power of 2.
-
-