gjacoby126 commented on a change in pull request #469: PHOENIX-5156 Consistent 
Global Indexes for Non-Transactional Tables
URL: https://github.com/apache/phoenix/pull/469#discussion_r266628268
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/hbase/index/Indexer.java
 ##########
 @@ -509,28 +438,104 @@ public void 
preBatchMutateWithExceptions(ObserverContext<RegionCoprocessorEnviro
           byte[] tableName = 
c.getEnvironment().getRegion().getTableDescriptor().getTableName().getName();
           Iterator<Pair<Mutation, byte[]>> indexUpdatesItr = 
indexUpdates.iterator();
           List<Mutation> localUpdates = new 
ArrayList<Mutation>(indexUpdates.size());
+          List<Pair<Mutation, byte[]>> postIndexUpdates = new 
ArrayList<>(indexUpdates.size());
+          List<Pair<Mutation, byte[]>> indexUpdatesForDeletes = new 
ArrayList<>(indexUpdates.size());
+          IndexMetaData indexMetaData = 
this.builder.getIndexMetaData(miniBatchOp);
+          if (!(indexMetaData instanceof PhoenixIndexMetaData)) {
+              throw new DoNotRetryIOException(
+                      "preBatchMutateWithExceptions: indexMetaData is not an 
instance of PhoenixIndexMetaData " +
+                              
c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString());
+          }
+          List<IndexMaintainer> maintainers = 
((PhoenixIndexMetaData)indexMetaData).getIndexMaintainers();
           while(indexUpdatesItr.hasNext()) {
               Pair<Mutation, byte[]> next = indexUpdatesItr.next();
               if (Bytes.compareTo(next.getSecond(), tableName) == 0) {
                   localUpdates.add(next.getFirst());
                   indexUpdatesItr.remove();
               }
+              else {
+                  // get index maintainer for this index table
+                  IndexMaintainer indexMaintainer = null;
+                  Iterator<IndexMaintainer> maintainerIterator = 
maintainers.iterator();
+                  while (maintainerIterator.hasNext()) {
+                      IndexMaintainer maintainer = maintainerIterator.next();
+                      if (Bytes.compareTo(next.getSecond(), 
maintainer.getIndexTableName()) == 0) {
+                          indexMaintainer = maintainer;
+                          break;
+                      }
+                  }
+
+                  if (indexMaintainer == null) {
+                      throw new DoNotRetryIOException(
+                              "preBatchMutateWithExceptions: indexMaintainer 
is null " +
+                                      
c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString());
+                  }
+                  byte[] emptyCF = 
indexMaintainer.getEmptyKeyValueFamily().copyBytesIfNecessary();
+                  // add the VERIFIED cell
+                  Mutation m = next.getFirst();
+                  boolean rebuild = 
PhoenixIndexMetaData.isIndexRebuild(m.getAttributesMap());
+                  long ts = 0;
+                  //if (rebuild) {
+                      Iterator iterator = 
m.getFamilyCellMap().entrySet().iterator();
+                      while (iterator.hasNext()) {
 
 Review comment:
   can break the getting of the latest timestamp in a mutation out into its own 
helper method.

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