BinShi-SecularBird commented on a change in pull request #608: PHOENIX-5539 
Full row index write at the last write phase for mutable…
URL: https://github.com/apache/phoenix/pull/608#discussion_r339211946
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java
 ##########
 @@ -555,33 +570,30 @@ private void 
prepareIndexMutations(ObserverContext<RegionCoprocessorEnvironment>
                   // add the VERIFIED cell, which is the empty cell
                   Mutation m = next.getFirst().getFirst();
                   boolean rebuild = 
PhoenixIndexMetaData.isIndexRebuild(m.getAttributesMap());
-                  long ts = getMaxTimestamp(m);
                   if (rebuild) {
                       if (m instanceof Put) {
+                          long ts = getMaxTimestamp(m);
+                          // Remove the empty column prepared by Index codec 
as we need to change its value
+                          removeEmptyColumn(m, emptyCF, emptyCQ);
                           ((Put)m).addColumn(emptyCF, emptyCQ, ts, 
VERIFIED_BYTES);
                       }
                   } else {
-                      if (m instanceof Put) {
-                          ((Put)m).addColumn(emptyCF, emptyCQ, ts, 
UNVERIFIED_BYTES);
-                          // Ignore post index updates (i.e., the third write 
phase updates) for this row if it is
-                          // going through concurrent updates
-                          ImmutableBytesPtr rowKey = new 
ImmutableBytesPtr(next.getSecond());
-                          if (!context.pendingRows.contains(rowKey)) {
-                              Put put = new Put(m.getRow());
-                              put.addColumn(emptyCF, emptyCQ, ts, 
VERIFIED_BYTES);
-                              context.intermediatePostIndexUpdates.add(new 
Pair<>(new Pair<>(put, next.getFirst().getSecond()), next.getSecond()));
-                          }
-                      } else {
-                          // For a delete mutation, first unverify the 
existing row in the index table and then delete
-                          // the row from the index table after deleting the 
corresponding row from the data table
-                          indexUpdatesItr.remove();
-                          Put put = new Put(m.getRow());
-                          put.addColumn(emptyCF, emptyCQ, ts, 
UNVERIFIED_BYTES);
-                          indexUpdatesForDeletes.add(new Pair<>(put, 
next.getFirst().getSecond()));
-                          // Ignore post index updates (i.e., the third write 
phase updates) for this row if it is
-                          // going through concurrent updates
-                          ImmutableBytesPtr rowKey = new 
ImmutableBytesPtr(next.getSecond());
-                          if (!context.pendingRows.contains(rowKey)) {
+                      indexUpdatesItr.remove();
+                      // For this mutation whether it is put or delete, set 
the status of the index row "unverified"
+                      // This will be done before the data table row is 
updated (i.e., in the first write phase)
+                      Put unverifiedPut = new Put(m.getRow());
+                      unverifiedPut.addColumn(emptyCF, emptyCQ, now, 
UNVERIFIED_BYTES);
+                      context.preIndexUpdates.add(new Pair <>(unverifiedPut, 
next.getFirst().getSecond()));
+                      // Ignore post index updates (i.e., the third write 
phase updates) for this row if it is
+                      // going through concurrent updates
+                      ImmutableBytesPtr rowKey = new 
ImmutableBytesPtr(next.getSecond());
+                      if (!context.pendingRows.contains(rowKey)) {
+                          if (m instanceof Put) {
+                              // Remove the empty column prepared by Index 
codec as we need to change its value
+                              removeEmptyColumn(m, emptyCF, emptyCQ);
+                              ((Put) m).addColumn(emptyCF, emptyCQ, now, 
VERIFIED_BYTES);
+                              context.intermediatePostIndexUpdates.add(next);
 
 Review comment:
   Move "context.intermediatePostIndexUpdates.add(next);" outside of if ... 
else?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to