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


Java BlockAppender类代码示例

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


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

示例1: close

import org.apache.hadoop.io.file.tfile.BCFile.Writer.BlockAppender; //导入依赖的package包/类
/**
 * Close the Writer. Resources will be released regardless of the exceptions
 * being thrown. Future close calls will have no effect.
 * 
 * The underlying FSDataOutputStream is not closed.
 */
@Override
public void close() throws IOException {
  if ((state == State.CLOSED)) {
    return;
  }
  try {
    // First try the normal finish.
    // Terminate upon the first Exception.
    if (errorCount == 0) {
      if (state != State.READY) {
        throw new IllegalStateException(
            "Cannot close TFile in the middle of key-value insertion.");
      }

      finishDataBlock(true);

      // first, write out data:TFile.meta
      BlockAppender outMeta =
          writerBCF
              .prepareMetaBlock(TFileMeta.BLOCK_NAME, COMPRESSION_NONE);
      try {
        tfileMeta.write(outMeta);
      } finally {
        outMeta.close();
      }

      // second, write out data:TFile.index
      BlockAppender outIndex =
          writerBCF.prepareMetaBlock(TFileIndex.BLOCK_NAME);
      try {
        tfileIndex.write(outIndex);
      } finally {
        outIndex.close();
      }

      writerBCF.close();
    }
  } finally {
    IOUtils.cleanup(LOG, blkAppender, writerBCF);
    blkAppender = null;
    writerBCF = null;
    state = State.CLOSED;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:51,代码来源:TFile.java

示例2: close

import org.apache.hadoop.io.file.tfile.BCFile.Writer.BlockAppender; //导入依赖的package包/类
/**
 * Close the Writer. Resources will be released regardless of the exceptions
 * being thrown. Future close calls will have no effect.
 * 
 * The underlying FSDataOutputStream is not closed.
 */
public void close() throws IOException {
  if ((state == State.CLOSED)) {
    return;
  }
  try {
    // First try the normal finish.
    // Terminate upon the first Exception.
    if (errorCount == 0) {
      if (state != State.READY) {
        throw new IllegalStateException(
            "Cannot close TFile in the middle of key-value insertion.");
      }

      finishDataBlock(true);

      // first, write out data:TFile.meta
      BlockAppender outMeta =
          writerBCF
              .prepareMetaBlock(TFileMeta.BLOCK_NAME, COMPRESSION_NONE);
      try {
        tfileMeta.write(outMeta);
      } finally {
        outMeta.close();
      }

      // second, write out data:TFile.index
      BlockAppender outIndex =
          writerBCF.prepareMetaBlock(TFileIndex.BLOCK_NAME);
      try {
        tfileIndex.write(outIndex);
      } finally {
        outIndex.close();
      }

writerBCF.close();
    }
  } finally {
    IOUtils.cleanup(LOG, blkAppender, writerBCF);
    blkAppender = null;
    writerBCF = null;
    state = State.CLOSED;
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:50,代码来源:TFile.java


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