Examples of HFileBlockEncodingContext


Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

    assertEquals(headerSize, cacheBlock.getDummyHeaderForVersion().length);
  }

  private HFileBlock createBlockOnDisk(HFileBlock block) throws IOException {
    int size;
    HFileBlockEncodingContext context = new HFileBlockDefaultEncodingContext(
        Compression.Algorithm.NONE, blockEncoder.getDataBlockEncoding(),
        HConstants.HFILEBLOCK_DUMMY_HEADER);
    context.setDummyHeader(block.getDummyHeaderForVersion());
    blockEncoder.beforeWriteToDisk(block.getBufferWithoutHeader(),
            includesMemstoreTS, context, block.getBlockType());
    byte[] encodedBytes = context.getUncompressedBytesWithHeader();
    size = encodedBytes.length - block.getDummyHeaderForVersion().length;
    return new HFileBlock(context.getBlockType(), size, size, -1,
            ByteBuffer.wrap(encodedBytes), HFileBlock.FILL_HEADER, 0, includesMemstoreTS,
            block.getMinorVersion(), block.getBytesPerChecksum(), block.getChecksumType(),
            block.getOnDiskDataSizeWithHeader());
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

    DataBlockEncoder encoder = encoding.getEncoder();
    int headerLen = dummyHeader.length;
    byte[] encodedResultWithHeader = null;
    if (encoder != null) {
      HFileBlockEncodingContext encodingCtx =
          encoder.newDataBlockEncodingContext(algo, encoding, dummyHeader);
      encoder.encodeKeyValues(rawBuf, includesMemstoreTS,
          encodingCtx);
      encodedResultWithHeader =
          encodingCtx.getUncompressedBytesWithHeader();
    } else {
      HFileBlockDefaultEncodingContext defaultEncodingCtx =
        new HFileBlockDefaultEncodingContext(algo, encoding, dummyHeader);
      byte[] rawBufWithHeader =
          new byte[rawBuf.array().length + headerLen];
View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

    DataBlockEncoder encoder = encoding.getEncoder();
    int headerLen = dummyHeader.length;
    byte[] encodedResultWithHeader = null;
    if (encoder != null) {
      HFileBlockEncodingContext encodingCtx =
          encoder.newDataBlockEncodingContext(algo, encoding, dummyHeader);
      encoder.encodeKeyValues(rawBuf, includesMemstoreTS,
          encodingCtx);
      encodedResultWithHeader =
          encodingCtx.getUncompressedBytesWithHeader();
    } else {
      HFileBlockDefaultEncodingContext defaultEncodingCtx =
        new HFileBlockDefaultEncodingContext(algo, encoding, dummyHeader);
      byte[] rawBufWithHeader =
          new byte[rawBuf.array().length + headerLen];
View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

    assertEquals(headerSize, cacheBlock.getDummyHeaderForVersion().length);
  }

  private HFileBlock createBlockOnDisk(HFileBlock block) throws IOException {
    int size;
    HFileBlockEncodingContext context = new HFileBlockDefaultEncodingContext(
        Compression.Algorithm.NONE, blockEncoder.getEncodingOnDisk(),
        HConstants.HFILEBLOCK_DUMMY_HEADER);
    context.setDummyHeader(block.getDummyHeaderForVersion());
    blockEncoder.beforeWriteToDisk(block.getBufferWithoutHeader(),
            includesMemstoreTS, context, block.getBlockType());
    byte[] encodedBytes = context.getUncompressedBytesWithHeader();
    size = encodedBytes.length - block.getDummyHeaderForVersion().length;
    return new HFileBlock(context.getBlockType(), size, size, -1,
            ByteBuffer.wrap(encodedBytes), HFileBlock.FILL_HEADER, 0, includesMemstoreTS,
            block.getMinorVersion(), block.getBytesPerChecksum(), block.getChecksumType(),
            block.getOnDiskDataSizeWithHeader());
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

    DataBlockEncoder encoder = encoding.getEncoder();
    int headerLen = dummyHeader.length;
    byte[] encodedResultWithHeader = null;
    if (encoder != null) {
      HFileBlockEncodingContext encodingCtx =
          encoder.newDataBlockEncodingContext(algo, encoding, dummyHeader);
      encoder.encodeKeyValues(rawBuf, includesMemstoreTS,
          encodingCtx);
      encodedResultWithHeader =
          encodingCtx.getUncompressedBytesWithHeader();
    } else {
      HFileBlockDefaultEncodingContext defaultEncodingCtx =
        new HFileBlockDefaultEncodingContext(algo, encoding, dummyHeader);
      byte[] rawBufWithHeader =
          new byte[rawBuf.array().length + headerLen];
View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

   */
  @Test
  public void testEncodingWritePath() throws IOException {
    // usually we have just block without headers, but don't complicate that
    HFileBlock block = getSampleHFileBlock();
    HFileBlockEncodingContext context = new HFileBlockDefaultEncodingContext(
        Compression.Algorithm.NONE, blockEncoder.getEncodingOnDisk(), HConstants.HFILEBLOCK_DUMMY_HEADER);
    blockEncoder.beforeWriteToDisk(block.getBufferWithoutHeader(),
            includesMemstoreTS, context, block.getBlockType());

    byte[] encodedBytes = context.getUncompressedBytesWithHeader();
    int size = encodedBytes.length - HConstants.HFILEBLOCK_HEADER_SIZE;
    HFileBlock blockOnDisk =
        new HFileBlock(context.getBlockType(), size, size, -1,
            ByteBuffer.wrap(encodedBytes), HFileBlock.FILL_HEADER, 0,
        includesMemstoreTS, block.getMinorVersion(),
        block.getBytesPerChecksum(), block.getChecksumType(),
        block.getOnDiskDataSizeWithHeader());

View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

  }

  private HFileBlock createBlockOnDisk(List<KeyValue> kvs, HFileBlock block, boolean useTags)
      throws IOException {
    int size;
    HFileBlockEncodingContext context = new HFileBlockDefaultEncodingContext(
        blockEncoder.getDataBlockEncoding(), HConstants.HFILEBLOCK_DUMMY_HEADER,
        block.getHFileContext());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(block.getDummyHeaderForVersion());
    DataOutputStream dos = new DataOutputStream(baos);
    blockEncoder.startBlockEncoding(context, dos);
    for (KeyValue kv : kvs) {
      blockEncoder.encode(kv, context, dos);
    }
    BufferGrabbingByteArrayOutputStream stream = new BufferGrabbingByteArrayOutputStream();
    baos.writeTo(stream);
    blockEncoder.endBlockEncoding(context, dos, stream.getBuffer(), BlockType.DATA);
    byte[] encodedBytes = baos.toByteArray();
    size = encodedBytes.length - block.getDummyHeaderForVersion().length;
    return new HFileBlock(context.getBlockType(), size, size, -1, ByteBuffer.wrap(encodedBytes),
        HFileBlock.FILL_HEADER, 0, block.getOnDiskDataSizeWithHeader(), block.getHFileContext());
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

    assertEquals(headerSize, cacheBlock.getDummyHeaderForVersion().length);
  }

  private HFileBlock createBlockOnDisk(HFileBlock block, boolean useTags) throws IOException {
    int size;
    HFileBlockEncodingContext context = new HFileBlockDefaultEncodingContext(
        blockEncoder.getDataBlockEncoding(),
        HConstants.HFILEBLOCK_DUMMY_HEADER, block.getHFileContext());
    context.setDummyHeader(block.getDummyHeaderForVersion());
    blockEncoder.beforeWriteToDisk(block.getBufferWithoutHeader(), context, block.getBlockType());
    byte[] encodedBytes = context.getUncompressedBytesWithHeader();
    size = encodedBytes.length - block.getDummyHeaderForVersion().length;
    return new HFileBlock(context.getBlockType(), size, size, -1,
            ByteBuffer.wrap(encodedBytes), HFileBlock.FILL_HEADER, 0,
            block.getOnDiskDataSizeWithHeader(), block.getHFileContext());
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

                        .withCompression(algo)
                        .withIncludesMvcc(includesMemstoreTS)
                        .withIncludesTags(useTag)
                        .build();
    if (encoder != null) {
      HFileBlockEncodingContext encodingCtx = encoder.newDataBlockEncodingContext(encoding,
          dummyHeader, meta);
      encoder.encodeKeyValues(rawBuf, encodingCtx);
      encodedResultWithHeader =
          encodingCtx.getUncompressedBytesWithHeader();
    } else {
      HFileBlockDefaultEncodingContext defaultEncodingCtx = new HFileBlockDefaultEncodingContext(
          encoding, dummyHeader, meta);
      byte[] rawBufWithHeader =
          new byte[rawBuf.array().length + headerLen];
View Full Code Here

Examples of org.apache.hadoop.hbase.io.encoding.HFileBlockEncodingContext

  }

  private HFileBlock createBlockOnDisk(List<KeyValue> kvs, HFileBlock block, boolean useTags)
      throws IOException {
    int size;
    HFileBlockEncodingContext context = new HFileBlockDefaultEncodingContext(
        blockEncoder.getDataBlockEncoding(), HConstants.HFILEBLOCK_DUMMY_HEADER,
        block.getHFileContext());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(block.getDummyHeaderForVersion());
    DataOutputStream dos = new DataOutputStream(baos);
    blockEncoder.startBlockEncoding(context, dos);
    for (KeyValue kv : kvs) {
      blockEncoder.encode(kv, context, dos);
    }
    BufferGrabbingByteArrayOutputStream stream = new BufferGrabbingByteArrayOutputStream();
    baos.writeTo(stream);
    blockEncoder.endBlockEncoding(context, dos, stream.getBuffer(), BlockType.DATA);
    byte[] encodedBytes = baos.toByteArray();
    size = encodedBytes.length - block.getDummyHeaderForVersion().length;
    return new HFileBlock(context.getBlockType(), size, size, -1, ByteBuffer.wrap(encodedBytes),
        HFileBlock.FILL_HEADER, 0, block.getOnDiskDataSizeWithHeader(), block.getHFileContext());
  }
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.