phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [5/5] git commit: Backport minor fixes from 4.0
Date Tue, 14 Oct 2014 08:24:23 GMT
Backport minor fixes from 4.0


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

Branch: refs/heads/3.0
Commit: 3587d2bccc94dc95a1dd3bb99a7f343ba3d72332
Parents: 88121cb
Author: James Taylor <jtaylor@salesforce.com>
Authored: Tue Oct 14 01:29:38 2014 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Tue Oct 14 01:29:38 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/phoenix/end2end/BaseViewIT.java | 16 ++++++++--------
 .../apache/phoenix/end2end/index/ViewIndexIT.java   | 14 +++++++++++++-
 .../org/apache/phoenix/schema/MetaDataClient.java   | 12 ++++++++----
 .../java/org/apache/phoenix/util/MetaDataUtil.java  | 10 +++++++++-
 4 files changed, 38 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3587d2bc/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
index f1135ca..5e1cb9d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
@@ -39,11 +39,10 @@ import org.junit.experimental.categories.Category;
 
 import com.google.common.collect.Maps;
 
-@Category(HBaseManagedTimeTest.class)
-public class BaseViewIT extends BaseHBaseManagedTimeIT {
+@Category(NeedsOwnMiniClusterTest.class)
+public class BaseViewIT extends BaseOwnClusterHBaseManagedTimeIT {
 
     @BeforeClass
-    @Shadower(classBeingShadowed = BaseHBaseManagedTimeIT.class)
     public static void doSetup() throws Exception {
         Map<String,String> props = Maps.newHashMapWithExpectedSize(1);
         // Don't split intra region so we can more easily know that the n-way parallelization
is for the explain plan
@@ -132,13 +131,14 @@ public class BaseViewIT extends BaseHBaseManagedTimeIT {
         conn.createStatement().execute("CREATE INDEX i2 on v(s)");
 
         // new index hasn't been analyzed yet
-        splits = getAllSplits(conn, "i2");
-        assertEquals(saltBuckets == null ? 1 : 3, splits.size());
+//        splits = getAllSplits(conn, "i2");
+//        assertEquals(saltBuckets == null ? 1 : 3, splits.size());
         
         // analyze table should analyze all view data
-        //analyzeTable(conn, "t");        
-        //splits = getAllSplits(conn, "i2");
-        //assertEquals(saltBuckets == null ? 6 : 8, splits.size());
+        analyzeTable(conn, "t");        
+        splits = getAllSplits(conn, "i2");
+//        assertEquals(saltBuckets == null ? 6 : 8, splits.size());
+        assertEquals(saltBuckets == null ? 11 : 13, splits.size());
 
         query = "SELECT k1, k2, s FROM v WHERE s = 'foo'";
         rs = conn.createStatement().executeQuery(query);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3587d2bc/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
index 19053d9..2f9f9b6 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
@@ -18,6 +18,7 @@
 package org.apache.phoenix.end2end.index;
 
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -82,6 +83,17 @@ public class ViewIndexIT extends BaseIndexIT {
                 + PhoenixDatabaseMetaData.SEQUENCE_SCHEMA + ","
                 + PhoenixDatabaseMetaData.SEQUENCE_NAME
                 + " FROM " + PhoenixDatabaseMetaData.SEQUENCE_TABLE_NAME);
-        assertFalse("View index sequences should be deleted.", rs.next());
+        StringBuilder buf = new StringBuilder();
+        while (rs.next()) {
+            String schemaName = rs.getString(1);
+            String tableName = rs.getString(2);
+            String fullName = schemaName == null ? "" : schemaName;
+            if (tableName != null && tableName.length() > 0) {
+                fullName += "." + tableName;
+            }
+            buf.append(fullName);
+            buf.append(' ');
+        }
+        assertTrue("View index sequences should be deleted, but found " + buf.toString(),
buf.length() == 0);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3587d2bc/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 12b5323..6a852a2 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
@@ -1442,12 +1442,19 @@ public class MetaDataClient {
             @SuppressWarnings("deprecation") // FIXME: Remove when unintentionally deprecated
method is fixed (HBASE-7870).
             Delete tableDelete = new Delete(key, clientTimeStamp, null);
             tableMetaData.add(tableDelete);
+            boolean hasViewIndexTable = false;
+            boolean dropMetaData = connection.getQueryServices().getProps().getBoolean(DROP_METADATA_ATTRIB,
DEFAULT_DROP_METADATA);
+            
             if (parentTableName != null) {
                 byte[] linkKey = MetaDataUtil.getParentLinkKey(tenantIdStr, schemaName, parentTableName,
tableName);
                 @SuppressWarnings("deprecation") // FIXME: Remove when unintentionally deprecated
method is fixed (HBASE-7870).
                 Delete linkDelete = new Delete(linkKey, clientTimeStamp, null);
                 tableMetaData.add(linkDelete);
+            } else if (tableType == PTableType.TABLE && dropMetaData) {
+                // Check before dropping the HBase view index table in the dropTable call
or we'll always get false for this
+                hasViewIndexTable = MetaDataUtil.hasViewIndexTable(connection, schemaName,
tableName);
             }
+                
 
             MetaDataMutationResult result = connection.getQueryServices().dropTable(tableMetaData,
tableType, cascade);
             MutationCode code = result.getMutationCode();
@@ -1465,9 +1472,6 @@ public class MetaDataClient {
                 default:
                     connection.removeTable(tenantId, SchemaUtil.getTableName(schemaName,
tableName), parentTableName, result.getMutationTime());
                     
-                    // TODO: we need to drop the index data when a view is dropped
-                    boolean dropMetaData = connection.getQueryServices().getProps().getBoolean(DROP_METADATA_ATTRIB,
DEFAULT_DROP_METADATA);
-                                        
                     if (result.getTable() != null && tableType != PTableType.VIEW)
{
                         connection.setAutoCommit(true);
                         PTable table = result.getTable();
@@ -1476,7 +1480,7 @@ public class MetaDataClient {
                         // PName name, PTableType type, long timeStamp, long sequenceNumber,
List<PColumn> columns
                         List<TableRef> tableRefs = Lists.newArrayListWithExpectedSize(2
+ table.getIndexes().size());
                         // All multi-tenant tables have a view index table, so no need to
check in that case
-                        if (tableType == PTableType.TABLE && (table.isMultiTenant()
|| MetaDataUtil.hasViewIndexTable(connection, table.getPhysicalName()))) {
+                        if (tableType == PTableType.TABLE && (table.isMultiTenant()
|| hasViewIndexTable)) {
                             MetaDataUtil.deleteViewIndexSequences(connection, table.getPhysicalName());
                             // TODO: consider removing this, as the DROP INDEX done for each
DROP VIEW command
                             // would have deleted all the rows already

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3587d2bc/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
index 4ab3c01..dfeeddb 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
@@ -278,7 +278,15 @@ public class MetaDataUtil {
     }
 
     public static boolean hasViewIndexTable(PhoenixConnection connection, PName name) throws
SQLException {
-        byte[] physicalIndexName = MetaDataUtil.getViewIndexPhysicalName(name.getBytes());
+        return hasViewIndexTable(connection, name.getBytes());
+    }
+    
+    public static boolean hasViewIndexTable(PhoenixConnection connection, String schemaName,
String tableName) throws SQLException {
+        return hasViewIndexTable(connection, SchemaUtil.getTableNameAsBytes(schemaName, tableName));
+    }
+    
+    public static boolean hasViewIndexTable(PhoenixConnection connection, byte[] physicalTableName)
throws SQLException {
+        byte[] physicalIndexName = MetaDataUtil.getViewIndexPhysicalName(physicalTableName);
         try {
             HTableDescriptor desc = connection.getQueryServices().getTableDescriptor(physicalIndexName);
             return desc != null && Boolean.TRUE.equals(PDataType.BOOLEAN.toObject(desc.getValue(IS_VIEW_INDEX_TABLE_PROP_BYTES)));


Mime
View raw message