commit a903507c4b3b0efc29e1a579a7f1d4de2da9fcfd Author: Ryan Rawson Date: Wed Sep 1 15:29:49 2010 -0700 Dont use a sync block in HCD to get max versions diff --git a/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java b/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java index 8e3bd53..cab3b05 100644 --- a/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java +++ b/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java @@ -185,6 +185,7 @@ public class HColumnDescriptor implements WritableComparable desc.values.entrySet()) { this.values.put(e.getKey(), e.getValue()); } + setMaxVersions(desc.getMaxVersions()); } /** @@ -357,12 +358,7 @@ public class HColumnDescriptor implements WritableComparable } /** @return maximum number of versions */ - public synchronized int getMaxVersions() { - if (this.cachedMaxVersions == -1) { - String value = getValue(HConstants.VERSIONS); - this.cachedMaxVersions = (value != null)? - Integer.valueOf(value).intValue(): DEFAULT_VERSIONS; - } + public int getMaxVersions() { return this.cachedMaxVersions; } @@ -371,6 +367,7 @@ public class HColumnDescriptor implements WritableComparable */ public void setMaxVersions(int maxVersions) { setValue(HConstants.VERSIONS, Integer.toString(maxVersions)); + cachedMaxVersions = maxVersions; } /** @@ -603,12 +600,12 @@ public class HColumnDescriptor implements WritableComparable ImmutableBytesWritable value = new ImmutableBytesWritable(); key.readFields(in); value.readFields(in); - + // in version 8, the BloomFilter setting changed from bool to enum if (version < 8 && Bytes.toString(key.get()).equals(BLOOMFILTER)) { value.set(Bytes.toBytes( Boolean.getBoolean(Bytes.toString(value.get())) - ? BloomType.ROW.toString() + ? BloomType.ROW.toString() : BloomType.NONE.toString())); } @@ -618,6 +615,9 @@ public class HColumnDescriptor implements WritableComparable // Convert old values. setValue(COMPRESSION, Compression.Algorithm.NONE.getName()); } + String value = getValue(HConstants.VERSIONS); + this.cachedMaxVersions = (value != null)? + Integer.valueOf(value).intValue(): DEFAULT_VERSIONS; } }