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

org.apache.cassandra.io.util

## Class SegmentedFile

- java.lang.Object
- - org.apache.cassandra.utils.concurrent.SharedCloseableImpl
  - - org.apache.cassandra.io.util.SegmentedFile

- All Implemented Interfaces:
    java.lang.AutoCloseable, SharedCloseable
  Direct Known Subclasses:
    BufferedSegmentedFile, CompressedSegmentedFile, MmappedSegmentedFile, PoolingSegmentedFile

      public abstract class SegmentedFile
      extends SharedCloseableImpl

  Abstracts a read-only file that has been split into segments, each of which can be represented by an independent FileDataInput. Allows for iteration over the FileDataInputs, or random access to the FileDataInput for a given position. The JVM can only map up to 2GB at a time, so each segment is at most that size when using mmap i/o. If a segment would need to be longer than 2GB, that segment will not be mmap'd, and a new RandomAccessFile will be created for each access to that segment.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SegmentedFile.Builder` Collects potential segmentation points in an underlying file, and builds a SegmentedFile to represent it.
    `protected static class` | `SegmentedFile.Cleanup`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `ChannelProxy` | `channel`
    `long` | `length`
    `long` | `onDiskLength`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SegmentedFile(SegmentedFile.Cleanup cleanup, ChannelProxy channel, long length, long onDiskLength)`
    `` | `SegmentedFile(SegmentedFile copy)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long[]` | `copyReadableBounds()` Retrieve the readable bounds if any so they can be cloned into other files such as when downsampling an index summary.
    `RandomAccessReader` | `createReader()`
    `RandomAccessReader` | `createThrottledReader(com.google.common.util.concurrent.RateLimiter limiter)`
    `void` | `dropPageCache(long before)`
    `static SegmentedFile.Builder` | `getBuilder(Config.DiskAccessMode mode, boolean compressed)`
    `static SegmentedFile.Builder` | `getCompressedBuilder(CompressedSequentialWriter writer)`
    `FileDataInput` | `getSegment(long position)`
    `java.util.Iterator<FileDataInput>` | `iterator(long position)`
    `java.lang.String` | `path()`
    `abstract SegmentedFile` | `sharedCopy()`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class org.apache.cassandra.utils.concurrent.SharedCloseableImpl

      `close, close, isCleanedUp`

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

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

- - ### Field Detail

    - #### channel

          public final ChannelProxy channel

    - #### length

          public final long length

    - #### onDiskLength

          public final long onDiskLength

  - ### Constructor Detail

    - #### SegmentedFile

          protected SegmentedFile(SegmentedFile.Cleanup cleanup,
                                  ChannelProxy channel,
                                  long length,
                                  long onDiskLength)

    - #### SegmentedFile

          public SegmentedFile(SegmentedFile copy)

  - ### Method Detail

    - #### path

          public java.lang.String path()

    - #### sharedCopy

          public abstract SegmentedFile sharedCopy()

      Returns:
        a new instance of the object representing the same state and backed by the same underlying resources. Coordinates with the original (and other instances) when the underlying resource should be closed. Throws an exception if the shared resource has already been closed.

    - #### createReader

          public RandomAccessReader createReader()

    - #### createThrottledReader

          public RandomAccessReader createThrottledReader(com.google.common.util.concurrent.RateLimiter limiter)

    - #### getSegment

          public FileDataInput getSegment(long position)

    - #### dropPageCache

          public void dropPageCache(long before)

    - #### getBuilder

          public static SegmentedFile.Builder getBuilder(Config.DiskAccessMode mode,
                                                         boolean compressed)

      Returns:
        A SegmentedFile.Builder.

    - #### getCompressedBuilder

          public static SegmentedFile.Builder getCompressedBuilder(CompressedSequentialWriter writer)

    - #### iterator

          public java.util.Iterator<FileDataInput> iterator(long position)

      Returns:
        An Iterator over segments, beginning with the segment containing the given position: each segment must be closed after use.

    - #### copyReadableBounds

          public long[] copyReadableBounds()

      Retrieve the readable bounds if any so they can be cloned into other files such as when downsampling an index summary. Readable bounds are in between record locations in a file that are good positions for mapping the file such that records don't cross mappings.

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

Copyright © 2018 The Apache Software Foundation