haridsv commented on code in PR #1751:
URL: https://github.com/apache/phoenix/pull/1751#discussion_r1510336887


##########
phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java:
##########
@@ -1587,6 +1623,56 @@ private PTable getTableFromCells(List<Cell> 
tableCellList, List<List<Cell>> allC
         return builder.build();
     }
 
+    private Long scanMaxLookbackAgeFromParent(byte[] key, long 
clientTimeStamp) throws IOException {
+        Scan scan = MetaDataUtil.newTableRowsScan(key, MIN_TABLE_TIMESTAMP, 
clientTimeStamp);
+        Table sysCat = ServerUtil.getHTableForCoprocessorScan(this.env,
+                SchemaUtil.getPhysicalTableName(SYSTEM_CATALOG_NAME_BYTES, 
env.getConfiguration()));
+        ResultScanner scanner = sysCat.getScanner(scan);
+        Result result = scanner.next();
+        boolean startCheckingForLink = false;
+        byte[] parentTableKey = null;
+        do {
+            if (result == null) {
+                return null;
+            }
+            else if (startCheckingForLink) {
+                byte[] linkTypeBytes = result.getValue(TABLE_FAMILY_BYTES, 
LINK_TYPE_BYTES);
+                if (linkTypeBytes != null) {
+                    LinkType linkType = 
LinkType.fromSerializedValue(linkTypeBytes[0]);
+                    int rowKeyColMetadataLength = 5;
+                    byte[][] rowKeyMetaData = new 
byte[rowKeyColMetadataLength][];
+                    getVarChars(result.getRow(), rowKeyColMetadataLength, 
rowKeyMetaData);

Review Comment:
   It is not in general a good practice to do static imports of functions.



##########
phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java:
##########
@@ -1587,6 +1623,56 @@ private PTable getTableFromCells(List<Cell> 
tableCellList, List<List<Cell>> allC
         return builder.build();
     }
 
+    private Long scanMaxLookbackAgeFromParent(byte[] key, long 
clientTimeStamp) throws IOException {
+        Scan scan = MetaDataUtil.newTableRowsScan(key, MIN_TABLE_TIMESTAMP, 
clientTimeStamp);
+        Table sysCat = ServerUtil.getHTableForCoprocessorScan(this.env,
+                SchemaUtil.getPhysicalTableName(SYSTEM_CATALOG_NAME_BYTES, 
env.getConfiguration()));
+        ResultScanner scanner = sysCat.getScanner(scan);
+        Result result = scanner.next();
+        boolean startCheckingForLink = false;
+        byte[] parentTableKey = null;
+        do {
+            if (result == null) {
+                return null;
+            }
+            else if (startCheckingForLink) {
+                byte[] linkTypeBytes = result.getValue(TABLE_FAMILY_BYTES, 
LINK_TYPE_BYTES);
+                if (linkTypeBytes != null) {
+                    LinkType linkType = 
LinkType.fromSerializedValue(linkTypeBytes[0]);
+                    int rowKeyColMetadataLength = 5;
+                    byte[][] rowKeyMetaData = new 
byte[rowKeyColMetadataLength][];
+                    getVarChars(result.getRow(), rowKeyColMetadataLength, 
rowKeyMetaData);
+                    if (linkType == VIEW_INDEX_PARENT_TABLE) {
+                        parentTableKey = 
getParentTableKeyFromChildRowKeyMetaData(rowKeyMetaData);
+                        return scanMaxLookbackAgeFromParent(parentTableKey, 
clientTimeStamp);

Review Comment:
   Why not `break` here and let the recursive call at line 1663 do the job?



-- 
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