gjacoby126 commented on code in PR #1563:
URL: https://github.com/apache/phoenix/pull/1563#discussion_r1102943974


##########
phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java:
##########
@@ -90,26 +89,33 @@ public StoreFileReader 
preStoreFileReaderOpen(ObserverContext<RegionCoprocessorE
         RegionInfo childRegion = region.getRegionInfo();
         byte[] splitKey = null;
         if (reader == null && r != null) {
-            
if(!p.toString().contains(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
+            if 
(!p.toString().contains(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
                 return reader;
             }
-            PhoenixConnection conn = null;
             Table metaTable = null;
             byte[] regionStartKeyInHFile = null;
-            try (Connection hbaseConn =
-                    
ConnectionFactory.createConnection(ctx.getEnvironment().getConfiguration())) {
+
+            try (PhoenixConnection conn =
+                    
QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration())
+                            .unwrap(PhoenixConnection.class)) {
+                // This is the CQSI shared Connection. MUST NOT be closed.
+                Connection hbaseConn = 
conn.getQueryServices().getAdmin().getConnection();
                 Scan scan = CompatUtil.getScanForTableName(hbaseConn, 
tableName);
                 SingleColumnValueFilter scvf = null;
                 if (Reference.isTopFileRegion(r.getFileRegion())) {
-                    scvf = new 
SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
-                        HConstants.SPLITB_QUALIFIER, CompareOperator.EQUAL, 
RegionInfoUtil.toByteArray(region.getRegionInfo()));
+                    scvf =
+                            new 
SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
+                                    HConstants.SPLITB_QUALIFIER, 
CompareOperator.EQUAL,
+                                    
RegionInfoUtil.toByteArray(region.getRegionInfo()));
                     scvf.setFilterIfMissing(true);
                 } else {
-                    scvf = new 
SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
-                        HConstants.SPLITA_QUALIFIER, CompareOperator.EQUAL, 
RegionInfoUtil.toByteArray(region.getRegionInfo()));
+                    scvf =
+                            new 
SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
+                                    HConstants.SPLITA_QUALIFIER, 
CompareOperator.EQUAL,
+                                    
RegionInfoUtil.toByteArray(region.getRegionInfo()));
                     scvf.setFilterIfMissing(true);
                 }
-                if(scvf != null) scan.setFilter(scvf);
+                if (scvf != null) scan.setFilter(scvf);

Review Comment:
   nit: checkstyle is warning on the 1-line if statement. 



##########
phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java:
##########
@@ -90,26 +89,33 @@ public StoreFileReader 
preStoreFileReaderOpen(ObserverContext<RegionCoprocessorE
         RegionInfo childRegion = region.getRegionInfo();
         byte[] splitKey = null;
         if (reader == null && r != null) {
-            
if(!p.toString().contains(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
+            if 
(!p.toString().contains(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
                 return reader;
             }
-            PhoenixConnection conn = null;
             Table metaTable = null;
             byte[] regionStartKeyInHFile = null;
-            try (Connection hbaseConn =
-                    
ConnectionFactory.createConnection(ctx.getEnvironment().getConfiguration())) {
+
+            try (PhoenixConnection conn =
+                    
QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration())
+                            .unwrap(PhoenixConnection.class)) {
+                // This is the CQSI shared Connection. MUST NOT be closed.
+                Connection hbaseConn = 
conn.getQueryServices().getAdmin().getConnection();
                 Scan scan = CompatUtil.getScanForTableName(hbaseConn, 
tableName);
                 SingleColumnValueFilter scvf = null;
                 if (Reference.isTopFileRegion(r.getFileRegion())) {
-                    scvf = new 
SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
-                        HConstants.SPLITB_QUALIFIER, CompareOperator.EQUAL, 
RegionInfoUtil.toByteArray(region.getRegionInfo()));
+                    scvf =
+                            new 
SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
+                                    HConstants.SPLITB_QUALIFIER, 
CompareOperator.EQUAL,
+                                    
RegionInfoUtil.toByteArray(region.getRegionInfo()));
                     scvf.setFilterIfMissing(true);
                 } else {
-                    scvf = new 
SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
-                        HConstants.SPLITA_QUALIFIER, CompareOperator.EQUAL, 
RegionInfoUtil.toByteArray(region.getRegionInfo()));
+                    scvf =
+                            new 
SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
+                                    HConstants.SPLITA_QUALIFIER, 
CompareOperator.EQUAL,
+                                    
RegionInfoUtil.toByteArray(region.getRegionInfo()));
                     scvf.setFilterIfMissing(true);
                 }
-                if(scvf != null) scan.setFilter(scvf);
+                if (scvf != null) scan.setFilter(scvf);

Review Comment:
   It's also warning on the existing 1-line if statement on 186, which would be 
good to fix while we're at it. 



-- 
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: issues-unsubscr...@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to