当前位置: 首页>>代码示例>>Java>>正文


Java BZip2Constants类代码示例

本文整理汇总了Java中org.apache.hadoop.io.compress.bzip2.BZip2Constants的典型用法代码示例。如果您正苦于以下问题:Java BZip2Constants类的具体用法?Java BZip2Constants怎么用?Java BZip2Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BZip2Constants类属于org.apache.hadoop.io.compress.bzip2包,在下文中一共展示了BZip2Constants类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.apache.hadoop.io.compress.bzip2.BZip2Constants; //导入依赖的package包/类
/**
* This method updates compressed stream position exactly when the
* client of this code has read off at least one byte passed any BZip2
* end of block marker.
*
* This mechanism is very helpful to deal with data level record
* boundaries. Please see constructor and next methods of
* org.apache.hadoop.mapred.LineRecordReader as an example usage of this
* feature.  We elaborate it with an example in the following:
*
* Assume two different scenarios of the BZip2 compressed stream, where
* [m] represent end of block, \n is line delimiter and . represent compressed
* data.
*
* ............[m]......\n.......
*
* ..........\n[m]......\n.......
*
* Assume that end is right after [m].  In the first case the reading
* will stop at \n and there is no need to read one more line.  (To see the
* reason of reading one more line in the next() method is explained in LineRecordReader.)
* While in the second example LineRecordReader needs to read one more line
* (till the second \n).  Now since BZip2Codecs only update position
* at least one byte passed a maker, so it is straight forward to differentiate
* between the two cases mentioned.
*
*/

public int read(byte[] b, int off, int len) throws IOException {
  if (needsReset) {
    internalReset();
  }

  int result = 0;
  result = this.input.read(b, off, len);
  if (result == BZip2Constants.END_OF_BLOCK) {
    this.posSM = POS_ADVERTISEMENT_STATE_MACHINE.ADVERTISE;
  }

  if (this.posSM == POS_ADVERTISEMENT_STATE_MACHINE.ADVERTISE) {
    result = this.input.read(b, off, off + 1);
    // This is the precise time to update compressed stream position
    // to the client of this code.
    this.updatePos(true);
    this.posSM = POS_ADVERTISEMENT_STATE_MACHINE.HOLD;
  }

  return result;

}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:51,代码来源:BZip2Codec.java


注:本文中的org.apache.hadoop.io.compress.bzip2.BZip2Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。