Пример #1
0
  /**
   * Get block locations from the underlying fs and fix their offsets and lengths.
   *
   * @param file the input file status to get block locations
   * @param start the start of the desired range in the contained file
   * @param len the length of the desired range
   * @return block locations for this segment of file
   * @throws IOException
   */
  @Override
  public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len)
      throws IOException {
    HarStatus hstatus = getFileHarStatus(file.getPath());
    Path partPath = new Path(archivePath, hstatus.getPartName());
    FileStatus partStatus = metadata.getPartFileStatus(partPath);

    // get all part blocks that overlap with the desired file blocks
    BlockLocation[] locations =
        fs.getFileBlockLocations(partStatus, hstatus.getStartIndex() + start, len);

    return fixBlockLocations(locations, start, len, hstatus.getStartIndex());
  }
Пример #2
0
 /**
  * Returns a har input stream which fakes end of file. It reads the index files to get the part
  * file name and the size and start of the file.
  */
 @Override
 public FSDataInputStream open(Path f, int bufferSize) throws IOException {
   // get the fs DataInputStream for the underlying file
   HarStatus hstatus = getFileHarStatus(f);
   if (hstatus.isDir()) {
     throw new FileNotFoundException(f + " : not a file in " + archivePath);
   }
   return new HarFSDataInputStream(
       fs,
       new Path(archivePath, hstatus.getPartName()),
       hstatus.getStartIndex(),
       hstatus.getLength(),
       bufferSize);
 }