You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by an...@apache.org on 2017/02/06 14:28:46 UTC
phoenix git commit: PHOENIX-3610 Fix tableName used to get the index
maintainers while creating HalfStoreFileReader for local index store
Repository: phoenix
Updated Branches:
refs/heads/master 76e4264d0 -> 172115a06
PHOENIX-3610 Fix tableName used to get the index maintainers while creating HalfStoreFileReader for local index store
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/172115a0
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/172115a0
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/172115a0
Branch: refs/heads/master
Commit: 172115a0653ec5308731c513772821ccfdc47f19
Parents: 76e4264
Author: Ankit Singhal <an...@gmail.com>
Authored: Mon Feb 6 19:58:29 2017 +0530
Committer: Ankit Singhal <an...@gmail.com>
Committed: Mon Feb 6 19:58:29 2017 +0530
----------------------------------------------------------------------
.../IndexHalfStoreFileReaderGenerator.java | 14 ++----------
.../java/org/apache/phoenix/util/IndexUtil.java | 24 ++++++++++++++++++++
.../org/apache/phoenix/util/MetaDataUtil.java | 5 +---
3 files changed, 27 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/172115a0/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
index 537febd..a8ebe75 100644
--- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
+++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
@@ -61,14 +61,11 @@ import org.apache.phoenix.schema.PTableType;
import org.apache.phoenix.util.ByteUtil;
import org.apache.phoenix.util.IndexUtil;
import org.apache.phoenix.util.MetaDataUtil;
-import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.QueryUtil;
import org.apache.phoenix.util.RepairUtil;
import com.google.common.collect.Lists;
-import jline.internal.Log;
-
public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver {
@Override
@@ -149,7 +146,7 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver {
try {
conn = QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration()).unwrap(
PhoenixConnection.class);
- PTable dataTable = PhoenixRuntime.getTableNoCache(conn, tableName.getNameAsString());
+ PTable dataTable = IndexUtil.getPDataTable(conn, ctx.getEnvironment().getRegion().getTableDesc());
List<PTable> indexes = dataTable.getIndexes();
Map<ImmutableBytesWritable, IndexMaintainer> indexMaintainers =
new HashMap<ImmutableBytesWritable, IndexMaintainer>();
@@ -272,14 +269,7 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver {
try {
PhoenixConnection conn = QueryUtil.getConnection(env.getConfiguration())
.unwrap(PhoenixConnection.class);
- String dataTableName = MetaDataUtil.getPhoenixTableNameFromDesc(env.getRegion().getTableDesc());
- if (dataTableName == null) {
- Log.warn("Found corrupted local index for region:" + env.getRegion().getRegionInfo().toString()
- + " but data table attribute is not set in tableDescriptor "
- + "so automatic repair will not succeed" + ", local index created are may be from old client");
- return null;
- }
- PTable dataPTable = PhoenixRuntime.getTable(conn, dataTableName);
+ PTable dataPTable = IndexUtil.getPDataTable(conn, env.getRegion().getTableDesc());
final List<IndexMaintainer> maintainers = Lists
.newArrayListWithExpectedSize(dataPTable.getIndexes().size());
for (PTable index : dataPTable.getIndexes()) {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/172115a0/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
index 54f0453..4a9cb57 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
@@ -23,6 +23,7 @@ import static org.apache.phoenix.util.PhoenixRuntime.getTable;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
+import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
@@ -32,6 +33,7 @@ import java.util.Map;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Delete;
@@ -738,4 +740,26 @@ public class IndexUtil {
public static boolean isLocalIndexStore(Store store) {
return store.getFamily().getNameAsString().startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX);
}
+
+ public static PTable getPDataTable(Connection conn, HTableDescriptor tableDesc) throws SQLException {
+ String dataTableName = Bytes.toString(tableDesc.getValue(MetaDataUtil.DATA_TABLE_NAME_PROP_BYTES));
+ String physicalTableName = tableDesc.getTableName().getNameAsString();
+ PTable pDataTable = null;
+ if (dataTableName == null) {
+ if (physicalTableName.contains(QueryConstants.NAMESPACE_SEPARATOR)) {
+ try {
+ pDataTable = PhoenixRuntime.getTable(conn, physicalTableName
+ .replace(QueryConstants.NAMESPACE_SEPARATOR, QueryConstants.NAME_SEPARATOR));
+ } catch (TableNotFoundException e) {
+ // could be a table mapped to external table
+ pDataTable = PhoenixRuntime.getTable(conn, physicalTableName);
+ }
+ }else{
+ pDataTable = PhoenixRuntime.getTable(conn, physicalTableName);
+ }
+ } else {
+ pDataTable = PhoenixRuntime.getTable(conn, dataTableName);
+ }
+ return pDataTable;
+ }
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/172115a0/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 b1b6725..5c41cce 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
@@ -560,7 +560,7 @@ public class MetaDataUtil {
public static final String DATA_TABLE_NAME_PROP_NAME = "DATA_TABLE_NAME";
- private static final byte[] DATA_TABLE_NAME_PROP_BYTES = Bytes.toBytes(DATA_TABLE_NAME_PROP_NAME);
+ public static final byte[] DATA_TABLE_NAME_PROP_BYTES = Bytes.toBytes(DATA_TABLE_NAME_PROP_NAME);
@@ -648,7 +648,4 @@ public class MetaDataUtil {
return Bytes.startsWith(cf, QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX_BYTES);
}
- public static String getPhoenixTableNameFromDesc(HTableDescriptor tableDesc) {
- return Bytes.toString(tableDesc.getValue(MetaDataUtil.DATA_TABLE_NAME_PROP_BYTES));
- }
}