HBASE-16444 CellUtil#estimatedSerializedSizeOfKey() should consider
KEY_INFRASTRUCTURE_SIZ (Ram)
This commit is contained in:
parent
abc64fa69f
commit
2aae923c32
|
@ -902,6 +902,7 @@ public final class CellUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Estimate based on keyvalue's serialization format.
|
||||||
* @param cell
|
* @param cell
|
||||||
* @return Estimate of the <code>cell</code> size in bytes.
|
* @return Estimate of the <code>cell</code> size in bytes.
|
||||||
*/
|
*/
|
||||||
|
@ -915,7 +916,7 @@ public final class CellUtil {
|
||||||
return getSumOfCellElementLengths(cell) +
|
return getSumOfCellElementLengths(cell) +
|
||||||
// Use the KeyValue's infrastructure size presuming that another implementation would have
|
// Use the KeyValue's infrastructure size presuming that another implementation would have
|
||||||
// same basic cost.
|
// same basic cost.
|
||||||
KeyValue.KEY_INFRASTRUCTURE_SIZE +
|
KeyValue.ROW_LENGTH_SIZE + KeyValue.FAMILY_LENGTH_SIZE +
|
||||||
// Serialization is probably preceded by a length (it is in the KeyValueCodec at least).
|
// Serialization is probably preceded by a length (it is in the KeyValueCodec at least).
|
||||||
Bytes.SIZEOF_INT;
|
Bytes.SIZEOF_INT;
|
||||||
}
|
}
|
||||||
|
@ -939,10 +940,17 @@ public final class CellUtil {
|
||||||
KeyValue.TIMESTAMP_TYPE_SIZE;
|
KeyValue.TIMESTAMP_TYPE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the serialized key size. We always serialize in the KeyValue's serialization
|
||||||
|
* format.
|
||||||
|
* @param cell the cell for which the key size has to be calculated.
|
||||||
|
* @return the key size
|
||||||
|
*/
|
||||||
public static int estimatedSerializedSizeOfKey(final Cell cell) {
|
public static int estimatedSerializedSizeOfKey(final Cell cell) {
|
||||||
if (cell instanceof KeyValue) return ((KeyValue)cell).getKeyLength();
|
if (cell instanceof KeyValue) return ((KeyValue)cell).getKeyLength();
|
||||||
// This will be a low estimate. Will do for now.
|
return cell.getRowLength() + cell.getFamilyLength() +
|
||||||
return getSumOfCellKeyElementLengths(cell);
|
cell.getQualifierLength() +
|
||||||
|
KeyValue.KEY_INFRASTRUCTURE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue