Java 类org.apache.hadoop.io.compress.bzip2.CBZip2InputStream 实例源码

项目:hadoop-oss    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:hadoop    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:aliyun-oss-hadoop-fs    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:big-c    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:hadoop-plus    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:hops    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:hadoop-TCP    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:hardfs    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:hadoop-on-lustre2    文件:BZip2Codec.java   
public BZip2CompressionInputStream(InputStream in, long start, long end,
    READ_MODE readMode) throws IOException {
  super(in, start, end);
  needsReset = false;
  bufferedIn = new BufferedInputStream(super.in);
  this.startingPos = super.getPos();
  this.readMode = readMode;
  if (this.startingPos == 0) {
    // We only strip header if it is start of file
    bufferedIn = readStreamHeader();
  }
  input = new CBZip2InputStream(bufferedIn, readMode);
  if (this.isHeaderStripped) {
    input.updateReportedByteCount(HEADER_LEN);
  }

  if (this.isSubHeaderStripped) {
    input.updateReportedByteCount(SUB_HEADER_LEN);
  }

  this.updatePos(false);
}
项目:hadoop-oss    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:hadoop    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:aliyun-oss-hadoop-fs    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:big-c    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:hadoop-EAR    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn);
  }
}
项目:hadoop-plus    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:hops    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:hadoop-TCP    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:hadoop-on-lustre    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn);
  }
}
项目:hardfs    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:hadoop-on-lustre2    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn, this.readMode);
  }
}
项目:RDFS    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn);
  }
}
项目:hadoop-0.20    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn);
  }
}
项目:hortonworks-extension    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn);
  }
}
项目:hortonworks-extension    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn);
  }
}
项目:hadoop-gpu    文件:BZip2Codec.java   
private void internalReset() throws IOException {
  if (needsReset) {
    needsReset = false;
    BufferedInputStream bufferedIn = readStreamHeader();
    input = new CBZip2InputStream(bufferedIn);
  }
}
项目:hadoop-oss    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() < start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:hadoop    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() < start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:aliyun-oss-hadoop-fs    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() < start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:big-c    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() < start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() < start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:hadoop-plus    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() <= start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:hops    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = 0L;
  if (start != 0) {
    // Other than the first of file, the marker size is 6 bytes.
    adjStart = Math.max(0L, start - (FIRST_BZIP2_BLOCK_MARKER_POSITION
        - (HEADER_LEN + SUB_HEADER_LEN)));
  }

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() < start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:hadoop-TCP    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() <= start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:hardfs    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() <= start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}
项目:hadoop-on-lustre2    文件:BZip2Codec.java   
/**
 * Creates CompressionInputStream to be used to read off uncompressed data
 * in one of the two reading modes. i.e. Continuous or Blocked reading modes
 *
 * @param seekableIn The InputStream
 * @param start The start offset into the compressed stream
 * @param end The end offset into the compressed stream
 * @param readMode Controls whether progress is reported continuously or
 *                 only at block boundaries.
 *
 * @return CompressionInputStream for BZip2 aligned at block boundaries
 */
public SplitCompressionInputStream createInputStream(InputStream seekableIn,
    Decompressor decompressor, long start, long end, READ_MODE readMode)
    throws IOException {

  if (!(seekableIn instanceof Seekable)) {
    throw new IOException("seekableIn must be an instance of " +
        Seekable.class.getName());
  }

  //find the position of first BZip2 start up marker
  ((Seekable)seekableIn).seek(0);

  // BZip2 start of block markers are of 6 bytes.  But the very first block
  // also has "BZh9", making it 10 bytes.  This is the common case.  But at
  // time stream might start without a leading BZ.
  final long FIRST_BZIP2_BLOCK_MARKER_POSITION =
    CBZip2InputStream.numberOfBytesTillNextMarker(seekableIn);
  long adjStart = Math.max(0L, start - FIRST_BZIP2_BLOCK_MARKER_POSITION);

  ((Seekable)seekableIn).seek(adjStart);
  SplitCompressionInputStream in =
    new BZip2CompressionInputStream(seekableIn, adjStart, end, readMode);


  // The following if clause handles the following case:
  // Assume the following scenario in BZip2 compressed stream where
  // . represent compressed data.
  // .....[48 bit Block].....[48 bit   Block].....[48 bit Block]...
  // ........................[47 bits][1 bit].....[48 bit Block]...
  // ................................^[Assume a Byte alignment here]
  // ........................................^^[current position of stream]
  // .....................^^[We go back 10 Bytes in stream and find a Block marker]
  // ........................................^^[We align at wrong position!]
  // ...........................................................^^[While this pos is correct]

  if (in.getPos() <= start) {
    ((Seekable)seekableIn).seek(start);
    in = new BZip2CompressionInputStream(seekableIn, start, end, readMode);
  }

  return in;
}