本文整理汇总了Java中org.apache.hadoop.hbase.util.ClassSize.REFERENCE属性的典型用法代码示例。如果您正苦于以下问题:Java ClassSize.REFERENCE属性的具体用法?Java ClassSize.REFERENCE怎么用?Java ClassSize.REFERENCE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.hbase.util.ClassSize
的用法示例。
在下文中一共展示了ClassSize.REFERENCE属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LruHashMap
/**
* Constructs a new, empty map with the specified initial capacity,
* load factor, and maximum memory usage.
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
* @param maxMemUsage the maximum total memory usage
* @throws IllegalArgumentException if the initial capacity is less than one
* @throws IllegalArgumentException if the initial capacity is greater than
* the maximum capacity
* @throws IllegalArgumentException if the load factor is <= 0
* @throws IllegalArgumentException if the max memory usage is too small
* to support the base overhead
*/
public LruHashMap(int initialCapacity, float loadFactor,
long maxMemUsage) {
if (initialCapacity < 1) {
throw new IllegalArgumentException("Initial capacity must be > 0");
}
if (initialCapacity > MAXIMUM_CAPACITY) {
throw new IllegalArgumentException("Initial capacity is too large");
}
if (loadFactor <= 0 || Float.isNaN(loadFactor)) {
throw new IllegalArgumentException("Load factor must be > 0");
}
if (maxMemUsage <= (OVERHEAD + initialCapacity * ClassSize.REFERENCE)) {
throw new IllegalArgumentException("Max memory usage too small to " +
"support base overhead");
}
/** Find a power of 2 >= initialCapacity */
int capacity = calculateCapacity(initialCapacity);
this.loadFactor = loadFactor;
this.threshold = calculateThreshold(capacity,loadFactor);
this.entries = new Entry[capacity];
this.memFree = maxMemUsage;
this.memTotal = maxMemUsage;
init();
}
示例2: heapSize
/**
* 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);
}
示例3: LruHashMap
/**
* Constructs a new, empty map with the specified initial capacity,
* load factor, and maximum memory usage.
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
* @param maxMemUsage the maximum total memory usage
* @throws IllegalArgumentException if the initial capacity is less than one
* @throws IllegalArgumentException if the initial capacity is greater than
* the maximum capacity
* @throws IllegalArgumentException if the load factor is <= 0
* @throws IllegalArgumentException if the max memory usage is too small
* to support the base overhead
*/
public LruHashMap(int initialCapacity, float loadFactor,
long maxMemUsage) {
if (initialCapacity < 1) {
throw new IllegalArgumentException("Initial capacity must be > 0");
}
if (initialCapacity > MAXIMUM_CAPACITY) {
throw new IllegalArgumentException("Initial capacity is too large");
}
if (loadFactor <= 0 || Float.isNaN(loadFactor)) {
throw new IllegalArgumentException("Load factor must be > 0");
}
if (maxMemUsage <= (OVERHEAD + initialCapacity * ClassSize.REFERENCE)) {
throw new IllegalArgumentException("Max memory usage too small to " +
"support base overhead");
}
/** Find a power of 2 >= initialCapacity */
int capacity = calculateCapacity(initialCapacity);
this.loadFactor = loadFactor;
this.threshold = calculateThreshold(capacity,loadFactor);
this.entries = new Entry[capacity];
this.memFree = maxMemUsage;
this.memTotal = maxMemUsage;
init();
}
示例4: calculateHeapSizeForBlockKeys
@Override
protected long calculateHeapSizeForBlockKeys(long heapSize) {
if (blockKeys != null) {
heapSize += ClassSize.REFERENCE;
// Adding array + references overhead
heapSize += ClassSize.align(ClassSize.ARRAY + blockKeys.length * ClassSize.REFERENCE);
// Adding blockKeys
for (Cell key : blockKeys) {
heapSize += ClassSize.align(PrivateCellUtil.estimatedHeapSizeOf(key));
}
}
// Add comparator and the midkey atomicreference
heapSize += 2 * ClassSize.REFERENCE;
return heapSize;
}
示例5: heapSize
@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;
}
示例6: growTable
/**
* Recreates the entire contents of the hashmap into a new array
* with double the capacity. This method is called when the number of
* keys in the map reaches the current threshold.
*
* @param newCapacity the new size of the hash entries
*/
private void growTable(int newCapacity) {
Entry [] oldTable = entries;
int oldCapacity = oldTable.length;
// Do not allow growing the table beyond the max capacity
if (oldCapacity == MAXIMUM_CAPACITY) {
threshold = Integer.MAX_VALUE;
return;
}
// Determine how much additional space will be required to grow the array
long requiredSpace = (newCapacity - oldCapacity) * ClassSize.REFERENCE;
// Verify/enforce we have sufficient memory to grow
checkAndFreeMemory(requiredSpace);
Entry [] newTable = new Entry[newCapacity];
// Transfer existing entries to new hash table
for(int i=0; i < oldCapacity; i++) {
Entry<K,V> entry = oldTable[i];
if(entry != null) {
// Set to null for GC
oldTable[i] = null;
do {
Entry<K,V> next = entry.next;
int idx = hashIndex(entry.hash, newCapacity);
entry.next = newTable[idx];
newTable[idx] = entry;
entry = next;
} while(entry != null);
}
}
entries = newTable;
threshold = (int)(newCapacity * loadFactor);
}
示例7: heapSizeWithoutTags
/**
* 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);
}
示例8: heapSize
@Override
public long heapSize() {
long sum = ClassSize.REFERENCE + super.heapSize();
if (this.value != null) {
sum += ClassSize.sizeOf(this.value);
}
return sum;
}
示例9: init
/**
* Set the initial heap usage of this class. Includes class variable
* overhead and the entry array.
*/
private void init() {
memFree -= OVERHEAD;
memFree -= (entries.length * ClassSize.REFERENCE);
}
示例10: getMinimumUsage
/**
* Returns the minimum memory usage of the base map structure.
*
* @return baseline memory overhead of object in bytes
*/
private long getMinimumUsage() {
return OVERHEAD + (entries.length * ClassSize.REFERENCE);
}