[
https://issues.apache.org/jira/browse/PHOENIX-1264?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14152032#comment-14152032
]
James Taylor commented on PHOENIX-1264:
---------------------------------------
Looks good, [~ramkrishna]. One minor change and then +1. Remove the else
condition here (see TODO below), as in the normal flow of processing, this
update cache will already have been done (and you don't want to do it again as
that'd be another RPC):
{code}
diff --git
a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
index 59814cc..6857b92 100644
---
a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
+++
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ParallelIterators.java
@@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.util.Pair;
import org.apache.phoenix.compile.GroupByCompiler.GroupBy;
import org.apache.phoenix.compile.RowProjector;
import org.apache.phoenix.compile.StatementContext;
+import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult;
import org.apache.phoenix.filter.ColumnProjectionFilter;
import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
import org.apache.phoenix.job.JobManager.JobCallable;
@@ -53,6 +54,7 @@ import org.apache.phoenix.query.ConnectionQueryServices;
import org.apache.phoenix.query.KeyRange;
import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.MetaDataClient;
import org.apache.phoenix.schema.PColumnFamily;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTable.ViewType;
@@ -101,7 +103,24 @@ public class ParallelIterators extends ExplainTable
implements ResultIterators {
RowProjector projector, GroupBy groupBy, Integer limit,
ParallelIteratorFactory iteratorFactory)
throws SQLException {
super(context, tableRef, groupBy);
- this.splits = getSplits(context, tableRef, statement.getHint());
+ //MetaDataClient client = new MetaDataClient(context.getConnection());
+ PTable physicalTable = tableRef.getTable();
+ String physicalName =
tableRef.getTable().getPhysicalName().getString();
+ MetaDataClient client = new MetaDataClient(context.getConnection());
+ if (!physicalName.equals(physicalTable.getName().getString())) { //
tableRef is not for the physical table
+ String physicalSchemaName =
SchemaUtil.getSchemaNameFromFullName(physicalName);
+ String physicalTableName =
SchemaUtil.getTableNameFromFullName(physicalName);
+ // TODO: this will be an extra RPC to ensure we have the latest
guideposts, but is almost always
+ // unnecessary. We should instead track when the last time an
update cache was done for this
+ // for physical table and not do it again until some interval has
passed (it's ok to use stale stats).
+ MetaDataMutationResult result = client.updateCache(null, /* use
global tenant id to get physical table */
+ physicalSchemaName, physicalTableName);
+ physicalTable = result.getTable();
+ } else { // TODO: remove this, as it's already been done while
compiling the query
+
client.updateCache(tableRef.getTable().getSchemaName().getString(),
tableRef.getTable().getTableName()
+ .getString());
+ }
+ this.splits = getSplits(context, physicalTable, statement.getHint());
{code}
> Add StatisticsCollector to existing tables on first connection to cluster
> -------------------------------------------------------------------------
>
> Key: PHOENIX-1264
> URL: https://issues.apache.org/jira/browse/PHOENIX-1264
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: James Taylor
> Assignee: ramkrishna.s.vasudevan
> Attachments: Phoenix-1264_1.patch, Phoenix-1264_2.patch,
> Phoenix-1264_3.0_1.patch, Phoenix-1264_3.0_3.patch, Phoenix-1264_3.patch
>
>
> We'll need to add the StatisticsCollector to existing tables so that stats
> are kept for these tables. We typically do that on first connection to the
> cluster in ensureTableCreated when our system table is created by walking
> through the existing Phoenix tables. We only need to do it if the system
> table already exists (otherwise, it's a new installation).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)