rishabhdaim commented on code in PR #847:
URL: https://github.com/apache/jackrabbit-oak/pull/847#discussion_r1129160463


##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/indexversion/PurgeOldIndexVersion.java:
##########
@@ -195,21 +227,51 @@ private void purgeOldIndexVersion(NodeStore store, 
List<IndexVersionOperation> t
             String nodeName = 
toDeleteIndexNameObject.getIndexName().getNodeName();
             NodeBuilder nodeBuilder = 
PurgeOldVersionUtils.getNode(rootBuilder, nodeName);
             if (nodeBuilder.exists()) {
+                String type = 
nodeBuilder.getProperty(TYPE_PROPERTY_NAME).getValue(Type.STRING);
+                List<IndexEditorProvider> indexEditorProviders = 
ImmutableList.of(
+                        new ReferenceEditorProvider(), new 
PropertyIndexEditorProvider(), new NodeCounterEditorProvider());
+                EditorHook hook = new EditorHook(new 
IndexUpdateProvider(CompositeIndexEditorProvider.compose(indexEditorProviders)));
                 if (toDeleteIndexNameObject.getOperation() == 
IndexVersionOperation.Operation.DELETE_HIDDEN_AND_DISABLE) {
                     LOG.info("Disabling {}", nodeName);
-                    nodeBuilder.setProperty("type", "disabled", Type.STRING);
-                    EditorHook hook = new EditorHook(new 
IndexUpdateProvider(new PropertyIndexEditorProvider()));
+                    nodeBuilder.setProperty(TYPE_PROPERTY_NAME, TYPE_DISABLED, 
Type.STRING);
+                    // Set this property :originalType so that when the purge 
job marks this index for deletion in later runs -
+                    // the proper post deletion hook can be called based on 
the original index type.
+                    nodeBuilder.setProperty(ORIGINAL_TYPE_PROPERTY_NAME, type, 
Type.STRING);
                     store.merge(rootBuilder, hook, CommitInfo.EMPTY);
                     
PurgeOldVersionUtils.recursiveDeleteHiddenChildNodes(store, nodeName);
                 } else if (toDeleteIndexNameObject.getOperation() == 
IndexVersionOperation.Operation.DELETE) {
+                    preserveDetailsFromIndexDefForPostOp(nodeBuilder);
                     LOG.info("Deleting {}", nodeName);
                     nodeBuilder.remove();
-                    EditorHook hook = new EditorHook(new 
IndexUpdateProvider(new PropertyIndexEditorProvider()));
                     store.merge(rootBuilder, hook, CommitInfo.EMPTY);
+                    
postDeleteOp(toDeleteIndexNameObject.getIndexName().getNodeName());
                 }
             } else {
                 LOG.error("nodebuilder null for path " + nodeName);
             }
         }
     }
+
+    /**
+     * @return IndexType served by the implementation like lucene or 
elasticsearch
+     */
+    protected abstract String getIndexType();

Review Comment:
   Since we are using `getIndexType()` without any null check, I think 
annotating this method with `@NonNull` is better.



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