Java Code Examples for org.apache.hadoop.hbase.util.Bytes.SIZEOF_LONG
The following are Jave code examples for showing how to use
SIZEOF_LONG of the
org.apache.hadoop.hbase.util.Bytes
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: ditb File: HFileReaderV3.java View Source Code | 7 votes |
protected final void readKeyValueLen() { // TODO: METHOD (mostly) DUPLICATED IN V2!!!! FIXED in master branch by collapsing v3 and v2. // This is a hot method. We go out of our way to make this method short so it can be // inlined and is not too big to compile. We also manage position in ByteBuffer ourselves // because it is faster than going via range-checked ByteBuffer methods or going through a // byte buffer array a byte at a time. int p = blockBuffer.position() + blockBuffer.arrayOffset(); // Get a long at a time rather than read two individual ints. In micro-benchmarking, even // with the extra bit-fiddling, this is order-of-magnitude faster than getting two ints. long ll = Bytes.toLong(blockBuffer.array(), p); // Read top half as an int of key length and bottom int as value length this.currKeyLen = (int)(ll >> Integer.SIZE); this.currValueLen = (int)(Bytes.MASK_FOR_LOWER_INT_IN_LONG ^ ll); checkKeyValueLen(); // Move position past the key and value lengths and then beyond the key and value p += (Bytes.SIZEOF_LONG + currKeyLen + currValueLen); if (reader.hfileContext.isIncludesTags()) { // Tags length is a short. this.currTagsLen = Bytes.toShort(blockBuffer.array(), p); checkTagsLen(); p += (Bytes.SIZEOF_SHORT + currTagsLen); } readMvccVersion(p); }
Example 2
Project: ditb File: CellCodec.java View Source Code | 7 votes |
@Override protected Cell parseCell() throws IOException { byte [] row = readByteArray(this.in); byte [] family = readByteArray(in); byte [] qualifier = readByteArray(in); byte [] longArray = new byte[Bytes.SIZEOF_LONG]; IOUtils.readFully(this.in, longArray); long timestamp = Bytes.toLong(longArray); byte type = (byte) this.in.read(); byte[] value = readByteArray(in); // Read memstore version byte[] memstoreTSArray = new byte[Bytes.SIZEOF_LONG]; IOUtils.readFully(this.in, memstoreTSArray); long memstoreTS = Bytes.toLong(memstoreTSArray); return CellUtil.createCell(row, family, qualifier, timestamp, type, value, memstoreTS); }
Example 3
Project: ditb File: IndexFile.java View Source Code | 6 votes |
static int trailerSize() { // Keep this up to date... return ( Bytes.SIZEOF_INT * 5 ) + ( Bytes.SIZEOF_LONG * 4 ) + TRAILERBLOCKMAGIC.length; }
Example 4
Project: ditb File: HFileBlockIndex.java View Source Code | 6 votes |
/** * Adds a new entry to this block index chunk. * * @param firstKey the first key in the block pointed to by this entry * @param blockOffset the offset of the next-level block pointed to by this * entry * @param onDiskDataSize the on-disk data of the block pointed to by this * entry, including header size * @param curTotalNumSubEntries if this chunk is the root index chunk under * construction, this specifies the current total number of * sub-entries in all leaf-level chunks, including the one * corresponding to the second-level entry being added. */ void add(byte[] firstKey, long blockOffset, int onDiskDataSize, long curTotalNumSubEntries) { // Record the offset for the secondary index secondaryIndexOffsetMarks.add(curTotalNonRootEntrySize); curTotalNonRootEntrySize += SECONDARY_INDEX_ENTRY_OVERHEAD + firstKey.length; curTotalRootSize += Bytes.SIZEOF_LONG + Bytes.SIZEOF_INT + WritableUtils.getVIntSize(firstKey.length) + firstKey.length; blockKeys.add(firstKey); blockOffsets.add(blockOffset); onDiskDataSizes.add(onDiskDataSize); if (curTotalNumSubEntries != -1) { numSubEntriesAt.add(curTotalNumSubEntries); // Make sure the parallel arrays are in sync. if (numSubEntriesAt.size() != blockKeys.size()) { throw new IllegalStateException("Only have key/value count " + "stats for " + numSubEntriesAt.size() + " block index " + "entries out of " + blockKeys.size()); } } }
Example 5
Project: ditb File: HFileReaderV2.java View Source Code | 6 votes |
protected void readKeyValueLen() { // TODO: METHOD (mostly) DUPLICATED IN V3!!!!! FIXED in master branch by collapsing v3 and v2. // This is a hot method. We go out of our way to make this method short so it can be // inlined and is not too big to compile. We also manage position in ByteBuffer ourselves // because it is faster than going via range-checked ByteBuffer methods or going through a // byte buffer array a byte at a time. int p = blockBuffer.position() + blockBuffer.arrayOffset(); // Get a long at a time rather than read two individual ints. In micro-benchmarking, even // with the extra bit-fiddling, this is order-of-magnitude faster than getting two ints. long ll = Bytes.toLong(blockBuffer.array(), p); // Read top half as an int of key length and bottom int as value length this.currKeyLen = (int)(ll >> Integer.SIZE); this.currValueLen = (int)(Bytes.MASK_FOR_LOWER_INT_IN_LONG ^ ll); checkKeyValueLen(); // Move position past the key and value lengths and then beyond the key and value p += (Bytes.SIZEOF_LONG + currKeyLen + currValueLen); readMvccVersion(p); }
Example 6
Project: ditb File: CodecPerformance.java View Source Code | 6 votes |
static int getRoughSize(final Cell [] cells) { int size = 0; for (Cell c: cells) { size += c.getRowLength() + c.getFamilyLength() + c.getQualifierLength() + c.getValueLength(); size += Bytes.SIZEOF_LONG + Bytes.SIZEOF_BYTE; } return size; }
Example 7
Project: ditb File: KeyValue.java View Source Code | 6 votes |
/** * HeapSize implementation * * We do not count the bytes in the rowCache because it should be empty for a KeyValue in the * MemStore. */ @Override public long heapSize() { int sum = 0; sum += ClassSize.OBJECT;// the KeyValue object itself sum += ClassSize.REFERENCE;// pointer to "bytes" sum += ClassSize.align(ClassSize.ARRAY);// "bytes" sum += ClassSize.align(length);// number of bytes of data in the "bytes" array sum += 2 * Bytes.SIZEOF_INT;// offset, length sum += Bytes.SIZEOF_LONG;// memstoreTS return ClassSize.align(sum); }
Example 8
Project: ditb File: CellCodecWithTags.java View Source Code | 6 votes |
protected Cell parseCell() throws IOException { byte[] row = readByteArray(this.in); byte[] family = readByteArray(in); byte[] qualifier = readByteArray(in); byte[] longArray = new byte[Bytes.SIZEOF_LONG]; IOUtils.readFully(this.in, longArray); long timestamp = Bytes.toLong(longArray); byte type = (byte) this.in.read(); byte[] value = readByteArray(in); byte[] tags = readByteArray(in); // Read memstore version byte[] memstoreTSArray = new byte[Bytes.SIZEOF_LONG]; IOUtils.readFully(this.in, memstoreTSArray); long memstoreTS = Bytes.toLong(memstoreTSArray); return CellUtil.createCell(row, family, qualifier, timestamp, type, value, tags, memstoreTS); }
Example 9
Project: ditb File: HRegion.java View Source Code | 5 votes |
/** * @return Get the long out of the passed in Cell * @throws DoNotRetryIOException */ private static long getLongValue(final Cell cell) throws DoNotRetryIOException { int len = cell.getValueLength(); if (len != Bytes.SIZEOF_LONG) { // throw DoNotRetryIOException instead of IllegalArgumentException throw new DoNotRetryIOException("Field is not a long, it's " + len + " bytes wide"); } return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), len); }
Example 10
Project: ditb File: LongColumnInterpreter.java View Source Code | 5 votes |
public Long getValue(byte[] colFamily, byte[] colQualifier, Cell kv) throws IOException { if (kv == null || kv.getValueLength() != Bytes.SIZEOF_LONG) return null; return Bytes.toLong(kv.getValueArray(), kv.getValueOffset()); }
Example 11
Project: ditb File: KeyValue.java View Source Code | 5 votes |
/** * This is a hack that should be removed once we don't care about matching * up client- and server-side estimations of cell size. It needed to be * backwards compatible with estimations done by older clients. We need to * pretend that tags never exist and KeyValues aren't serialized with tag * length included. See HBASE-13262 and HBASE-13303 */ @Deprecated public long heapSizeWithoutTags() { int sum = 0; sum += ClassSize.OBJECT;// the KeyValue object itself sum += ClassSize.REFERENCE;// pointer to "bytes" sum += ClassSize.align(ClassSize.ARRAY);// "bytes" sum += KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE; sum += getKeyLength(); sum += getValueLength(); sum += 2 * Bytes.SIZEOF_INT;// offset, length sum += Bytes.SIZEOF_LONG;// memstoreTS return ClassSize.align(sum); }
Example 12
Project: ditb File: RawLong.java View Source Code | 4 votes |
@Override public int encodedLength(Long val) { return Bytes.SIZEOF_LONG; }
Example 13
Project: ditb File: RawLong.java View Source Code | 4 votes |
@Override public int skip(PositionedByteRange src) { src.setPosition(src.getPosition() + Bytes.SIZEOF_LONG); return Bytes.SIZEOF_LONG; }