org.apache.hadoop.io.file.tfile.BCFile.Writer.BlockAppender Java Examples

The following examples show how to use org.apache.hadoop.io.file.tfile.BCFile.Writer.BlockAppender. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TFile.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
  }
}
 
Example #2
Source File: TFile.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
  }
}
 
Example #3
Source File: TFile.java    From RDFS with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
  }
}
 
Example #4
Source File: TFile.java    From hadoop-gpu with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
  }
}