StreamWriter (apache-cassandra API)
Date: 2018-02-12

org.apache.cassandra.streaming

## Class StreamWriter

- java.lang.Object
- - org.apache.cassandra.streaming.StreamWriter

- Direct Known Subclasses:
    CompressedStreamWriter

      public class StreamWriter
      extends java.lang.Object

  StreamWriter writes given section of the SSTable to given channel.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected StreamManager.StreamRateLimiter` | `limiter`
    `protected java.util.Collection<Pair<java.lang.Long,java.lang.Long>>` | `sections`
    `protected StreamSession` | `session`
    `protected SSTableReader` | `sstable`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StreamWriter(SSTableReader sstable, java.util.Collection<Pair<java.lang.Long,java.lang.Long>> sections, StreamSession session)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected long` | `totalSize()`
    `void` | `write(DataOutputStreamPlus output)` Stream file of specified sections to given channel.
    `protected long` | `write(RandomAccessReader reader, DataIntegrityMetadata.ChecksumValidator validator, int start, long length, long bytesTransferred)` Sequentially read bytes from the file and write them to the output stream

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### sstable

          protected final SSTableReader sstable

    - #### sections

          protected final java.util.Collection<Pair<java.lang.Long,java.lang.Long>> sections

    - #### limiter

          protected final StreamManager.StreamRateLimiter limiter

    - #### session

          protected final StreamSession session

  - ### Constructor Detail

    - #### StreamWriter

          public StreamWriter(SSTableReader sstable,
                              java.util.Collection<Pair<java.lang.Long,java.lang.Long>> sections,
                              StreamSession session)

  - ### Method Detail

    - #### write

          public void write(DataOutputStreamPlus output)
                     throws java.io.IOException

      Stream file of specified sections to given channel. StreamWriter uses LZF compression on wire to decrease size to transfer.
      Parameters:
        `output` - where this writes data to
      Throws:
        `java.io.IOException` - on any I/O error

    - #### totalSize

          protected long totalSize()

    - #### write

          protected long write(RandomAccessReader reader,
                               DataIntegrityMetadata.ChecksumValidator validator,
                               int start,
                               long length,
                               long bytesTransferred)
                        throws java.io.IOException

      Sequentially read bytes from the file and write them to the output stream
      Parameters:
        `reader` - The file reader to read from
        `validator` - validator to verify data integrity
        `start` - number of bytes to skip transfer, but include for validation.
        `length` - The full length that should be read from `reader`
        `bytesTransferred` - Number of bytes already read out of `length`
      Returns:
        Number of bytes read
      Throws:
        `java.io.IOException` - on any I/O error

Copyright © 2018 The Apache Software Foundation