PHOENIX-2409 Create getTable() convenience method on PhoenixConnection
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/6f05484a Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6f05484a Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6f05484a Branch: refs/heads/txn Commit: 6f05484abe26ff3111894a1d6bc8dc97213bb304 Parents: 2dfede4 Author: James Taylor <[email protected]> Authored: Thu Nov 12 16:40:40 2015 -0800 Committer: James Taylor <[email protected]> Committed: Thu Nov 12 16:40:40 2015 -0800 ---------------------------------------------------------------------- .../java/org/apache/phoenix/end2end/AlterTableIT.java | 14 +++++++------- .../apache/phoenix/end2end/AlterTableWithViewsIT.java | 8 ++++---- .../phoenix/end2end/index/ImmutableIndexIT.java | 2 +- .../apache/phoenix/end2end/index/IndexMetadataIT.java | 4 ++-- .../apache/phoenix/end2end/index/LocalIndexIT.java | 6 +++--- .../apache/phoenix/end2end/index/SaltedIndexIT.java | 2 +- .../org/apache/phoenix/compile/DeleteCompiler.java | 2 +- .../java/org/apache/phoenix/compile/FromCompiler.java | 4 ++-- .../apache/phoenix/compile/ProjectionCompiler.java | 6 +++--- .../org/apache/phoenix/jdbc/PhoenixConnection.java | 6 ++++++ .../org/apache/phoenix/schema/MetaDataClient.java | 10 +++++----- .../java/org/apache/phoenix/util/PhoenixRuntime.java | 2 +- .../org/apache/phoenix/compile/QueryCompilerTest.java | 4 ++-- .../apache/phoenix/filter/SkipScanBigFilterTest.java | 2 +- .../org/apache/phoenix/index/IndexMaintainerTest.java | 4 ++-- .../phoenix/query/BaseConnectionlessQueryTest.java | 2 +- .../phoenix/query/ParallelIteratorsSplitTest.java | 2 +- .../org/apache/phoenix/schema/RowKeySchemaTest.java | 2 +- .../phoenix/schema/RowKeyValueAccessorTest.java | 2 +- 19 files changed, 45 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java index a523fac..cdf7b5d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java @@ -725,7 +725,7 @@ public class AlterTableIT extends BaseOwnClusterHBaseManagedTimeIT { private void asssertIsWALDisabled(Connection conn, String fullTableName, boolean expectedValue) throws SQLException { PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - assertEquals(expectedValue, pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isWALDisabled()); + assertEquals(expectedValue, pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isWALDisabled()); } @Test @@ -1433,7 +1433,7 @@ public class AlterTableIT extends BaseOwnClusterHBaseManagedTimeIT { private static void assertImmutableRows(Connection conn, String fullTableName, boolean expectedValue) throws SQLException { PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - assertEquals(expectedValue, pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows()); + assertEquals(expectedValue, pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows()); } @Test @@ -2093,7 +2093,7 @@ public class AlterTableIT extends BaseOwnClusterHBaseManagedTimeIT { ddl = "ALTER TABLE TESTCHANGEPHOENIXPROPS SET MULTI_TENANT = true"; conn.createStatement().execute(ddl); // check metadata cache is updated with MULTI_TENANT = true - PTable t = conn.unwrap(PhoenixConnection.class).getMetaDataCache().getTable(new PTableKey(null, "TESTCHANGEPHOENIXPROPS")); + PTable t = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, "TESTCHANGEPHOENIXPROPS")); assertTrue(t.isMultiTenant()); // check table metadata updated server side @@ -2114,14 +2114,14 @@ public class AlterTableIT extends BaseOwnClusterHBaseManagedTimeIT { try (Connection conn = DriverManager.getConnection(getUrl())) { conn.createStatement().execute("CREATE TABLE T1 (PK1 DATE NOT NULL, PK2 VARCHAR NOT NULL, KV1 VARCHAR CONSTRAINT PK PRIMARY KEY(PK1 ROW_TIMESTAMP, PK2)) "); PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); - PTable table = phxConn.getMetaDataCache().getTable(new PTableKey(phxConn.getTenantId(), "T1")); + PTable table = phxConn.getTable(new PTableKey(phxConn.getTenantId(), "T1")); // Assert that the column shows up as row time stamp in the cache. assertTrue(table.getColumn("PK1").isRowTimestamp()); assertFalse(table.getColumn("PK2").isRowTimestamp()); assertIsRowTimestampSet("T1", "PK1"); conn.createStatement().execute("CREATE TABLE T6 (PK1 VARCHAR, PK2 DATE PRIMARY KEY ROW_TIMESTAMP, KV1 VARCHAR, KV2 INTEGER)"); - table = phxConn.getMetaDataCache().getTable(new PTableKey(phxConn.getTenantId(), "T6")); + table = phxConn.getTable(new PTableKey(phxConn.getTenantId(), "T6")); // Assert that the column shows up as row time stamp in the cache. assertFalse(table.getColumn("PK1").isRowTimestamp()); assertTrue(table.getColumn("PK2").isRowTimestamp()); @@ -2129,7 +2129,7 @@ public class AlterTableIT extends BaseOwnClusterHBaseManagedTimeIT { // Create an index on a table has a row time stamp pk column. The column should show up as a row time stamp column for the index too. conn.createStatement().execute("CREATE INDEX T6_IDX ON T6 (KV1) include (KV2)"); - PTable indexTable = phxConn.getMetaDataCache().getTable(new PTableKey(phxConn.getTenantId(), "T6_IDX")); + PTable indexTable = phxConn.getTable(new PTableKey(phxConn.getTenantId(), "T6_IDX")); String indexColName = IndexUtil.getIndexColumnName(table.getColumn("PK2")); // Assert that the column shows up as row time stamp in the cache. assertTrue(indexTable.getColumn(indexColName).isRowTimestamp()); @@ -2145,7 +2145,7 @@ public class AlterTableIT extends BaseOwnClusterHBaseManagedTimeIT { // Make sure that the base table column declared as row_timestamp is also row_timestamp for view conn.createStatement().execute("CREATE VIEW T6_VIEW (KV3 VARCHAR, KV4 VARCHAR, KV5 INTEGER, CONSTRAINT PK PRIMARY KEY (KV3, KV4) ) AS SELECT * FROM T6"); - PTable view = phxConn.getMetaDataCache().getTable(new PTableKey(phxConn.getTenantId(), "T6_VIEW")); + PTable view = phxConn.getTable(new PTableKey(phxConn.getTenantId(), "T6_VIEW")); assertNotNull(view.getPKColumn("PK2")); assertTrue(view.getPKColumn("PK2").isRowTimestamp()); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java index 77738be..3f311ea 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java @@ -778,7 +778,7 @@ public class AlterTableWithViewsIT extends BaseHBaseManagedTimeIT { private boolean checkColumnPartOfPk(PhoenixConnection conn, String columnName, String tableName) throws SQLException { String normalizedTableName = SchemaUtil.normalizeIdentifier(tableName); - PTable table = conn.getMetaDataCache().getTable(new PTableKey(conn.getTenantId(), normalizedTableName)); + PTable table = conn.getTable(new PTableKey(conn.getTenantId(), normalizedTableName)); List<PColumn> pkCols = table.getPKColumns(); String normalizedColumnName = SchemaUtil.normalizeIdentifier(columnName); for (PColumn pkCol : pkCols) { @@ -791,7 +791,7 @@ public class AlterTableWithViewsIT extends BaseHBaseManagedTimeIT { private int getIndexOfPkColumn(PhoenixConnection conn, String columnName, String tableName) throws SQLException { String normalizedTableName = SchemaUtil.normalizeIdentifier(tableName); - PTable table = conn.getMetaDataCache().getTable(new PTableKey(conn.getTenantId(), normalizedTableName)); + PTable table = conn.getTable(new PTableKey(conn.getTenantId(), normalizedTableName)); List<PColumn> pkCols = table.getPKColumns(); String normalizedColumnName = SchemaUtil.normalizeIdentifier(columnName); int i = 0; @@ -1097,12 +1097,12 @@ public class AlterTableWithViewsIT extends BaseHBaseManagedTimeIT { } private static long getTableSequenceNumber(PhoenixConnection conn, String tableName) throws SQLException { - PTable table = conn.getMetaDataCache().getTable(new PTableKey(conn.getTenantId(), SchemaUtil.normalizeIdentifier(tableName))); + PTable table = conn.getTable(new PTableKey(conn.getTenantId(), SchemaUtil.normalizeIdentifier(tableName))); return table.getSequenceNumber(); } private static short getMaxKeySequenceNumber(PhoenixConnection conn, String tableName) throws SQLException { - PTable table = conn.getMetaDataCache().getTable(new PTableKey(conn.getTenantId(), SchemaUtil.normalizeIdentifier(tableName))); + PTable table = conn.getTable(new PTableKey(conn.getTenantId(), SchemaUtil.normalizeIdentifier(tableName))); return SchemaUtil.getMaxKeySeq(table); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexIT.java index 9eb9a57..350e0b1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexIT.java @@ -189,7 +189,7 @@ public class ImmutableIndexIT extends BaseHBaseManagedTimeIT { private void assertImmutableRows(Connection conn, String fullTableName, boolean expectedValue) throws SQLException { PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - assertEquals(expectedValue, pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows()); + assertEquals(expectedValue, pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows()); } @Test http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java index d6ced3c..e72ad0c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java @@ -100,7 +100,7 @@ public class IndexMetadataIT extends BaseHBaseManagedTimeIT { String fullTableName = SchemaUtil.getTableName(schemaName, tableName); conn.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName).next(); // client side cache will update PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)).getIndexMaintainers(ptr, pconn); + pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).getIndexMaintainers(ptr, pconn); assertTrue(ptr.getLength() > 0); } @@ -109,7 +109,7 @@ public class IndexMetadataIT extends BaseHBaseManagedTimeIT { String fullTableName = SchemaUtil.getTableName(schemaName, tableName); conn.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName).next(); // client side cache will update PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)).getIndexMaintainers(ptr, pconn); + pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).getIndexMaintainers(ptr, pconn); assertTrue(ptr.getLength() == 0); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java index 5e01510..ee523de 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java @@ -113,7 +113,7 @@ public class LocalIndexIT extends BaseHBaseManagedTimeIT { Connection conn1 = DriverManager.getConnection(getUrl()); conn1.createStatement().execute("CREATE LOCAL INDEX " + TestUtil.DEFAULT_INDEX_TABLE_NAME + " ON " + TestUtil.DEFAULT_DATA_TABLE_NAME + "(v1)"); conn1.createStatement().executeQuery("SELECT * FROM " + TestUtil.DEFAULT_DATA_TABLE_FULL_NAME).next(); - PTable localIndex = conn1.unwrap(PhoenixConnection.class).getMetaDataCache().getTable(new PTableKey(null,TestUtil.DEFAULT_INDEX_TABLE_NAME)); + PTable localIndex = conn1.unwrap(PhoenixConnection.class).getTable(new PTableKey(null,TestUtil.DEFAULT_INDEX_TABLE_NAME)); assertEquals(IndexType.LOCAL, localIndex.getIndexType()); assertNotNull(localIndex.getViewIndexId()); } @@ -129,7 +129,7 @@ public class LocalIndexIT extends BaseHBaseManagedTimeIT { } catch (SQLException e) { } try { conn2.createStatement().executeQuery("SELECT * FROM " + TestUtil.DEFAULT_DATA_TABLE_FULL_NAME).next(); - conn2.unwrap(PhoenixConnection.class).getMetaDataCache().getTable(new PTableKey(null,TestUtil.DEFAULT_INDEX_TABLE_NAME)); + conn2.unwrap(PhoenixConnection.class).getTable(new PTableKey(null,TestUtil.DEFAULT_INDEX_TABLE_NAME)); fail("Local index should not be created."); } catch (TableNotFoundException e) { } } @@ -145,7 +145,7 @@ public class LocalIndexIT extends BaseHBaseManagedTimeIT { } catch (SQLException e) { } try { conn2.createStatement().executeQuery("SELECT * FROM " + TestUtil.DEFAULT_DATA_TABLE_FULL_NAME).next(); - conn2.unwrap(PhoenixConnection.class).getMetaDataCache().getTable(new PTableKey(null,TestUtil.DEFAULT_INDEX_TABLE_NAME)); + conn2.unwrap(PhoenixConnection.class).getTable(new PTableKey(null,TestUtil.DEFAULT_INDEX_TABLE_NAME)); fail("Local index should not be created."); } catch (TableNotFoundException e) { } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java index 4cc80a4..b5c8477 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java @@ -68,7 +68,7 @@ public class SaltedIndexIT extends BaseHBaseManagedTimeIT { conn.createStatement().execute("ALTER TABLE " + TestUtil.DEFAULT_DATA_TABLE_FULL_NAME + " SET IMMUTABLE_ROWS=true"); conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + TestUtil.DEFAULT_DATA_TABLE_FULL_NAME).next(); PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - assertTrue(pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), TestUtil.DEFAULT_DATA_TABLE_FULL_NAME)).isImmutableRows()); + assertTrue(pconn.getTable(new PTableKey(pconn.getTenantId(), TestUtil.DEFAULT_DATA_TABLE_FULL_NAME)).isImmutableRows()); } finally { conn.close(); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java index 96588d1..2c90bdf 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java @@ -348,7 +348,7 @@ public class DeleteCompiler { // optimizer updated the cache if it found indexes that were out of date. // If the index was marked as disabled, it should not be in the list // of immutable indexes. - table = connection.getMetaDataCache().getTable(new PTableKey(table.getTenantId(), table.getName().getString())); + table = connection.getTable(new PTableKey(table.getTenantId(), table.getName().getString())); tableRefToBe.setTable(table); immutableIndex = getNonDisabledImmutableIndexes(tableRefToBe); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java index dd92b00..426556f 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java @@ -414,11 +414,11 @@ public class FromCompiler { } } else { try { - theTable = connection.getMetaDataCache().getTable(new PTableKey(tenantId, fullTableName)); + theTable = connection.getTable(new PTableKey(tenantId, fullTableName)); } catch (TableNotFoundException e1) { if (tenantId != null) { // Check with null tenantId next try { - theTable = connection.getMetaDataCache().getTable(new PTableKey(null, fullTableName)); + theTable = connection.getTable(new PTableKey(null, fullTableName)); } catch (TableNotFoundException e2) { } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java index ad02961..86b89b8 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java @@ -184,11 +184,11 @@ public class ProjectionCompiler { String tableName = index.getParentName().getString(); PTable dataTable = null; try { - dataTable = conn.getMetaDataCache().getTable(new PTableKey(tenantId, tableName)); + dataTable = conn.getTable(new PTableKey(tenantId, tableName)); } catch (TableNotFoundException e) { if (tenantId != null) { // Check with null tenantId - dataTable = conn.getMetaDataCache().getTable(new PTableKey(null, tableName)); + dataTable = conn.getTable(new PTableKey(null, tableName)); } else { throw e; @@ -279,7 +279,7 @@ public class ProjectionCompiler { PTable index = tableRef.getTable(); PhoenixConnection conn = context.getConnection(); String tableName = index.getParentName().getString(); - PTable table = conn.getMetaDataCache().getTable(new PTableKey(conn.getTenantId(), tableName)); + PTable table = conn.getTable(new PTableKey(conn.getTenantId(), tableName)); PColumnFamily pfamily = table.getColumnFamily(cfName); for (PColumn column : pfamily.getColumns()) { String indexColName = IndexUtil.getIndexColumnName(column); http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java index 6985fc3..6a142e5 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java @@ -78,7 +78,9 @@ import org.apache.phoenix.schema.PMetaData; import org.apache.phoenix.schema.PMetaData.Pruner; import org.apache.phoenix.schema.PName; import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableKey; import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.schema.TableNotFoundException; import org.apache.phoenix.schema.types.PArrayDataType; import org.apache.phoenix.schema.types.PDataType; import org.apache.phoenix.schema.types.PDate; @@ -406,6 +408,10 @@ public class PhoenixConnection implements Connection, org.apache.phoenix.jdbc.Jd return mutateBatchSize; } + public PTable getTable(PTableKey key) throws TableNotFoundException { + return metaData.getTable(key); + } + public PMetaData getMetaDataCache() { return metaData; } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/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 82239ea..753c122 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 @@ -427,7 +427,7 @@ public class MetaDataClient { String fullTableName = SchemaUtil.getTableName(schemaName, tableName); long tableTimestamp = HConstants.LATEST_TIMESTAMP; try { - table = connection.getMetaDataCache().getTable(new PTableKey(tenantId, fullTableName)); + table = connection.getTable(new PTableKey(tenantId, fullTableName)); tableTimestamp = table.getTimeStamp(); } catch (TableNotFoundException e) { } @@ -1728,7 +1728,7 @@ public class MetaDataClient { linkStatement.setString(4, physicalName.getString()); linkStatement.setByte(5, LinkType.PHYSICAL_TABLE.getSerializedValue()); if (tableType == PTableType.VIEW) { - PTable physicalTable = connection.getMetaDataCache().getTable(new PTableKey(null, physicalName.getString())); + PTable physicalTable = connection.getTable(new PTableKey(null, physicalName.getString())); linkStatement.setLong(6, physicalTable.getSequenceNumber()); } else { linkStatement.setLong(6, parent.getSequenceNumber()); @@ -2933,7 +2933,7 @@ public class MetaDataClient { if (retried) { throw e; } - table = connection.getMetaDataCache().getTable(new PTableKey(tenantId, fullTableName)); + table = connection.getTable(new PTableKey(tenantId, fullTableName)); retried = true; } } @@ -3052,7 +3052,7 @@ public class MetaDataClient { String physicalName = table.getPhysicalName().getString(); if (isView && table.getViewType() != ViewType.MAPPED) { try { - return connection.getMetaDataCache().getTable(new PTableKey(null, physicalName)).getTableStats(); + return connection.getTable(new PTableKey(null, physicalName)).getTableStats(); } catch (TableNotFoundException e) { // Possible when the table timestamp == current timestamp - 1. // This would be most likely during the initial index build of a view index @@ -3089,6 +3089,6 @@ public class MetaDataClient { //TODO just use view.getParentName().getString() after implementing https://issues.apache.org/jira/browse/PHOENIX-2114 SelectStatement select = new SQLParser(view.getViewStatement()).parseQuery(); String parentName = SchemaUtil.normalizeFullTableName(select.getFrom().toString().trim()); - return connection.getMetaDataCache().getTable(new PTableKey(view.getTenantId(), parentName)); + return connection.getTable(new PTableKey(view.getTenantId(), parentName)); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java index 4f87765..2e6142a 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java @@ -355,7 +355,7 @@ public class PhoenixRuntime { PTable table = null; PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); try { - table = pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), name)); + table = pconn.getTable(new PTableKey(pconn.getTenantId(), name)); } catch (TableNotFoundException e) { String schemaName = SchemaUtil.getSchemaNameFromFullName(name); String tableName = SchemaUtil.getTableNameFromFullName(name); http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java index 5ff63dc..dd7b181 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java @@ -159,7 +159,7 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest { String query = "CREATE TABLE t1 (k integer not null primary key, a.k decimal, b.k decimal)"; conn.createStatement().execute(query); PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - PColumn c = pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), "T1")).getColumn("K"); + PColumn c = pconn.getTable(new PTableKey(pconn.getTenantId(), "T1")).getColumn("K"); assertTrue(SchemaUtil.isPKColumn(c)); } finally { conn.close(); @@ -1170,7 +1170,7 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest { private void assertImmutableRows(Connection conn, String fullTableName, boolean expectedValue) throws SQLException { PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - assertEquals(expectedValue, pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows()); + assertEquals(expectedValue, pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows()); } @Test http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java b/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java index e645383..d142672 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java @@ -646,7 +646,7 @@ public class SkipScanBigFilterTest extends BaseConnectionlessQueryTest { } stmt.execute(); - final PTable table = conn.unwrap(PhoenixConnection.class).getMetaDataCache().getTable(new PTableKey(null, "PERF.BIG_OLAP_DOC")); + final PTable table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, "PERF.BIG_OLAP_DOC")); GuidePostsInfo info = new GuidePostsInfo(0,Collections.<byte[]> emptyList(), 0l); for (byte[] gp : guidePosts) { info.addGuidePost(gp, 1000); http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java index 592ac7c..27ed370 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/index/IndexMaintainerTest.java @@ -100,8 +100,8 @@ public class IndexMaintainerTest extends BaseConnectionlessQueryTest { try { conn.createStatement().execute("CREATE INDEX idx ON " + fullTableName + "(" + indexColumns + ") " + (includeColumns.isEmpty() ? "" : "INCLUDE (" + includeColumns + ") ") + (indexProps.isEmpty() ? "" : indexProps)); PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - PTable table = pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)); - PTable index = pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(),fullIndexName)); + PTable table = pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)); + PTable index = pconn.getTable(new PTableKey(pconn.getTenantId(),fullIndexName)); ImmutableBytesWritable ptr = new ImmutableBytesWritable(); table.getIndexMaintainers(ptr, pconn); List<IndexMaintainer> c1 = IndexMaintainer.deserialize(ptr, builder); http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java index abaaeb5..452ea4d 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java @@ -123,7 +123,7 @@ public class BaseConnectionlessQueryTest extends BaseTest { props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(HConstants.LATEST_TIMESTAMP)); PhoenixConnection conn = DriverManager.getConnection(PHOENIX_CONNECTIONLESS_JDBC_URL, props).unwrap(PhoenixConnection.class); try { - PTable table = conn.getMetaDataCache().getTable(new PTableKey(null, ATABLE_NAME)); + PTable table = conn.getTable(new PTableKey(null, ATABLE_NAME)); ATABLE = table; ORGANIZATION_ID = new ColumnRef(new TableRef(table), table.getColumn("ORGANIZATION_ID").getPosition()).newColumnExpression(); ENTITY_ID = new ColumnRef(new TableRef(table), table.getColumn("ENTITY_ID").getPosition()).newColumnExpression(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/test/java/org/apache/phoenix/query/ParallelIteratorsSplitTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/ParallelIteratorsSplitTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/ParallelIteratorsSplitTest.java index ed1f3e4..6febf60 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/ParallelIteratorsSplitTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/ParallelIteratorsSplitTest.java @@ -104,7 +104,7 @@ public class ParallelIteratorsSplitTest extends BaseConnectionlessQueryTest { Connection conn = DriverManager.getConnection(getUrl(), props); PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - PTable table = pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), TABLE_NAME)); + PTable table = pconn.getTable(new PTableKey(pconn.getTenantId(), TABLE_NAME)); TableRef tableRef = new TableRef(table); List<HRegionLocation> regions = pconn.getQueryServices().getAllTableRegions(tableRef.getTable().getPhysicalName().getBytes()); List<KeyRange> ranges = getSplits(tableRef, scan, regions, scanRanges); http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeySchemaTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeySchemaTest.java b/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeySchemaTest.java index bcd08f0..6977103 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeySchemaTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeySchemaTest.java @@ -56,7 +56,7 @@ public class RowKeySchemaTest extends BaseConnectionlessQueryTest { String fullTableName = SchemaUtil.getTableName(SchemaUtil.normalizeIdentifier(schemaName),SchemaUtil.normalizeIdentifier(tableName)); conn.createStatement().execute("CREATE TABLE " + fullTableName + "(" + dataColumns + " CONSTRAINT pk PRIMARY KEY (" + pk + ")) " + (dataProps.isEmpty() ? "" : dataProps) ); PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - PTable table = pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)); + PTable table = pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)); conn.close(); StringBuilder buf = new StringBuilder("UPSERT INTO " + fullTableName + " VALUES("); for (int i = 0; i < values.length; i++) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/6f05484a/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeyValueAccessorTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeyValueAccessorTest.java b/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeyValueAccessorTest.java index 23ec4bf..7ab72d6 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeyValueAccessorTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/schema/RowKeyValueAccessorTest.java @@ -52,7 +52,7 @@ public class RowKeyValueAccessorTest extends BaseConnectionlessQueryTest { String fullTableName = SchemaUtil.getTableName(SchemaUtil.normalizeIdentifier(schemaName),SchemaUtil.normalizeIdentifier(tableName)); conn.createStatement().execute("CREATE TABLE " + fullTableName + "(" + dataColumns + " CONSTRAINT pk PRIMARY KEY (" + pk + ")) " + (dataProps.isEmpty() ? "" : dataProps) ); PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); - PTable table = pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)); + PTable table = pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)); conn.close(); StringBuilder buf = new StringBuilder("UPSERT INTO " + fullTableName + " VALUES("); for (int i = 0; i < values.length; i++) {
