Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cassandra.io.util
Class SequentialWriter

    java.lang.Object
      java.io.OutputStream
          org.apache.cassandra.io.util.SequentialWriter

All Implemented Interfaces:
  java.io.Closeable, java.io.Flushable

Direct Known Subclasses:
  CompressedSequentialWriter

    public class SequentialWriter

extends java.io.OutputStream

Nested Class Summary
`protected static class` | `SequentialWriter.BufferedFileWriterMark` Class to hold a mark to the position of the file

Field Summary
`protected byte[]` | `buffer`
`protected long` | `bufferOffset`
`protected long` | `current`
`protected boolean` | `isDirty`
`protected java.io.RandomAccessFile` | `out`
`java.io.DataOutputStream` | `stream`
`protected boolean` | `syncNeeded`
`protected int` | `validBufferBytes`

Constructor Summary
`SequentialWriter(java.io.File file, int bufferSize, boolean skipIOCache)`

Method Summary
`void` | `close()`
`byte[]` | `digest()` Return the digest associated to this file or null if no digest was created.
`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` | `getOnDiskFilePointer()` Return the current file pointer of the underlying on-disk file.
`java.lang.String` | `getPath()`
`long` | `length()`
`FileMark` | `mark()`
`static SequentialWriter` | `open(java.io.File file)`
`static SequentialWriter` | `open(java.io.File file, boolean skipIOCache)`
`static SequentialWriter` | `open(java.io.File file, int bufferSize, boolean skipIOCache)`
`protected void` | `reBuffer()`
`void` | `resetAndTruncate(FileMark mark)`
`protected void` | `resetBuffer()`
`void` | `setComputeDigest()` Turn on digest computation on this writer.
`void` | `sync()` Synchronize file contents with disk.
`protected void` | `syncDataOnlyInternal()`
`protected void` | `syncInternal()`
`void` | `truncate(long toSize)`
`void` | `write(byte[] buffer)`
`void` | `write(byte[] data, int offset, int length)`
`void` | `write(int value)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### isDirty

    protected boolean isDirty

### syncNeeded

    protected boolean syncNeeded

### buffer

    protected byte[] buffer

### current

    protected long current

### bufferOffset

    protected long bufferOffset

### validBufferBytes

    protected int validBufferBytes

### out

    protected final java.io.RandomAccessFile out

### stream

    public final java.io.DataOutputStream stream

Constructor Detail

### SequentialWriter

    public SequentialWriter(java.io.File file,
                            int bufferSize,
                            boolean skipIOCache)
                     throws java.io.IOException

Throws:
  `java.io.IOException`

Method Detail

### open

    public static SequentialWriter open(java.io.File file)
                                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### open

    public static SequentialWriter open(java.io.File file,
                                        boolean skipIOCache)
                                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### open

    public static SequentialWriter open(java.io.File file,
                                        int bufferSize,
                                        boolean skipIOCache)
                                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### write

    public void write(int value)
               throws java.io.IOException

  Specified by:
    `write` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException`

### write

    public void write(byte[] buffer)
               throws java.io.IOException

  Overrides:
    `write` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException`

### write

    public void write(byte[] data,
                      int offset,
                      int length)
               throws java.io.IOException

  Overrides:
    `write` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException`

### sync

    public void sync()
              throws java.io.IOException

  Synchronize file contents with disk.

  Throws:
    `java.io.IOException` - on any I/O error.

### syncDataOnlyInternal

    protected void syncDataOnlyInternal()
                                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### syncInternal

    protected void syncInternal()
                         throws java.io.IOException

  Throws:
    `java.io.IOException`

### flush

    public void flush()
               throws java.io.IOException

  If buffer is dirty, flush it's contents to the operating system. Does not imply fsync(). Currently, for implementation reasons, this also invalidates the buffer.

  Specified by:
    `flush` in interface `java.io.Flushable`
  Overrides:
    `flush` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException` - on any I/O error.

### flushInternal

    protected void flushInternal()
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### flushData

    protected void flushData()
                      throws java.io.IOException

  Override this method instead of overriding flush()

  Throws:
    `java.io.IOException` - on any I/O error.

### getFilePointer

    public long getFilePointer()

### getOnDiskFilePointer

    public long getOnDiskFilePointer()
                              throws java.io.IOException

  Return 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

  Throws:
    `java.io.IOException`

### length

    public long length()
                throws java.io.IOException

  Throws:
    `java.io.IOException`

### getPath

    public java.lang.String getPath()

### reBuffer

    protected void reBuffer()
                     throws java.io.IOException

  Throws:
    `java.io.IOException`

### resetBuffer

    protected void resetBuffer()

### mark

    public FileMark mark()

### resetAndTruncate

    public void resetAndTruncate(FileMark mark)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### truncate

    public void truncate(long toSize)
                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### close

    public void close()
               throws java.io.IOException

  Specified by:
    `close` in interface `java.io.Closeable`
  Overrides:
    `close` in class `java.io.OutputStream`
  Throws:
    `java.io.IOException`

### setComputeDigest

    public void setComputeDigest()

  Turn on digest computation on this writer. This can only be called before any data is written to this write, otherwise an IllegalStateException is thrown.

### digest

    public byte[] digest()

  Return the digest associated to this file or null if no digest was created. This can only be called once the file is fully created, i.e. after close() has been called. Otherwise an IllegalStateException is thrown.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013 The Apache Software Foundation