palashc commented on code in PR #1575:
URL: https://github.com/apache/phoenix/pull/1575#discussion_r1240114340
##########
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:
Dump from one of the tests:
```
\x00\x00T_N000001\x00\x00V_N000003/0:LINK_TYPE/1687542526662/Put/vlen=1/seqid=0
column= LINK_TYPE val=\x04
\x00\x00T_N000001\x00\x00V_N000003/0:_0/1687542526683/Put/vlen=1/seqid=0
column= _0 val=\x01
\x00\x00T_N000001\x00\x00V_N000003/0:_0/1687542526662/Put/vlen=1/seqid=0
column= _0 val=\x02
```
--
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]