phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdsi...@apache.org
Subject [26/42] phoenix git commit: Bring back check for existing HBase table
Date Fri, 23 Dec 2016 01:28:00 GMT
Bring back check for existing HBase table


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1bddaa0b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1bddaa0b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1bddaa0b

Branch: refs/heads/encodecolumns2
Commit: 1bddaa0b45d96c9cf974b48b0d2ae1fc988d8882
Parents: ffb984f
Author: Samarth <samarth.jain@salesforce.com>
Authored: Wed Nov 23 10:10:01 2016 -0800
Committer: Thomas D'Silva <tdsilva@salesforce.com>
Committed: Thu Dec 22 13:00:44 2016 -0800

----------------------------------------------------------------------
 .../org/apache/phoenix/schema/MetaDataClient.java | 18 +++++++++++++-----
 .../apache/phoenix/compile/WhereCompilerTest.java |  4 ++--
 .../apache/phoenix/execute/MutationStateTest.java |  4 ++--
 .../apache/phoenix/query/ConnectionlessTest.java  | 14 ++++++++------
 4 files changed, 25 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1bddaa0b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 8936b9b..53c1c86 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -2041,10 +2041,7 @@ public class MetaDataClient {
                  * We can't control what column qualifiers are used in HTable mapped to Phoenix
views. So we are not
                  * able to encode column names.
                  */  
-                if (viewType == MAPPED) {
-                    storageScheme = ONE_CELL_PER_KEYVALUE_COLUMN;
-                    encodingScheme = FOUR_BYTE_QUALIFIERS;
-                } else {
+                if (viewType != MAPPED) {
                     /*
                      * For regular phoenix views, use the storage scheme of the physical
table since they all share the
                      * the same HTable. Views always use the base table's column qualifier
counter for doling out
@@ -2078,7 +2075,18 @@ public class MetaDataClient {
                  * because we cannot control the column qualifiers that were used when populating
the hbase table.
                  * TODO: samarth add a test case for this
                  */
-                if (parent != null) {
+                
+                byte[] tableNameBytes = SchemaUtil.getTableNameAsBytes(schemaName, tableName);
+                boolean tableExists = true;
+                try {
+                    connection.getQueryServices().getTableDescriptor(tableNameBytes);
+                } catch (org.apache.phoenix.schema.TableNotFoundException e) {
+                    tableExists = false;
+                }
+                if (tableExists) {
+                    storageScheme = ONE_CELL_PER_KEYVALUE_COLUMN;
+                    encodingScheme = NON_ENCODED_QUALIFIERS;
+                } else if (parent != null) {
                     storageScheme = parent.getStorageScheme();
                     encodingScheme = parent.getEncodingScheme();
                 } else if (isImmutableRows) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1bddaa0b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
index 06c20d3..c65408e 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java
@@ -121,7 +121,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest {
         Filter filter = scan.getFilter();
         Expression idExpression = new ColumnRef(plan.getTableRef(), plan.getTableRef().getTable().getPColumnForColumnName("ID").getPosition()).newColumnExpression();
         Expression id = new RowKeyColumnExpression(idExpression,new RowKeyValueAccessor(plan.getTableRef().getTable().getPKColumns(),0));
-        Expression company = new KeyValueColumnExpression(plan.getTableRef().getTable().getPColumnForColumnName("COMPANY"),
true);
+        Expression company = new KeyValueColumnExpression(plan.getTableRef().getTable().getPColumnForColumnName("COMPANY"),
false);
         // FilterList has no equals implementation
         assertTrue(filter instanceof FilterList);
         FilterList filterList = (FilterList)filter;
@@ -153,7 +153,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest {
         assertEquals(
                 singleKVFilter(constantComparison(
                     CompareOp.EQUAL,
-                    new KeyValueColumnExpression(column, true),
+                    new KeyValueColumnExpression(column, false),
                     "c3")),
                 filter);
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1bddaa0b/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java
index 8553b73..276d946 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/execute/MutationStateTest.java
@@ -127,11 +127,11 @@ public class MutationStateTest {
     private void assertTable(String tableName1,List<KeyValue> keyValues1,String tableName2,List<KeyValue>
keyValues2) {
         assertTrue("MUTATION_TEST1".equals(tableName1));
         assertTrue(Bytes.equals(PUnsignedInt.INSTANCE.toBytes(111),CellUtil.cloneRow(keyValues1.get(0))));
-        assertTrue("app1".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues1.get(1)))));
+        assertTrue("app1".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues1.get(0)))));
 
         assertTrue("MUTATION_TEST2".equals(tableName2));
         assertTrue(Bytes.equals(PUnsignedInt.INSTANCE.toBytes(222),CellUtil.cloneRow(keyValues2.get(0))));
-        assertTrue("app2".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues2.get(1)))));
+        assertTrue("app2".equals(PVarchar.INSTANCE.toObject(CellUtil.cloneValue(keyValues2.get(0)))));
 
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1bddaa0b/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java
index 84cc65c..089c5f1 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/ConnectionlessTest.java
@@ -141,21 +141,19 @@ public class ConnectionlessTest {
         assertTrue(iterator.hasNext());
         kv = iterator.next();
         assertArrayEquals(expectedRowKey1, kv.getRow());        
-        assertEquals(QueryConstants.EMPTY_COLUMN_VALUE, PVarchar.INSTANCE.toObject(kv.getValue()));
-        kv = iterator.next();
-        assertArrayEquals(expectedRowKey1, kv.getRow());        
         assertEquals(name1, PVarchar.INSTANCE.toObject(kv.getValue()));
         assertTrue(iterator.hasNext());
         kv = iterator.next();
         assertArrayEquals(expectedRowKey1, kv.getRow());        
         assertEquals(now, PDate.INSTANCE.toObject(kv.getValue()));
+        assertTrue(iterator.hasNext());
+        kv = iterator.next();
+        assertArrayEquals(expectedRowKey1, kv.getRow());        
+        assertEquals(QueryConstants.EMPTY_COLUMN_VALUE, PVarchar.INSTANCE.toObject(kv.getValue()));
     }
 
     private static void assertRow2(Iterator<KeyValue> iterator, byte[] expectedRowKey2)
{
         KeyValue kv;
-        kv = iterator.next();
-        assertArrayEquals(expectedRowKey2, kv.getRow());        
-        assertEquals(QueryConstants.EMPTY_COLUMN_VALUE, PVarchar.INSTANCE.toObject(kv.getValue()));
         assertTrue(iterator.hasNext());
         kv = iterator.next();
         assertArrayEquals(expectedRowKey2, kv.getRow());        
@@ -164,6 +162,10 @@ public class ConnectionlessTest {
         kv = iterator.next();
         assertArrayEquals(expectedRowKey2, kv.getRow());        
         assertEquals(now, PDate.INSTANCE.toObject(kv.getValue()));
+        assertTrue(iterator.hasNext());
+        kv = iterator.next();
+        assertArrayEquals(expectedRowKey2, kv.getRow());        
+        assertEquals(QueryConstants.EMPTY_COLUMN_VALUE, PVarchar.INSTANCE.toObject(kv.getValue()));
     }
     
     @Test


Mime
View raw message