Package org.apache.hadoop.hbase.io.encoding

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


    public Writer(HFileDataBlockEncoder dataBlockEncoder, HFileContext meta) {
      super(dataBlockEncoder, meta);
      compressAlgo = meta.getCompression() == null ? NONE : meta.getCompression();
      this.dataBlockEncoder = dataBlockEncoder != null ? dataBlockEncoder
          : NoOpDataBlockEncoder.INSTANCE;
      defaultBlockEncodingCtx = new HFileBlockDefaultEncodingContext(null, DUMMY_HEADER, meta);
      dataBlockEncodingCtx = this.dataBlockEncoder.newDataBlockEncodingContext(DUMMY_HEADER, meta);
      baosInMemory = new ByteArrayOutputStream();

      prevOffsetByType = new long[BlockType.values().length];
      for (int i = 0; i < prevOffsetByType.length; ++i)
View Full Code Here


  }

  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

      byte[] dummyHeader, HFileContext fileContext) {
    DataBlockEncoder encoder = encoding.getEncoder();
    if (encoder != null) {
      return encoder.newDataBlockEncodingContext(encoding, dummyHeader, fileContext);
    }
    return new HFileBlockDefaultEncodingContext(null, dummyHeader, fileContext);
  }
View Full Code Here

              .withHBaseCheckSum(false)
              .withIncludesMvcc(includesMemstoreTS)
              .withIncludesTags(includesTag)
              .withCompression(compressionAlgorithm)
              .build();
      defaultBlockEncodingCtx = new HFileBlockDefaultEncodingContext(null, DUMMY_HEADER, meta);
      dataBlockEncodingCtx =
          this.dataBlockEncoder.newDataBlockEncodingContext(
              DUMMY_HEADER, meta);
      baosInMemory = new ByteArrayOutputStream();
View Full Code Here

          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];
      System.arraycopy(rawBuf.array(), 0, rawBufWithHeader,
          headerLen, rawBuf.array().length);
      defaultEncodingCtx.compressAfterEncodingWithBlockType(rawBufWithHeader,
          BlockType.DATA);
      encodedResultWithHeader =
        defaultEncodingCtx.getUncompressedBytesWithHeader();
    }
    final int encodedSize =
        encodedResultWithHeader.length - headerLen;
    if (encoder != null) {
      // We need to account for the two-byte encoding algorithm ID that
View Full Code Here

    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

TOP

Related Classes of org.apache.hadoop.hbase.io.encoding.HFileBlockDefaultEncodingContext

Copyright © 2018 www.massapicom. 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.