本文整理汇总了Java中org.apache.hadoop.hbase.util.ClassSize.align方法的典型用法代码示例。如果您正苦于以下问题:Java ClassSize.align方法的具体用法?Java ClassSize.align怎么用?Java ClassSize.align使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.util.ClassSize
的用法示例。
在下文中一共展示了ClassSize.align方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSizedCellScanner
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
static CellScanner getSizedCellScanner(final Cell[] cells) {
int size = -1;
for (Cell cell : cells) {
size += PrivateCellUtil.estimatedSerializedSizeOf(cell);
}
final int totalSize = ClassSize.align(size);
final CellScanner cellScanner = CellUtil.createCellScanner(cells);
return new SizedCellScanner() {
@Override
public long heapSize() {
return totalSize;
}
@Override
public Cell current() {
return cellScanner.current();
}
@Override
public boolean advance() throws IOException {
return cellScanner.advance();
}
};
}
示例2: LruCachedBlock
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
public LruCachedBlock(BlockCacheKey cacheKey, Cacheable buf, long accessTime,
boolean inMemory) {
this.cacheKey = cacheKey;
this.buf = buf;
this.accessTime = accessTime;
// We approximate the size of this class by the size of its name string
// plus the size of its byte buffer plus the overhead associated with all
// the base classes. We also include the base class
// sizes in the PER_BLOCK_OVERHEAD variable rather than align()ing them with
// their buffer lengths. This variable is used elsewhere in unit tests.
this.size = ClassSize.align(cacheKey.heapSize())
+ ClassSize.align(buf.heapSize()) + PER_BLOCK_OVERHEAD;
if(inMemory) {
this.priority = BlockPriority.MEMORY;
} else {
this.priority = BlockPriority.SINGLE;
}
}
示例3: heapSize
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
/**
* 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);
}
示例4: heapSize
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
@Override
public long heapSize() {
long size = ClassSize.align(
ClassSize.OBJECT +
// Block type, byte buffer and meta references
3 * ClassSize.REFERENCE +
// On-disk size, uncompressed size, and next block's on-disk size
// bytePerChecksum and onDiskDataSize
4 * Bytes.SIZEOF_INT +
// This and previous block offset
2 * Bytes.SIZEOF_LONG +
// Heap size of the meta object. meta will be always not null.
fileContext.heapSize()
);
if (buf != null) {
// Deep overhead of the byte buffer. Needs to be aligned separately.
size += ClassSize.align(buf.capacity() + BYTE_BUFFER_HEAP_SIZE);
}
return ClassSize.align(size);
}
示例5: testHeapSizeForBlockIndex
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
/** Checks if the HeapSize calculator is within reason */
@Test
public void testHeapSizeForBlockIndex() throws IOException {
Class<HFileBlockIndex.BlockIndexReader> cl =
HFileBlockIndex.BlockIndexReader.class;
long expected = ClassSize.estimateBase(cl, false);
HFileBlockIndex.BlockIndexReader bi =
new HFileBlockIndex.BlockIndexReader(KeyValue.RAW_COMPARATOR, 1);
long actual = bi.heapSize();
// Since the arrays in BlockIndex(byte [][] blockKeys, long [] blockOffsets,
// int [] blockDataSizes) are all null they are not going to show up in the
// HeapSize calculation, so need to remove those array costs from expected.
expected -= ClassSize.align(3 * ClassSize.ARRAY);
if (expected != actual) {
ClassSize.estimateBase(cl, true);
assertEquals(expected, actual);
}
}
示例6: getSizedCellScanner
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
static CellScanner getSizedCellScanner(final Cell [] cells) {
int size = -1;
for (Cell cell: cells) {
size += CellUtil.estimatedSerializedSizeOf(cell);
}
final int totalSize = ClassSize.align(size);
final CellScanner cellScanner = CellUtil.createCellScanner(cells);
return new SizedCellScanner() {
@Override
public long heapSize() {
return totalSize;
}
@Override
public Cell current() {
return cellScanner.current();
}
@Override
public boolean advance() throws IOException {
return cellScanner.advance();
}
};
}
示例7: heapSize
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
public long heapSize() {
long heapsize = ClassSize.align(ClassSize.OBJECT +
2 * Bytes.SIZEOF_INT + (3 + 1) * ClassSize.REFERENCE);
//Calculating the size of blockKeys
if(blockKeys != null) {
//Adding array + references overhead
heapsize += ClassSize.align(ClassSize.ARRAY +
blockKeys.length * ClassSize.REFERENCE);
//Adding bytes
for(byte [] bs : blockKeys) {
heapsize += ClassSize.align(ClassSize.ARRAY + bs.length);
}
}
if(blockOffsets != null) {
heapsize += ClassSize.align(ClassSize.ARRAY +
blockOffsets.length * Bytes.SIZEOF_LONG);
}
if(blockDataSizes != null) {
heapsize += ClassSize.align(ClassSize.ARRAY +
blockDataSizes.length * Bytes.SIZEOF_INT);
}
return ClassSize.align(heapsize);
}
示例8: testHeapSizeForBlockIndex
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
/** Checks if the HeapSize calculator is within reason */
@Test
public void testHeapSizeForBlockIndex() throws IOException {
Class<HFileBlockIndex.BlockIndexReader> cl =
HFileBlockIndex.BlockIndexReader.class;
long expected = ClassSize.estimateBase(cl, false);
HFileBlockIndex.BlockIndexReader bi =
new HFileBlockIndex.BlockIndexReader(Bytes.BYTES_RAWCOMPARATOR, 1);
long actual = bi.heapSize();
// Since the arrays in BlockIndex(byte [][] blockKeys, long [] blockOffsets,
// int [] blockDataSizes) are all null they are not going to show up in the
// HeapSize calculation, so need to remove those array costs from expected.
expected -= ClassSize.align(3 * ClassSize.ARRAY);
if (expected != actual) {
ClassSize.estimateBase(cl, true);
assertEquals(expected, actual);
}
}
示例9: getSizedCellScanner
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
static CellScanner getSizedCellScanner(final Cell [] cells) {
int size = -1;
for (Cell cell: cells) {
size += CellUtil.estimatedSizeOf(cell);
}
final int totalSize = ClassSize.align(size);
final CellScanner cellScanner = CellUtil.createCellScanner(cells);
return new SizedCellScanner() {
@Override
public long heapSize() {
return totalSize;
}
@Override
public Cell current() {
return cellScanner.current();
}
@Override
public boolean advance() throws IOException {
return cellScanner.advance();
}
};
}
示例10: appendEntry
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
long appendEntry(Entry entry) {
internify(entry);
entryBuffer.add(entry);
long incrHeap = entry.getEdit().heapSize() +
ClassSize.align(2 * ClassSize.REFERENCE) + // WALKey pointers
0; // TODO linkedlist entry
heapInBuffer += incrHeap;
return incrHeap;
}
示例11: heapSize
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
@Override
public long heapSize() {
long sum = CellUtil.estimatedHeapSizeOf(cell) - cell.getTagsLength();
sum += ClassSize.OBJECT;// this object itself
sum += (2 * ClassSize.REFERENCE);// pointers to cell and tags array
if (this.tags != null) {
sum += ClassSize.align(ClassSize.ARRAY);// "tags"
sum += this.tags.length;
}
return sum;
}
示例12: heapSize
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
@Override
public long heapSize() {
long ret = ClassSize.ARRAYLIST;
for (Cell cell : cells) {
ret += CellUtil.estimatedHeapSizeOf(cell);
}
if (scopes != null) {
ret += ClassSize.TREEMAP;
ret += ClassSize.align(scopes.size() * ClassSize.MAP_ENTRY);
// TODO this isn't quite right, need help here
}
return ret;
}
示例13: CachedBlock
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
public CachedBlock(String blockName, ByteBuffer buf, long accessTime,
boolean inMemory) {
this.blockName = blockName;
this.buf = buf;
this.accessTime = accessTime;
this.size = ClassSize.align(blockName.length()) +
ClassSize.align(buf.capacity()) + PER_BLOCK_OVERHEAD;
if(inMemory) {
this.priority = BlockPriority.MEMORY;
} else {
this.priority = BlockPriority.SINGLE;
}
}
示例14: heapSizeWithoutTags
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
/**
* 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);
}
示例15: testMutations
import org.apache.hadoop.hbase.util.ClassSize; //导入方法依赖的package包/类
@Test
public void testMutations(){
Class<?> cl;
long expected;
long actual;
cl = TimeRange.class;
actual = ClassSize.TIMERANGE;
expected = ClassSize.estimateBase(cl, false);
if (expected != actual) {
ClassSize.estimateBase(cl, true);
assertEquals(expected, actual);
}
byte[] row = new byte[] { 0 };
cl = Put.class;
actual = new Put(row).MUTATION_OVERHEAD + ClassSize.align(ClassSize.ARRAY);
expected = ClassSize.estimateBase(cl, false);
//The actual TreeMap is not included in the above calculation
expected += ClassSize.align(ClassSize.TREEMAP);
if (expected != actual) {
ClassSize.estimateBase(cl, true);
assertEquals(expected, actual);
}
cl = Delete.class;
actual = new Delete(row).MUTATION_OVERHEAD + ClassSize.align(ClassSize.ARRAY);
expected = ClassSize.estimateBase(cl, false);
//The actual TreeMap is not included in the above calculation
expected += ClassSize.align(ClassSize.TREEMAP);
if (expected != actual) {
ClassSize.estimateBase(cl, true);
assertEquals(expected, actual);
}
}