HBASE-1355 [performance] Cache family maxversions; we were calculating on each access

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@769577 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-04-28 22:35:07 +00:00
parent 4ffb3cc723
commit 0ce8963a4d
4 changed files with 22 additions and 11 deletions

View File

@ -90,6 +90,8 @@ Release 0.20.0 - Unreleased
HBASE-1287 Partitioner class not used in TableMapReduceUtil.initTableReduceJob()
(Lars George and Billy Pearson via Stack)
HBASE-1320 hbase-1234 broke filter tests
HBASE-1355 [performance] Cache family maxversions; we were calculating on
each access
IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage

View File

@ -145,6 +145,11 @@ public class HColumnDescriptor implements ISerializable, WritableComparable<HCol
protected Map<ImmutableBytesWritable,ImmutableBytesWritable> values =
new HashMap<ImmutableBytesWritable,ImmutableBytesWritable>();
/*
* Cache the max versions rather than calculate it every time.
*/
private int cachedMaxVersions = -1;
/**
* Default constructor. Must be present for Writable.
*/
@ -370,11 +375,13 @@ public class HColumnDescriptor implements ISerializable, WritableComparable<HCol
/** @return maximum number of versions */
@TOJSON
public int getMaxVersions() {
String value = getValue(HConstants.VERSIONS);
if (value != null)
return Integer.valueOf(value).intValue();
return DEFAULT_VERSIONS;
public synchronized int getMaxVersions() {
if (this.cachedMaxVersions == -1) {
String value = getValue(HConstants.VERSIONS);
this.cachedMaxVersions = (value != null)?
Integer.valueOf(value).intValue(): DEFAULT_VERSIONS;
}
return this.cachedMaxVersions;
}
/**

View File

@ -632,11 +632,13 @@ public class HBaseRPC {
Object value = method.invoke(instance, call.getParameters());
int processingTime = (int) (System.currentTimeMillis() - startTime);
int qTime = (int) (startTime-receivedTime);
LOG.debug("Served: " + call.getMethodName() +
if (LOG.isDebugEnabled()) {
LOG.debug("Served: " + call.getMethodName() +
" queueTime= " + qTime +
" procesingTime= " + processingTime);
rpcMetrics.rpcQueueTime.inc(qTime);
rpcMetrics.rpcProcessingTime.inc(processingTime);
rpcMetrics.rpcQueueTime.inc(qTime);
rpcMetrics.rpcProcessingTime.inc(processingTime);
}
MetricsTimeVaryingRate m = rpcMetrics.metricsList.get(call.getMethodName());

View File

@ -1139,9 +1139,9 @@ public class Store implements HConstants {
throw new IllegalArgumentException("Number of versions must be > 0");
}
// Make sure we do not return more than maximum versions for this store.
return wantedVersions > this.family.getMaxVersions() &&
wantedVersions != HConstants.ALL_VERSIONS?
this.family.getMaxVersions(): wantedVersions;
int maxVersions = this.family.getMaxVersions();
return wantedVersions > maxVersions &&
wantedVersions != HConstants.ALL_VERSIONS? maxVersions: wantedVersions;
}
/**