org.apache.hadoop.mapreduce.lib.input

## Class FileSplit

- java.lang.Object
- - org.apache.hadoop.mapreduce.InputSplit
  - - org.apache.hadoop.mapreduce.lib.input.FileSplit

- All Implemented Interfaces:
    org.apache.hadoop.io.Writable

      @InterfaceAudience.Public
       @InterfaceStability.Stable
      public class FileSplit
      extends InputSplit
      implements org.apache.hadoop.io.Writable

  A section of an input file. Returned by `InputFormat.getSplits(JobContext)` and passed to `InputFormat.createRecordReader(InputSplit,TaskAttemptContext)`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileSplit()`
    `FileSplit(org.apache.hadoop.fs.Path file, long start, long length, String[] hosts)` Constructs a split with host information
    `FileSplit(org.apache.hadoop.fs.Path file, long start, long length, String[] hosts, String[] inMemoryHosts)` Constructs a split with host and cached-blocks information

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getLength()` The number of bytes in the file to process.
    `SplitLocationInfo[]` | `getLocationInfo()` Gets info about which nodes the input split is stored on and how it is stored at each location.
    `String[]` | `getLocations()` Get the list of nodes by name where the data for the split would be local.
    `org.apache.hadoop.fs.Path` | `getPath()` The file containing this split's data.
    `long` | `getStart()` The position of the first byte in the file to process.
    `void` | `readFields(DataInput in)`
    `String` | `toString()`
    `void` | `write(DataOutput out)`

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

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

- - ### Constructor Detail

    - #### FileSplit

          public FileSplit()

    - #### FileSplit

          public FileSplit(org.apache.hadoop.fs.Path file,
                           long start,
                           long length,
                           String[] hosts)

      Constructs a split with host information
      Parameters:
        `file` - the file name
        `start` - the position of the first byte in the file to process
        `length` - the number of bytes in the file to process
        `hosts` - the list of hosts containing the block, possibly null

    - #### FileSplit

          public FileSplit(org.apache.hadoop.fs.Path file,
                           long start,
                           long length,
                           String[] hosts,
                           String[] inMemoryHosts)

      Constructs a split with host and cached-blocks information
      Parameters:
        `file` - the file name
        `start` - the position of the first byte in the file to process
        `length` - the number of bytes in the file to process
        `hosts` - the list of hosts containing the block
        `inMemoryHosts` - the list of hosts containing the block in memory

  - ### Method Detail

    - #### getPath

          public org.apache.hadoop.fs.Path getPath()

      The file containing this split's data.

    - #### getStart

          public long getStart()

      The position of the first byte in the file to process.

    - #### getLength

          public long getLength()

      The number of bytes in the file to process.
      Specified by:
        `getLength` in class `InputSplit`
      Returns:
        the number of bytes in the split

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### write

          public void write(DataOutput out)
                     throws IOException

      Specified by:
        `write` in interface `org.apache.hadoop.io.Writable`
      Throws:
        `IOException`

    - #### readFields

          public void readFields(DataInput in)
                          throws IOException

      Specified by:
        `readFields` in interface `org.apache.hadoop.io.Writable`
      Throws:
        `IOException`

    - #### getLocations

          public String[] getLocations()
                                throws IOException

      Description copied from class: `InputSplit`
      Get the list of nodes by name where the data for the split would be local. The locations do not need to be serialized.
      Specified by:
        `getLocations` in class `InputSplit`
      Returns:
        a new array of the node nodes.
      Throws:
        `IOException`

    - #### getLocationInfo

          @InterfaceStability.Evolving
          public SplitLocationInfo[] getLocationInfo()
                                                                           throws IOException

      Description copied from class: `InputSplit`
      Gets info about which nodes the input split is stored on and how it is stored at each location.
      Overrides:
        `getLocationInfo` in class `InputSplit`
      Returns:
        list of `SplitLocationInfo`s describing how the split data is stored at each location. A null value indicates that all the locations have the data stored on disk.
      Throws:
        `IOException`

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.