Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Fixed a bug in generated scripts pre-validation of column families
Browse files Browse the repository at this point in the history
attributes which caused warnings when not using default attributes :
The HColumnDescriptor retrieved before each pre-validation was built
from scratch and therefore holding default values of attributes. The
column family is now retrieved using the table.getFamily(familyName)
method.
Tests have been updated to match this changes.
  • Loading branch information
Thomas Maurel committed Nov 21, 2012
1 parent ecf98ca commit 17d5289
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
Expand Up @@ -223,7 +223,8 @@ private void scriptVerifyTableMatches(HTableDescriptor oldTable, String operatio
// now descend into child objects
for (HColumnDescriptor c : oldTable.getColumnFamilies()){
s(" # Column family: " + c.getNameAsString());
s(" cf = HColumnDescriptor.new(\"" + c.getNameAsString() + "\")");
s(" cfname = \"" + c.getNameAsString() + "\"");
s(" cf = table.getFamily(cfname.bytes.to_a)");

for (Entry<String,String> p : getSortedStringEntries(c.getValues())){
s(" compare(" + errorCollectionName + ", cf, \"" + operationName + "\", \"" + p.getKey() + "\", \"" + escapeDoubleQuotes(p.getValue()) + "\")");
Expand Down
12 changes: 8 additions & 4 deletions src/test/resources/DiffScriptGenerationTestResultAB.rb
Expand Up @@ -74,7 +74,8 @@ def compare(errs, obj, action, attr, val)
compare(preWarnings, table, "drop", "READONLY", "false")
compare(preWarnings, table, "drop", "fullSchema", "<table isReadOnly=\"false\" maxFileSizeMB=\"256\" memStoreFlushSizeMB=\"64\" name=\"dropMe\" owner=\"ivarley\" useDeferredLogFlush=\"false\"><key><keyPart inverted=\"false\" length=\"15\" name=\"dropMeKeyPart1\" type=\"String\"/><keyPart inverted=\"true\" length=\"15\" name=\"dropMeKeyPart2\" type=\"Timestamp\"/></key><columnFamilies><columnFamily blockCache=\"true\" blockSizeKB=\"64\" bloomFilter=\"NONE\" inMemory=\"false\" maxVersions=\"3\" name=\"dropMeColumnFamily1\" replicationScope=\"0\" timeToLiveMS=\"2147483647\"><column name=\"dropMeColumn1\" type=\"String\"/><column name=\"dropMeColumn2\" type=\"Timestamp\"/><column name=\"dropMeColumn3\" type=\"Byte\"/></columnFamily></columnFamilies></table>")
# Column family: dropMeColumnFamily1
cf = HColumnDescriptor.new("dropMeColumnFamily1")
cfname = "dropMeColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preWarnings, cf, "drop", "BLOCKCACHE", "true")
compare(preWarnings, cf, "drop", "BLOCKSIZE", "65536")
compare(preWarnings, cf, "drop", "BLOOMFILTER", "NONE")
Expand Down Expand Up @@ -113,7 +114,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, table, "alter", "READONLY", "false")
compare(preErrors, table, "alter", "fullSchema", "<table isReadOnly=\"false\" maxFileSizeMB=\"256\" memStoreFlushSizeMB=\"64\" name=\"alterMe\" owner=\"ivarley\" useDeferredLogFlush=\"false\"><key><keyPart inverted=\"false\" length=\"15\" name=\"alterMeKeyPart1\" type=\"String\"/><keyPart inverted=\"true\" length=\"15\" name=\"alterMeKeyPart2\" type=\"Timestamp\"/></key><columnFamilies><columnFamily blockCache=\"true\" blockSizeKB=\"64\" bloomFilter=\"NONE\" inMemory=\"false\" maxVersions=\"3\" name=\"alterMeColumnFamily1\" replicationScope=\"0\" timeToLiveMS=\"2147483647\"><column name=\"alterMeColumn1\" type=\"String\"/><column name=\"alterMeColumn2\" type=\"Timestamp\"/><column name=\"alterMeColumn3\" type=\"Byte\"/></columnFamily></columnFamilies></table>")
# Column family: alterMeColumnFamily1
cf = HColumnDescriptor.new("alterMeColumnFamily1")
cfname = "alterMeColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "alter", "BLOCKCACHE", "true")
compare(preErrors, cf, "alter", "BLOCKSIZE", "65536")
compare(preErrors, cf, "alter", "BLOOMFILTER", "NONE")
Expand Down Expand Up @@ -257,7 +259,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, table, "create", "READONLY", "false")
compare(preErrors, table, "create", "fullSchema", "<table isReadOnly=\"false\" maxFileSizeMB=\"256\" memStoreFlushSizeMB=\"64\" name=\"createMe\" owner=\"ivarley\" useDeferredLogFlush=\"false\"><key><keyPart inverted=\"false\" length=\"15\" name=\"createMeKeyPart1\" type=\"String\"/><keyPart inverted=\"true\" length=\"15\" name=\"createMeKeyPart2\" type=\"Timestamp\"/></key><columnFamilies><columnFamily blockCache=\"true\" blockSizeKB=\"64\" bloomFilter=\"NONE\" inMemory=\"false\" maxVersions=\"3\" name=\"createMeColumnFamily1\" replicationScope=\"0\" timeToLiveMS=\"2147483647\"><column name=\"createMeColumn1\" type=\"String\"/><column name=\"createMeColumn2\" type=\"Timestamp\"/><column name=\"createMeColumn3\" type=\"Byte\"/></columnFamily></columnFamilies></table>")
# Column family: createMeColumnFamily1
cf = HColumnDescriptor.new("createMeColumnFamily1")
cfname = "createMeColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "create", "BLOCKCACHE", "true")
compare(preErrors, cf, "create", "BLOCKSIZE", "65536")
compare(preErrors, cf, "create", "BLOOMFILTER", "NONE")
Expand Down Expand Up @@ -290,7 +293,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, table, "alter", "READONLY", "false")
compare(preErrors, table, "alter", "fullSchema", "<table isReadOnly=\"false\" maxFileSizeMB=\"257\" memStoreFlushSizeMB=\"65\" name=\"alterMe\" owner=\"ivarley2\" useDeferredLogFlush=\"false\"><key><keyPart inverted=\"false\" length=\"15\" name=\"alterMeKeyPart1\" type=\"String\"/><keyPart inverted=\"true\" length=\"15\" name=\"alterMeKeyPart2\" type=\"Timestamp\"/></key><columnFamilies><columnFamily blockCache=\"true\" blockSizeKB=\"65\" bloomFilter=\"NONE\" inMemory=\"false\" maxVersions=\"3\" name=\"alterMeColumnFamily1\" replicationScope=\"0\" timeToLiveMS=\"2147483647\"><column name=\"alterMeColumn1\" type=\"String\"/><column name=\"alterMeColumn2\" type=\"Timestamp\"/><column name=\"alterMeColumn3\" type=\"Byte\"/></columnFamily></columnFamilies></table>")
# Column family: alterMeColumnFamily1
cf = HColumnDescriptor.new("alterMeColumnFamily1")
cfname = "alterMeColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "alter", "BLOCKCACHE", "true")
compare(preErrors, cf, "alter", "BLOCKSIZE", "66560")
compare(preErrors, cf, "alter", "BLOOMFILTER", "NONE")
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/DiffScriptGenerationTestResultD.rb
Expand Up @@ -66,7 +66,8 @@ def compare(errs, obj, action, attr, val)
compare(preWarnings, table, "drop", "READONLY", "false")
compare(preWarnings, table, "drop", "fullSchema", "<table isReadOnly=\"false\" maxFileSizeMB=\"256\" memStoreFlushSizeMB=\"64\" name=\"createMe\" owner=\"ivarley\" useDeferredLogFlush=\"false\"><key><keyPart inverted=\"false\" length=\"15\" name=\"createMeKeyPart1\" type=\"String\"/><keyPart inverted=\"true\" length=\"15\" name=\"createMeKeyPart2\" type=\"Timestamp\"/></key><columnFamilies><columnFamily blockCache=\"true\" blockSizeKB=\"64\" bloomFilter=\"NONE\" inMemory=\"false\" maxVersions=\"3\" name=\"createMeColumnFamily1\" replicationScope=\"0\" timeToLiveMS=\"2147483647\"><column name=\"createMeColumn1\" type=\"String\"/><column name=\"createMeColumn2\" type=\"Timestamp\"/><column name=\"createMeColumn3\" type=\"Byte\"/></columnFamily></columnFamilies></table>")
# Column family: createMeColumnFamily1
cf = HColumnDescriptor.new("createMeColumnFamily1")
cfname = "createMeColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preWarnings, cf, "drop", "BLOCKCACHE", "true")
compare(preWarnings, cf, "drop", "BLOCKSIZE", "65536")
compare(preWarnings, cf, "drop", "BLOOMFILTER", "NONE")
Expand Down
6 changes: 4 additions & 2 deletions src/test/resources/DiffScriptGenerationTestResultEF.rb
Expand Up @@ -66,7 +66,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, table, "alter", "READONLY", "false")
compare(preErrors, table, "alter", "fullSchema", "<table name=\"minimal\"><columnFamilies><columnFamily name=\"minimalColumnFamily1\"></columnFamily></columnFamilies></table>")
# Column family: minimalColumnFamily1
cf = HColumnDescriptor.new("minimalColumnFamily1")
cfname = "minimalColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "alter", "BLOCKCACHE", "true")
compare(preErrors, cf, "alter", "BLOCKSIZE", "65536")
compare(preErrors, cf, "alter", "BLOOMFILTER", "NONE")
Expand Down Expand Up @@ -159,7 +160,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, table, "alter", "READONLY", "false")
compare(preErrors, table, "alter", "fullSchema", "<table isReadOnly=\"false\" maxFileSizeMB=\"10240\" memStoreFlushSizeMB=\"128\" name=\"minimal\" useDeferredLogFlush=\"false\"><columnFamilies><columnFamily blockCache=\"true\" blockSizeKB=\"64\" bloomFilter=\"NONE\" inMemory=\"false\" maxVersions=\"3\" name=\"minimalColumnFamily1\" replicationScope=\"0\" timeToLiveMS=\"2147483647\"></columnFamily></columnFamilies></table>")
# Column family: minimalColumnFamily1
cf = HColumnDescriptor.new("minimalColumnFamily1")
cfname = "minimalColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "alter", "BLOCKCACHE", "true")
compare(preErrors, cf, "alter", "BLOCKSIZE", "65536")
compare(preErrors, cf, "alter", "BLOOMFILTER", "NONE")
Expand Down
6 changes: 4 additions & 2 deletions src/test/resources/DiffScriptGenerationTestResultFE.rb
Expand Up @@ -66,7 +66,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, table, "alter", "READONLY", "false")
compare(preErrors, table, "alter", "fullSchema", "<table isReadOnly=\"false\" maxFileSizeMB=\"10240\" memStoreFlushSizeMB=\"128\" name=\"minimal\" useDeferredLogFlush=\"false\"><columnFamilies><columnFamily blockCache=\"true\" blockSizeKB=\"64\" bloomFilter=\"NONE\" inMemory=\"false\" maxVersions=\"3\" name=\"minimalColumnFamily1\" replicationScope=\"0\" timeToLiveMS=\"2147483647\"></columnFamily></columnFamilies></table>")
# Column family: minimalColumnFamily1
cf = HColumnDescriptor.new("minimalColumnFamily1")
cfname = "minimalColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "alter", "BLOCKCACHE", "true")
compare(preErrors, cf, "alter", "BLOCKSIZE", "65536")
compare(preErrors, cf, "alter", "BLOOMFILTER", "NONE")
Expand Down Expand Up @@ -159,7 +160,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, table, "alter", "READONLY", "false")
compare(preErrors, table, "alter", "fullSchema", "<table name=\"minimal\"><columnFamilies><columnFamily name=\"minimalColumnFamily1\"></columnFamily></columnFamilies></table>")
# Column family: minimalColumnFamily1
cf = HColumnDescriptor.new("minimalColumnFamily1")
cfname = "minimalColumnFamily1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "alter", "BLOCKCACHE", "true")
compare(preErrors, cf, "alter", "BLOCKSIZE", "65536")
compare(preErrors, cf, "alter", "BLOOMFILTER", "NONE")
Expand Down
6 changes: 4 additions & 2 deletions src/test/resources/PhoenixScriptGenerationTestResultA.rb
Expand Up @@ -141,7 +141,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, table, "create", "MEMSTORE_FLUSHSIZE", "134217728")
compare(preErrors, table, "create", "READONLY", "false")
# Column family: 1
cf = HColumnDescriptor.new("1")
cfname = "1"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "create", "BLOCKCACHE", "true")
compare(preErrors, cf, "create", "BLOCKSIZE", "65536")
compare(preErrors, cf, "create", "BLOOMFILTER", "NONE")
Expand All @@ -155,7 +156,8 @@ def compare(errs, obj, action, attr, val)
compare(preErrors, cf, "create", "TTL", "2147483647")
compare(preErrors, cf, "create", "VERSIONS", "3")
# Column family: 2
cf = HColumnDescriptor.new("2")
cfname = "2"
cf = table.getFamily(cfname.bytes.to_a)
compare(preErrors, cf, "create", "BLOCKCACHE", "true")
compare(preErrors, cf, "create", "BLOCKSIZE", "65536")
compare(preErrors, cf, "create", "BLOOMFILTER", "NONE")
Expand Down

0 comments on commit 17d5289

Please sign in to comment.