Package org.apache.cassandra.io.compress
Class CompressedSequentialWriter
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.cassandra.io.util.DataOutputStreamPlus
-
- org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
-
- org.apache.cassandra.io.util.SequentialWriter
-
- org.apache.cassandra.io.compress.CompressedSequentialWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataOutput
,java.io.Flushable
,java.lang.AutoCloseable
,DataOutputPlus
,Transactional
public class CompressedSequentialWriter extends SequentialWriter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
CompressedSequentialWriter.CompressedFileWriterMark
Class to hold a mark to the position of the fileprotected class
CompressedSequentialWriter.TransactionalProxy
-
Nested classes/interfaces inherited from class org.apache.cassandra.io.util.SequentialWriter
SequentialWriter.BufferedFileWriterMark
-
Nested classes/interfaces inherited from interface org.apache.cassandra.utils.concurrent.Transactional
Transactional.AbstractTransactional
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.io.util.SequentialWriter
bufferOffset, fchannel, lastFlushOffset, runPostFlush
-
Fields inherited from class org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
buffer
-
Fields inherited from class org.apache.cassandra.io.util.DataOutputStreamPlus
channel
-
-
Constructor Summary
Constructors Constructor Description CompressedSequentialWriter(File file, File offsetsFile, File digestFile, SequentialWriterOption option, CompressionParams parameters, MetadataCollector sstableMetadataCollector)
Create CompressedSequentialWriter without digest file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
bytesLeftInPage()
Returns how many bytes are left in the page.void
flush()
protected void
flushData()
Override this method instead of overriding flush()long
getEstimatedOnDiskBytesWritten()
Get a quick estimation on how many bytes have been written to disk It should for the most part be exactly the same as getOnDiskFilePointer()long
getOnDiskFilePointer()
Returns the current file pointer of the underlying on-disk file.DataPosition
mark()
int
maxBytesInPage()
Returns the number of bytes that a page can take at maximum.CompressionMetadata
open(long overrideLength)
long
paddedPosition()
Returns the next padded position.void
padToPageBoundary()
Pad this with zeroes until the next page boundary.void
resetAndTruncate(DataPosition 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 positionprotected SequentialWriter.TransactionalProxy
txnProxy()
-
Methods inherited from class org.apache.cassandra.io.util.SequentialWriter
abort, close, commit, current, doFlush, finish, getFile, getLastFlushOffset, getPath, hasPosition, isOpen, length, position, prepareToCommit, resetBuffer, setPostFlushListener, skipBytes, sync, syncDataOnlyInternal, syncInternal, truncate, writeDirectlyToChannel
-
Methods inherited from class org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
allocate, order, write, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeMostSignificantBytes, writeShort, writeUTF
-
Methods inherited from class org.apache.cassandra.io.util.DataOutputStreamPlus
newDefaultChannel, retrieveTemporaryBuffer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.io.util.DataOutputPlus
write, writeUnsignedVInt, writeUnsignedVInt, writeUnsignedVInt32, writeVInt, writeVInt, writeVInt32
-
-
-
-
Constructor Detail
-
CompressedSequentialWriter
public CompressedSequentialWriter(File file, File offsetsFile, File digestFile, SequentialWriterOption option, CompressionParams parameters, MetadataCollector sstableMetadataCollector)
Create CompressedSequentialWriter without digest file.- Parameters:
file
- File to writeoffsetsFile
- File to write compression metadatadigestFile
- File to write digestoption
- Write option (buffer size and type will be set the same as compression params)parameters
- Compression mparameterssstableMetadataCollector
- Metadata collector
-
-
Method Detail
-
getOnDiskFilePointer
public long getOnDiskFilePointer()
Description copied from class:SequentialWriter
Returns the current file pointer of the underlying on-disk file. Note that since write works by buffering data, the value of this will increase by buffer size and not every write to the writer will modify this value. Furthermore, for compressed files, this value refers to compressed data, while the writer getFilePointer() refers to uncompressedFile- Overrides:
getOnDiskFilePointer
in classSequentialWriter
- Returns:
- the current file pointer
-
getEstimatedOnDiskBytesWritten
public long getEstimatedOnDiskBytesWritten()
Get a quick estimation on how many bytes have been written to disk It should for the most part be exactly the same as getOnDiskFilePointer()- Overrides:
getEstimatedOnDiskBytesWritten
in classSequentialWriter
-
flush
public void flush()
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classBufferedDataOutputStreamPlus
-
flushData
protected void flushData()
Description copied from class:SequentialWriter
Override this method instead of overriding flush()- Overrides:
flushData
in classSequentialWriter
-
open
public CompressionMetadata open(long overrideLength)
-
mark
public DataPosition mark()
- Overrides:
mark
in classSequentialWriter
-
resetAndTruncate
public void resetAndTruncate(DataPosition mark)
Description copied from class:SequentialWriter
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- Overrides:
resetAndTruncate
in classSequentialWriter
-
maxBytesInPage
public int maxBytesInPage()
Description copied from interface:DataOutputPlus
Returns the number of bytes that a page can take at maximum.- Specified by:
maxBytesInPage
in interfaceDataOutputPlus
- Overrides:
maxBytesInPage
in classSequentialWriter
-
padToPageBoundary
public void padToPageBoundary()
Description copied from interface:DataOutputPlus
Pad this with zeroes until the next page boundary. If the destination position is already at a page boundary, do not do anything.- Specified by:
padToPageBoundary
in interfaceDataOutputPlus
- Overrides:
padToPageBoundary
in classSequentialWriter
-
bytesLeftInPage
public int bytesLeftInPage()
Description copied from interface:DataOutputPlus
Returns how many bytes are left in the page.- Specified by:
bytesLeftInPage
in interfaceDataOutputPlus
- Overrides:
bytesLeftInPage
in classSequentialWriter
-
paddedPosition
public long paddedPosition()
Description copied from interface:DataOutputPlus
Returns the next padded position. This is either the current position (if already padded), or the start of next page.- Specified by:
paddedPosition
in interfaceDataOutputPlus
- Overrides:
paddedPosition
in classSequentialWriter
-
txnProxy
protected SequentialWriter.TransactionalProxy txnProxy()
- Overrides:
txnProxy
in classSequentialWriter
-
-