public class SequentialWriter extends java.io.OutputStream implements java.nio.channels.WritableByteChannel, Transactional
| Modifier and Type | Class and Description |
|---|---|
protected static class |
SequentialWriter.BufferedFileWriterMark
Class to hold a mark to the position of the file
|
protected class |
SequentialWriter.TransactionalProxy |
Transactional.AbstractTransactional| Modifier and Type | Field and Description |
|---|---|
protected java.nio.ByteBuffer |
buffer |
protected long |
bufferOffset |
protected java.nio.channels.FileChannel |
channel |
protected Descriptor |
descriptor |
protected boolean |
isDirty |
protected long |
lastFlushOffset |
protected java.lang.Runnable |
runPostFlush |
DataOutputPlus |
stream |
protected boolean |
syncNeeded |
| Constructor and Description |
|---|
SequentialWriter(java.io.File file,
int bufferSize,
BufferType bufferType) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Throwable |
abort(java.lang.Throwable accumulate) |
void |
close() |
java.lang.Throwable |
commit(java.lang.Throwable accumulate) |
protected long |
current() |
void |
deleteFile(boolean val) |
void |
finish() |
void |
flush()
If buffer is dirty, flush it's contents to the operating system.
|
protected void |
flushData()
Override this method instead of overriding flush()
|
protected void |
flushInternal() |
long |
getFilePointer() |
long |
getLastFlushOffset() |
long |
getOnDiskFilePointer()
Returns the current file pointer of the underlying on-disk file.
|
java.lang.String |
getPath() |
boolean |
isOpen() |
long |
length() |
FileMark |
mark() |
static SequentialWriter |
open(java.io.File file)
Open a heap-based, non-compressed SequentialWriter
|
static ChecksummedSequentialWriter |
open(java.io.File file,
java.io.File crcPath) |
static CompressedSequentialWriter |
open(java.lang.String dataFilePath,
java.lang.String offsetsPath,
CompressionParameters parameters,
MetadataCollector sstableMetadataCollector) |
void |
prepareToCommit() |
protected void |
reBuffer() |
void |
releaseFileHandle() |
void |
resetAndTruncate(FileMark mark)
Drops all buffered data that's past the limits of our new file mark + buffer capacity, or syncs and truncates
the underlying file to the marked position
|
protected void |
resetBuffer() |
SequentialWriter |
setDescriptor(Descriptor descriptor) |
void |
setPostFlushListener(java.lang.Runnable runPostFlush) |
void |
sync()
Synchronize file contents with disk.
|
protected void |
syncDataOnlyInternal() |
protected void |
syncInternal() |
void |
truncate(long toSize) |
protected SequentialWriter.TransactionalProxy |
txnProxy() |
void |
write(byte[] buffer) |
void |
write(byte[] data,
int offset,
int length) |
int |
write(java.nio.ByteBuffer src) |
void |
write(int value) |
protected boolean isDirty
protected boolean syncNeeded
protected java.nio.ByteBuffer buffer
protected long bufferOffset
protected final java.nio.channels.FileChannel channel
public final DataOutputPlus stream
protected long lastFlushOffset
protected java.lang.Runnable runPostFlush
protected Descriptor descriptor
public SequentialWriter(java.io.File file,
int bufferSize,
BufferType bufferType)
public static SequentialWriter open(java.io.File file)
public static ChecksummedSequentialWriter open(java.io.File file, java.io.File crcPath)
public static CompressedSequentialWriter open(java.lang.String dataFilePath, java.lang.String offsetsPath, CompressionParameters parameters, MetadataCollector sstableMetadataCollector)
public void write(int value)
throws java.nio.channels.ClosedChannelException
write in class java.io.OutputStreamjava.nio.channels.ClosedChannelExceptionpublic void write(byte[] buffer)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(byte[] data,
int offset,
int length)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic int write(java.nio.ByteBuffer src)
throws java.io.IOException
write in interface java.nio.channels.WritableByteChanneljava.io.IOExceptionpublic void sync()
protected void syncDataOnlyInternal()
protected void syncInternal()
public void flush()
flush in interface java.io.Flushableflush in class java.io.OutputStreamprotected void flushInternal()
public void setPostFlushListener(java.lang.Runnable runPostFlush)
protected void flushData()
FSWriteError - on any I/O error.public long getFilePointer()
public long getOnDiskFilePointer()
public long length()
public java.lang.String getPath()
protected void reBuffer()
protected void resetBuffer()
protected long current()
public FileMark mark()
public void resetAndTruncate(FileMark mark)
public long getLastFlushOffset()
public void truncate(long toSize)
public boolean isOpen()
isOpen in interface java.nio.channels.Channelpublic SequentialWriter setDescriptor(Descriptor descriptor)
public final void prepareToCommit()
prepareToCommit in interface Transactionalpublic final java.lang.Throwable commit(java.lang.Throwable accumulate)
commit in interface Transactionalpublic final java.lang.Throwable abort(java.lang.Throwable accumulate)
abort in interface Transactionalpublic final void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channelclose in class java.io.OutputStreampublic final void finish()
protected SequentialWriter.TransactionalProxy txnProxy()
public void deleteFile(boolean val)
public void releaseFileHandle()
Copyright © 2015 The Apache Software Foundation