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


Java ByteBufferUtils.readVLong方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.util.ByteBufferUtils.readVLong方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBufferUtils.readVLong方法的具体用法?Java ByteBufferUtils.readVLong怎么用?Java ByteBufferUtils.readVLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.util.ByteBufferUtils的用法示例。


在下文中一共展示了ByteBufferUtils.readVLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nextShallowCopy

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Creates a new KeyValue object positioned in the supplied ByteBuffer and sets the ByteBuffer's
 * position to the start of the next KeyValue. Does not allocate a new array or copy data.
 */
public static KeyValue nextShallowCopy(final ByteBuffer bb, final boolean includesMvccVersion) {
  if (bb.isDirect()) {
    throw new IllegalArgumentException("only supports heap buffers");
  }
  if (bb.remaining() < 1) {
    return null;
  }
  int underlyingArrayOffset = bb.arrayOffset() + bb.position();
  int keyLength = bb.getInt();
  int valueLength = bb.getInt();
  int kvLength = KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE + keyLength + valueLength;
  KeyValue keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength);
  ByteBufferUtils.skip(bb, keyLength + valueLength);
  if (includesMvccVersion) {
    long mvccVersion = ByteBufferUtils.readVLong(bb);
    keyValue.setMvccVersion(mvccVersion);
  }
  return keyValue;
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:24,代码来源:KeyValueUtil.java

示例2: nextShallowCopy

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Creates a new KeyValue object positioned in the supplied ByteBuffer and sets the ByteBuffer's
 * position to the start of the next KeyValue. Does not allocate a new array or copy data.
 * @param bb
 * @param includesMvccVersion
 * @param includesTags
 */
public static KeyValue nextShallowCopy(final ByteBuffer bb, final boolean includesMvccVersion,
    boolean includesTags) {
  if (bb.isDirect()) {
    throw new IllegalArgumentException("only supports heap buffers");
  }
  if (bb.remaining() < 1) {
    return null;
  }
  KeyValue keyValue = null;
  int underlyingArrayOffset = bb.arrayOffset() + bb.position();
  int keyLength = bb.getInt();
  int valueLength = bb.getInt();
  ByteBufferUtils.skip(bb, keyLength + valueLength);
  int tagsLength = 0;
  if (includesTags) {
    // Read short as unsigned, high byte first
    tagsLength = ((bb.get() & 0xff) << 8) ^ (bb.get() & 0xff);
    ByteBufferUtils.skip(bb, tagsLength);
  }
  int kvLength = (int) KeyValue.getKeyValueDataStructureSize(keyLength, valueLength, tagsLength);
  keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength);
  if (includesMvccVersion) {
    long mvccVersion = ByteBufferUtils.readVLong(bb);
    keyValue.setSequenceId(mvccVersion);
  }
  return keyValue;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:KeyValueUtil.java

示例3: createSeeker

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public EncodedSeeker createSeeker(KVComparator comparator,
    final HFileBlockDecodingContext decodingCtx) {
  return new BufferedEncodedSeeker<SeekerState>(comparator, decodingCtx) {
    @Override
    protected void decodeNext() {
      current.keyLength = currentBuffer.getInt();
      current.valueLength = currentBuffer.getInt();
      current.ensureSpaceForKey();
      currentBuffer.get(current.keyBuffer, 0, current.keyLength);
      current.valueOffset = currentBuffer.position();
      ByteBufferUtils.skip(currentBuffer, current.valueLength);
      if (includesTags()) {
        // Read short as unsigned, high byte first
        current.tagsLength = ((currentBuffer.get() & 0xff) << 8) ^ (currentBuffer.get() & 0xff);
        ByteBufferUtils.skip(currentBuffer, current.tagsLength);
      }
      if (includesMvcc()) {
        current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer);
      } else {
        current.memstoreTS = 0;
      }
      current.nextKvOffset = currentBuffer.position();
    }

    @Override
    protected void decodeFirst() {
      ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT);
      current.lastCommonPrefix = 0;
      decodeNext();
    }
  };
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:CopyKeyDataBlockEncoder.java

示例4: createSeeker

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public EncodedSeeker createSeeker(KVComparator comparator,
    final HFileBlockDecodingContext decodingCtx) {
  return new BufferedEncodedSeeker<SeekerState>(comparator, decodingCtx) {
    @Override
    protected void decodeNext() {
      current.keyLength = ByteBufferUtils.readCompressedInt(currentBuffer);
      current.valueLength = ByteBufferUtils.readCompressedInt(currentBuffer);
      current.lastCommonPrefix =
          ByteBufferUtils.readCompressedInt(currentBuffer);
      current.keyLength += current.lastCommonPrefix;
      current.ensureSpaceForKey();
      currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,
          current.keyLength - current.lastCommonPrefix);
      current.valueOffset = currentBuffer.position();
      ByteBufferUtils.skip(currentBuffer, current.valueLength);
      if (includesTags()) {
        decodeTags();
      }
      if (includesMvcc()) {
        current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer);
      } else {
        current.memstoreTS = 0;
      }
      current.nextKvOffset = currentBuffer.position();
    }

    @Override
    protected void decodeFirst() {
      ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT);
      decodeNext();
    }
  };
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:PrefixKeyDeltaEncoder.java

示例5: createSeeker

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public EncodedSeeker createSeeker(RawComparator<byte[]> comparator,
    final boolean includesMemstoreTS) {
  return new BufferedEncodedSeeker<SeekerState>(comparator) {
    @Override
    protected void decodeNext() {
      current.keyLength = currentBuffer.getInt();
      current.valueLength = currentBuffer.getInt();
      current.ensureSpaceForKey();
      currentBuffer.get(current.keyBuffer, 0, current.keyLength);
      current.valueOffset = currentBuffer.position();
      ByteBufferUtils.skip(currentBuffer, current.valueLength);
      if (includesMemstoreTS) {
        current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer);
      } else {
        current.memstoreTS = 0;
      }
      current.nextKvOffset = currentBuffer.position();
    }

    @Override
    protected void decodeFirst() {
      ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT);
      current.lastCommonPrefix = 0;
      decodeNext();
    }
  };
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:29,代码来源:CopyKeyDataBlockEncoder.java

示例6: afterEncodingKeyValue

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
protected final void afterEncodingKeyValue(ByteBuffer in,
    DataOutputStream out, boolean includesMemstoreTS) {
  if (includesMemstoreTS) {
    // Copy memstore timestamp from the byte buffer to the output stream.
    long memstoreTS = -1;
    try {
      memstoreTS = ByteBufferUtils.readVLong(in);
      WritableUtils.writeVLong(out, memstoreTS);
    } catch (IOException ex) {
      throw new RuntimeException("Unable to copy memstore timestamp " +
          memstoreTS + " after encoding a key/value");
    }
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:15,代码来源:BufferedDataBlockEncoder.java

示例7: createSeeker

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public EncodedSeeker createSeeker(RawComparator<byte[]> comparator,
    final boolean includesMemstoreTS) {
  return new BufferedEncodedSeeker<SeekerState>(comparator) {
    @Override
    protected void decodeNext() {
      current.keyLength = ByteBufferUtils.readCompressedInt(currentBuffer);
      current.valueLength = ByteBufferUtils.readCompressedInt(currentBuffer);
      current.lastCommonPrefix =
          ByteBufferUtils.readCompressedInt(currentBuffer);
      current.keyLength += current.lastCommonPrefix;
      current.ensureSpaceForKey();
      currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,
          current.keyLength - current.lastCommonPrefix);
      current.valueOffset = currentBuffer.position();
      ByteBufferUtils.skip(currentBuffer, current.valueLength);
      if (includesMemstoreTS) {
        current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer);
      } else {
        current.memstoreTS = 0;
      }
      current.nextKvOffset = currentBuffer.position();
    }

    @Override
    protected void decodeFirst() {
      ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT);
      decodeNext();
    }
  };
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:32,代码来源:PrefixKeyDeltaEncoder.java

示例8: nextShallowCopy

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Creates a new KeyValue object positioned in the supplied ByteBuffer and sets the ByteBuffer's
 * position to the start of the next KeyValue. Does not allocate a new array or copy data.
 * @param bb
 * @param includesMvccVersion
 * @param includesTags 
 */
public static KeyValue nextShallowCopy(final ByteBuffer bb, final boolean includesMvccVersion,
    boolean includesTags) {
  if (bb.isDirect()) {
    throw new IllegalArgumentException("only supports heap buffers");
  }
  if (bb.remaining() < 1) {
    return null;
  }
  KeyValue keyValue = null;
  int underlyingArrayOffset = bb.arrayOffset() + bb.position();
  int keyLength = bb.getInt();
  int valueLength = bb.getInt();
  ByteBufferUtils.skip(bb, keyLength + valueLength);
  int tagsLength = 0;
  if (includesTags) {
    // Read short as unsigned, high byte first
    tagsLength = ((bb.get() & 0xff) << 8) ^ (bb.get() & 0xff);
    ByteBufferUtils.skip(bb, tagsLength);
  }
  int kvLength = (int) KeyValue.getKeyValueDataStructureSize(keyLength, valueLength, tagsLength);
  keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength);
  if (includesMvccVersion) {
    long mvccVersion = ByteBufferUtils.readVLong(bb);
    keyValue.setSequenceId(mvccVersion);
  }
  return keyValue;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:35,代码来源:KeyValueUtil.java

示例9: nextShallowCopy

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Creates a new KeyValue object positioned in the supplied ByteBuffer and sets the ByteBuffer's
 * position to the start of the next KeyValue. Does not allocate a new array or copy data.
 * @param bb
 * @param includesMvccVersion
 * @param includesTags 
 */
public static KeyValue nextShallowCopy(final ByteBuffer bb, final boolean includesMvccVersion,
    boolean includesTags) {
  if (bb.isDirect()) {
    throw new IllegalArgumentException("only supports heap buffers");
  }
  if (bb.remaining() < 1) {
    return null;
  }
  KeyValue keyValue = null;
  int underlyingArrayOffset = bb.arrayOffset() + bb.position();
  int keyLength = bb.getInt();
  int valueLength = bb.getInt();
  ByteBufferUtils.skip(bb, keyLength + valueLength);
  short tagsLength = 0;
  if (includesTags) {
    tagsLength = bb.getShort();
    ByteBufferUtils.skip(bb, tagsLength);
  }
  int kvLength = (int) KeyValue.getKeyValueDataStructureSize(keyLength, valueLength, tagsLength);
  keyValue = new KeyValue(bb.array(), underlyingArrayOffset, kvLength);
  if (includesMvccVersion) {
    long mvccVersion = ByteBufferUtils.readVLong(bb);
    keyValue.setMvccVersion(mvccVersion);
  }
  return keyValue;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:34,代码来源:KeyValueUtil.java

示例10: createSeeker

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public EncodedSeeker createSeeker(KVComparator comparator,
    final HFileBlockDecodingContext decodingCtx) {
  return new BufferedEncodedSeeker<SeekerState>(comparator, decodingCtx) {
    @Override
    protected void decodeNext() {
      current.keyLength = currentBuffer.getInt();
      current.valueLength = currentBuffer.getInt();
      current.ensureSpaceForKey();
      currentBuffer.get(current.keyBuffer, 0, current.keyLength);
      current.valueOffset = currentBuffer.position();
      ByteBufferUtils.skip(currentBuffer, current.valueLength);
      if (includesTags()) {
        current.tagsLength = currentBuffer.getShort();
        ByteBufferUtils.skip(currentBuffer, current.tagsLength);
      }
      if (includesMvcc()) {
        current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer);
      } else {
        current.memstoreTS = 0;
      }
      current.nextKvOffset = currentBuffer.position();
    }

    @Override
    protected void decodeFirst() {
      ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT);
      current.lastCommonPrefix = 0;
      decodeNext();
    }
  };
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:33,代码来源:CopyKeyDataBlockEncoder.java

示例11: afterEncodingKeyValue

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
protected final void afterEncodingKeyValue(ByteBuffer in,
    DataOutputStream out, HFileBlockDefaultEncodingContext encodingCtx) throws IOException {
  if (encodingCtx.getHFileContext().isIncludesTags()) {
    short tagsLength = in.getShort();
    ByteBufferUtils.putCompressedInt(out, tagsLength);
    // There are some tags to be written
    if (tagsLength > 0) {
      TagCompressionContext tagCompressionContext = encodingCtx.getTagCompressionContext();
      // When tag compression is enabled, tagCompressionContext will have a not null value. Write
      // the tags using Dictionary compression in such a case
      if (tagCompressionContext != null) {
        tagCompressionContext.compressTags(out, in, tagsLength);
      } else {
        ByteBufferUtils.moveBufferToStream(out, in, tagsLength);
      }
    }
  }
  if (encodingCtx.getHFileContext().isIncludesMvcc()) {
    // Copy memstore timestamp from the byte buffer to the output stream.
    long memstoreTS = -1;
    try {
      memstoreTS = ByteBufferUtils.readVLong(in);
      WritableUtils.writeVLong(out, memstoreTS);
    } catch (IOException ex) {
      throw new RuntimeException("Unable to copy memstore timestamp " +
          memstoreTS + " after encoding a key/value");
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:30,代码来源:BufferedDataBlockEncoder.java

示例12: createSeeker

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public EncodedSeeker createSeeker(KVComparator comparator,
    final boolean includesMemstoreTS) {
  return new BufferedEncodedSeeker<SeekerState>(comparator) {
    @Override
    protected void decodeNext() {
      current.keyLength = currentBuffer.getInt();
      current.valueLength = currentBuffer.getInt();
      current.ensureSpaceForKey();
      currentBuffer.get(current.keyBuffer, 0, current.keyLength);
      current.valueOffset = currentBuffer.position();
      ByteBufferUtils.skip(currentBuffer, current.valueLength);
      if (includesMemstoreTS) {
        current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer);
      } else {
        current.memstoreTS = 0;
      }
      current.nextKvOffset = currentBuffer.position();
    }

    @Override
    protected void decodeFirst() {
      ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT);
      current.lastCommonPrefix = 0;
      decodeNext();
    }
  };
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:29,代码来源:CopyKeyDataBlockEncoder.java

示例13: createSeeker

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public EncodedSeeker createSeeker(KVComparator comparator,
    final boolean includesMemstoreTS) {
  return new BufferedEncodedSeeker<SeekerState>(comparator) {
    @Override
    protected void decodeNext() {
      current.keyLength = ByteBufferUtils.readCompressedInt(currentBuffer);
      current.valueLength = ByteBufferUtils.readCompressedInt(currentBuffer);
      current.lastCommonPrefix =
          ByteBufferUtils.readCompressedInt(currentBuffer);
      current.keyLength += current.lastCommonPrefix;
      current.ensureSpaceForKey();
      currentBuffer.get(current.keyBuffer, current.lastCommonPrefix,
          current.keyLength - current.lastCommonPrefix);
      current.valueOffset = currentBuffer.position();
      ByteBufferUtils.skip(currentBuffer, current.valueLength);
      if (includesMemstoreTS) {
        current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer);
      } else {
        current.memstoreTS = 0;
      }
      current.nextKvOffset = currentBuffer.position();
    }

    @Override
    protected void decodeFirst() {
      ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT);
      decodeNext();
    }
  };
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:32,代码来源:PrefixKeyDeltaEncoder.java

示例14: getIterator

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Provides access to compressed value.
 * @param headerSize header size of the block.
 * @return Forwards sequential iterator.
 */
public Iterator<Cell> getIterator(int headerSize) {
  final int rawSize = rawKVs.length;
  byte[] encodedDataWithHeader = getEncodedData();
  int bytesToSkip = headerSize + Bytes.SIZEOF_SHORT;
  ByteArrayInputStream bais = new ByteArrayInputStream(encodedDataWithHeader,
      bytesToSkip, encodedDataWithHeader.length - bytesToSkip);
  final DataInputStream dis = new DataInputStream(bais);

  return new Iterator<Cell>() {
    private ByteBuffer decompressedData = null;

    @Override
    public boolean hasNext() {
      if (decompressedData == null) {
        return rawSize > 0;
      }
      return decompressedData.hasRemaining();
    }

    @Override
    public Cell next() {
      if (decompressedData == null) {
        try {
          decompressedData = dataBlockEncoder.decodeKeyValues(dis, dataBlockEncoder
              .newDataBlockDecodingContext(meta));
        } catch (IOException e) {
          throw new RuntimeException("Problem with data block encoder, " +
              "most likely it requested more bytes than are available.", e);
        }
        decompressedData.rewind();
      }
      int offset = decompressedData.position();
      int klen = decompressedData.getInt();
      int vlen = decompressedData.getInt();
      int tagsLen = 0;
      ByteBufferUtils.skip(decompressedData, klen + vlen);
      // Read the tag length in case when steam contain tags
      if (meta.isIncludesTags()) {
        tagsLen = ((decompressedData.get() & 0xff) << 8) ^ (decompressedData.get() & 0xff);
        ByteBufferUtils.skip(decompressedData, tagsLen);
      }
      KeyValue kv = new KeyValue(decompressedData.array(), offset,
          (int) KeyValue.getKeyValueDataStructureSize(klen, vlen, tagsLen));
      if (meta.isIncludesMvcc()) {
        long mvccVersion = ByteBufferUtils.readVLong(decompressedData);
        kv.setSequenceId(mvccVersion);
      }
      return kv;
    }

    @Override
    public void remove() {
      throw new NotImplementedException("remove() is not supported!");
    }

    @Override
    public String toString() {
      return "Iterator of: " + dataBlockEncoder.getClass().getName();
    }

  };
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:68,代码来源:EncodedDataBlock.java

示例15: encodeData

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Do the encoding, but do not cache the encoded data.
 * @return encoded data block with header and checksum
 */
public byte[] encodeData() {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  try {
    baos.write(HConstants.HFILEBLOCK_DUMMY_HEADER);
    DataOutputStream out = new DataOutputStream(baos);
    this.dataBlockEncoder.startBlockEncoding(encodingCtx, out);
    ByteBuffer in = getUncompressedBuffer();
    in.rewind();
    int klength, vlength;
    int tagsLength = 0;
    long memstoreTS = 0L;
    KeyValue kv = null;
    while (in.hasRemaining()) {
      int kvOffset = in.position();
      klength = in.getInt();
      vlength = in.getInt();
      ByteBufferUtils.skip(in, klength + vlength);
      if (this.meta.isIncludesTags()) {
        tagsLength = ((in.get() & 0xff) << 8) ^ (in.get() & 0xff);
        ByteBufferUtils.skip(in, tagsLength);
      }
      if (this.meta.isIncludesMvcc()) {
        memstoreTS = ByteBufferUtils.readVLong(in);
      }
      kv = new KeyValue(in.array(), kvOffset, (int) KeyValue.getKeyValueDataStructureSize(
          klength, vlength, tagsLength));
      kv.setSequenceId(memstoreTS);
      this.dataBlockEncoder.encode(kv, encodingCtx, out);
    }
    BufferGrabbingByteArrayOutputStream stream = new BufferGrabbingByteArrayOutputStream();
    baos.writeTo(stream);
    this.dataBlockEncoder.endBlockEncoding(encodingCtx, out, stream.buf);
  } catch (IOException e) {
    throw new RuntimeException(String.format(
        "Bug in encoding part of algorithm %s. " +
        "Probably it requested more bytes than are available.",
        toString()), e);
  }
  return baos.toByteArray();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:45,代码来源:EncodedDataBlock.java


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