kadirozde commented on a change in pull request #1256:
URL: https://github.com/apache/phoenix/pull/1256#discussion_r660011956



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
##########
@@ -574,20 +575,35 @@ public static void wrapResultUsingOffset(final 
RegionCoprocessorEnvironment envi
                 }
             }
             Result joinResult = null;
-            if (dataRegion != null) {
-                joinResult = dataRegion.get(get);
-            } else {
-                TableName dataTable =
-                    
TableName.valueOf(MetaDataUtil.getLocalIndexUserTableName(environment.getRegion().
-                        
getTableDescriptor().getTableName().getNameAsString()));
+            if (ScanUtil.isLocalIndex(scan)) {
+                if (dataRegion != null) {
+                    joinResult = dataRegion.get(get);
+                } else {
+                    TableName dataTable =
+                        
TableName.valueOf(MetaDataUtil.getLocalIndexUserTableName(environment.getRegion().
+                            
getTableDescriptor().getTableName().getNameAsString()));
+                    Table table = null;
+                    try {
+                        table = 
environment.getConnection().getTable(dataTable);
+                        joinResult = table.get(get);
+                    } finally {
+                        if (table != null) table.close();
+                    }
+                }
+            } else if (ScanUtil.isGlobalIndex(scan)) {
+                byte[] dataTableName = 
scan.getAttribute(PHYSICAL_DATA_TABLE_NAME);
                 Table table = null;
                 try {
-                    table = environment.getConnection().getTable(dataTable);
+                    table = ServerUtil.ConnectionFactory.
+                            
getConnection(ServerUtil.ConnectionType.INDEX_WRITER_CONNECTION, environment).
+                            getTable(TableName.valueOf(dataTableName));
                     joinResult = table.get(get);

Review comment:
       I was not sure if I do it in this PR or open a separate jira for that. 
We can buffer lots of data row keys in memory and then use a skip scan filter 
and even multiple threads to issue a separate scan for each data table region. 
Essentially, this is what we do for reverse index verification. However, it 
requires quite a bit code refactoring. Please note this PR updates both client 
and server code. If we leave the improvement to the second PR, that will update 
only the server side. What do you think?

##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
##########
@@ -574,20 +575,35 @@ public static void wrapResultUsingOffset(final 
RegionCoprocessorEnvironment envi
                 }
             }
             Result joinResult = null;
-            if (dataRegion != null) {
-                joinResult = dataRegion.get(get);
-            } else {
-                TableName dataTable =
-                    
TableName.valueOf(MetaDataUtil.getLocalIndexUserTableName(environment.getRegion().
-                        
getTableDescriptor().getTableName().getNameAsString()));
+            if (ScanUtil.isLocalIndex(scan)) {
+                if (dataRegion != null) {
+                    joinResult = dataRegion.get(get);
+                } else {
+                    TableName dataTable =
+                        
TableName.valueOf(MetaDataUtil.getLocalIndexUserTableName(environment.getRegion().
+                            
getTableDescriptor().getTableName().getNameAsString()));
+                    Table table = null;
+                    try {
+                        table = 
environment.getConnection().getTable(dataTable);
+                        joinResult = table.get(get);
+                    } finally {
+                        if (table != null) table.close();
+                    }
+                }
+            } else if (ScanUtil.isGlobalIndex(scan)) {
+                byte[] dataTableName = 
scan.getAttribute(PHYSICAL_DATA_TABLE_NAME);
                 Table table = null;
                 try {
-                    table = environment.getConnection().getTable(dataTable);
+                    table = ServerUtil.ConnectionFactory.
+                            
getConnection(ServerUtil.ConnectionType.INDEX_WRITER_CONNECTION, environment).
+                            getTable(TableName.valueOf(dataTableName));
                     joinResult = table.get(get);

Review comment:
       I have created https://issues.apache.org/jira/browse/PHOENIX-6501 for 
this improvement




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to