org.apache.cassandra.io.util

## Class SegmentedFile

- java.lang.Object
- - org.apache.cassandra.io.util.SegmentedFile

- Direct Known Subclasses:
    BufferedSegmentedFile, CompressedSegmentedFile, MmappedSegmentedFile, PoolingSegmentedFile

      public abstract class SegmentedFile
      extends java.lang.Object

  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.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `long` | `length`
    `long` | `onDiskLength`
    `java.lang.String` | `path`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SegmentedFile(java.lang.String path, long length, long onDiskLength)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `cleanup()` Do whatever action is needed to reclaim ressources used by this SegmentedFile.
    `static SegmentedFile.Builder` | `getBuilder(Config.DiskAccessMode mode)`
    `static SegmentedFile.Builder` | `getCompressedBuilder()`
    `static SegmentedFile.Builder` | `getCompressedBuilder(CompressedSequentialWriter writer)`
    `abstract FileDataInput` | `getSegment(long position)`
    `java.util.Iterator<FileDataInput>` | `iterator(long position)`
    `java.lang.String` | `toString()`

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

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

- - ### Field Detail

    - #### path

          public final java.lang.String path

    - #### length

          public final long length

    - #### onDiskLength

          public final long onDiskLength

  - ### Constructor Detail

    - #### SegmentedFile

          protected SegmentedFile(java.lang.String path,
                       long length,
                       long onDiskLength)

  - ### Method Detail

    - #### getBuilder

          public static SegmentedFile.Builder getBuilder(Config.DiskAccessMode mode)

      Returns:
        A SegmentedFile.Builder.

    - #### getCompressedBuilder

          public static SegmentedFile.Builder getCompressedBuilder()

    - #### getCompressedBuilder

          public static SegmentedFile.Builder getCompressedBuilder(CompressedSequentialWriter writer)

    - #### getSegment

          public abstract FileDataInput getSegment(long position)

    - #### 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.

    - #### cleanup

          public abstract void cleanup()

      Do whatever action is needed to reclaim ressources used by this SegmentedFile.

    - #### toString

          public java.lang.String toString()

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

Copyright © 2014 The Apache Software Foundation