Package org.apache.hadoop.fs

Examples of org.apache.hadoop.fs.FSDataInputStream.seek()


    FileSystem fs = FileSystem.get(uri, conf);
    FSDataInputStream in = null;
    try {
      in = fs.open(new Path(filename));
      if (fileOffset > 0) {
        in.seek(fileOffset);
      }
      in.readFully(buf, bufOffset, len);
    } finally {
      IOUtils.closeStream(in);
    }
View Full Code Here


      end = Long.MAX_VALUE;
    } else {
      if (start != 0) {
        skipFirstLine = true;
        --start;
        fileIn.seek(start);
      }
      in = new LineReader(fileIn, job);
    }
    if (skipFirstLine) {  // skip first line and re-establish "start".
      start += in.readLine(new Text());
View Full Code Here

         * send it to the reducer.
         */
        //open the map-output file
        mapOutputIn = fileSys.open(mapOutputFileName);
        //seek to the correct offset for the reduce
        mapOutputIn.seek(startOffset);
         
        long totalRead = 0;
        int len = mapOutputIn.read(buffer, 0,
                                   partLength < MAX_BYTES_TO_READ
                                   ? (int)partLength : MAX_BYTES_TO_READ);
View Full Code Here

        for (int parts = 0; parts < partitions; parts++){
          List<SegmentDescriptor> segmentList =
            new ArrayList<SegmentDescriptor>(numSpills);
          for(int i = 0; i < numSpills; i++) {
            FSDataInputStream indexIn = localFs.open(indexFileName[i]);
            indexIn.seek(parts * 16);
            long segmentOffset = indexIn.readLong();
            long segmentLength = indexIn.readLong();
            indexIn.close();
            SegmentDescriptor s = sorter.new SegmentDescriptor(segmentOffset,
                                                               segmentLength, filename[i]);
View Full Code Here

          String key = file.readUTF();
          String value = file.readUTF();
          opts.put(key, value);
        }
      } else {
        file.seek(0);
        return file;
      }
      return file;
    } catch (IOException ex) {
      file.seek(0);
View Full Code Here

        file.seek(0);
        return file;
      }
      return file;
    } catch (IOException ex) {
      file.seek(0);
      return file;
    }
  }

  @SuppressWarnings("deprecation")
View Full Code Here

    else
    {
      if (start != 0) //TODO: start is always zero?
      {
            --start;
            _input.seek(start);
      }
      internalInputStream = inputStream = new CountingInputStream(_input, start);
    }
    Collection rtr = CollectionFactory.loadCollection(
      ApplicationSetup.getProperty("trec.collection.class", "TRECCollection"),
View Full Code Here

          inputs[i] = new FSDataInputStream(new RaidUtils.ZeroInputStream(
              offset + blockSize));
        } else {
          FSDataInputStream in = parityFs.open(
              parityFile, conf.getInt("io.file.buffer.size", 64 * 1024));
          in.seek(offset);
          LOG.info("Adding " + parityFile + ":" + offset + " as input " + i);
          inputs[i] = in;
        }
      }
      // Now open streams to the data blocks.
View Full Code Here

          inputs[i] = new FSDataInputStream(new RaidUtils.ZeroInputStream(
              offset + blockSize));
        } else {
          FSDataInputStream in = fs.open(
            srcFile, conf.getInt("io.file.buffer.size", 64 * 1024));
          in.seek(offset);
          LOG.info("Adding " + srcFile + ":" + offset + " as input " + i);
          inputs[i] = in;
        }
      }
      if (erasedLocations.size() > paritySize) {
View Full Code Here

    try {
      for (int i = 0; i < codec.stripeLength; i++) {
        long seekOffset = stripeStartOffset + i * blockSize;
        if (seekOffset < srcSize) {
          FSDataInputStream in = fs.open(srcFile, bufferSize);
          in.seek(seekOffset);
          LOG.info("Opening stream at " + srcFile + ":" + seekOffset);
          blocks[i] = in;
        } else {
          LOG.info("Using zeros at offset " + seekOffset);
          // We have no src data at this offset.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.