palashc commented on code in PR #1575:
URL: https://github.com/apache/phoenix/pull/1575#discussion_r1240146269


##########
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java:
##########
@@ -2203,6 +2196,89 @@ public MetaDataResponse call(MetaDataService instance) 
throws IOException {
                 return rpcCallback.get();
             }
         });
+
+        //For view creation, if SYSCAT rpc succeeds, mark child_link rows as 
VERIFIED
+        if (!childLinkMutations.isEmpty()) {
+            try {
+                if (result.getMutationCode() == MutationCode.TABLE_NOT_FOUND) {
+                    sendChildLinkMutations(childLinkMutations, true, false, 
physicalTableNameBytes, schemaBytes);
+                } else {
+                    sendChildLinkMutations(childLinkMutations, true, true, 
physicalTableNameBytes, schemaBytes);
+                }
+            }
+            catch (SQLException e) {
+                //unverified rows will be repaired during read
+                LOGGER.debug("Exception in phase-3 of view creation: " + 
e.getMessage());
+                addChildLinkScanTask();
+            }
+        }
+        return result;
+    }
+
+    /*
+    Helper method to send mutations to SYSTEM.CHILD_LINK using its endpoint 
coprocessor
+     */
+    public void sendChildLinkMutations(List<Mutation> mutations, boolean 
isVerified, boolean isDelete,
+                                        byte[] physicalTableNameBytes, byte[] 
schemaBytes)
+            throws SQLException {
+
+        // get empty column information
+        PTable childLinkLogicalTable = getTable(null, 
PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME, HConstants.LATEST_TIMESTAMP);
+        byte[] emptyCF = 
SchemaUtil.getEmptyColumnFamily(childLinkLogicalTable);
+        byte[] emptyCQ = 
EncodedColumnsUtil.getEmptyKeyValueInfo(childLinkLogicalTable).getFirst();
+
+        // add empty column value to mutations or create delete mutations for 
phase-3
+        List<Mutation> childLinkMutations = new ArrayList<>();
+        for (Mutation m : mutations) {
+            if (isDelete) {
+                Delete delete = new Delete(m.getRow());
+                childLinkMutations.add(delete);
+            }
+            else {
+                Put put = isVerified ? new Put(m.getRow()) : (Put)m;
+                byte[] emptyColumnValue = isVerified ? VERIFIED_BYTES : 
UNVERIFIED_BYTES;
+                put.addColumn(emptyCF, emptyCQ, IndexUtil.getMaxTimestamp(m), 
emptyColumnValue);

Review Comment:
   Yes, you are right. I printed out all timestamps seen in 
`IndexUtil.getMaxTimestamp(m)` and for the test, they are always long max 
value. So these timestamps are being assigned at the server side? 



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