Index: hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java =================================================================== --- hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java (revision 1485584) +++ hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java (working copy) @@ -393,28 +393,12 @@ isLegalFamilyName(familyName); this.name = familyName; - if (maxVersions <= 0) { - // TODO: Allow maxVersion of 0 to be the way you say "Keep all versions". - // Until there is support, consider 0 or < 0 -- a configuration error. - throw new IllegalArgumentException("Maximum versions must be positive"); - } - - if (minVersions > 0) { - if (timeToLive == HConstants.FOREVER) { - throw new IllegalArgumentException("Minimum versions requires TTL."); - } - if (minVersions >= maxVersions) { - throw new IllegalArgumentException("Minimum versions must be < " - + "maximum versions."); - } - } - + setTimeToLive(timeToLive); setMaxVersions(maxVersions); setMinVersions(minVersions); setKeepDeletedCells(keepDeletedCells); setInMemory(inMemory); setBlockCacheEnabled(blockCacheEnabled); - setTimeToLive(timeToLive); setCompressionType(Compression.Algorithm. valueOf(compression.toUpperCase())); setEncodeOnDisk(encodeOnDisk); @@ -567,6 +551,14 @@ * @return this (for chained invocation) */ public HColumnDescriptor setMaxVersions(int maxVersions) { + if (maxVersions <= 0) { + // TODO: Allow maxVersion of 0 to be the way you say "Keep all versions". + // Until there is support, consider 0 or < 0 -- a configuration error. + throw new IllegalArgumentException("Maximum versions must be positive"); + } else if (maxVersions <= this.getMinVersions()) { + throw new IllegalArgumentException("Maximum versions must be > " + "minimum versions " + + this.getMinVersions()); + } setValue(HConstants.VERSIONS, Integer.toString(maxVersions)); cachedMaxVersions = maxVersions; return this; @@ -753,6 +745,16 @@ * @return this (for chained invocation) */ public HColumnDescriptor setMinVersions(int minVersions) { + if (minVersions > 0) { + if (this.getTimeToLive() == HConstants.FOREVER) { + // set to DEFAULT instead of throw exception here. + this.setTimeToLive(DEFAULT_TTL); + } + if (minVersions >= this.getMaxVersions()) { + throw new IllegalArgumentException("Minimum versions must be < " + "maximum versions " + + this.getMaxVersions()); + } + } return setValue(MIN_VERSIONS, Integer.toString(minVersions)); }