OAK-12010 Simplified index management (without optimizer)#2689
OAK-12010 Simplified index management (without optimizer)#2689thomasmueller merged 16 commits intotrunkfrom
Conversation
bhabegger
left a comment
There was a problem hiding this comment.
Nice clean work 👍
I like the test coverage and the comments among the rest !
I don't see anything blocking and just have a few comments/suggestions.
| if (!diffContent.exists()) { | ||
| continue; | ||
| } | ||
| PropertyState lastMod = diffContent.getProperty("jcr:lastModified"); |
There was a problem hiding this comment.
Is there not a constant definition for this type of "well-known" entries ? (same for :lastProcessed, jcr:data, /oak:index/, etc.)
In my opinion this helps a lot to understand, identify in one go what are the 'system' properties, paths, etc., and know where they are used. But also have them documented in the code base as javadoc.
(Not a blocker, just a curiosity 😉)
There was a problem hiding this comment.
There probably is. I agree we are not consistently using these constants, so there is a risk of typos.
There was a problem hiding this comment.
I used constants now where available, and did add new ones where I think it is useful (which -- granted -- is subjective).
| import java.util.ArrayList; | ||
|
|
||
| import org.apache.felix.inventory.Format; | ||
| import org.apache.jackrabbit.oak.commons.json.JsonObject; |
There was a problem hiding this comment.
I'm guessing that OAK has it's own JSON processing library for historical reasons ?
| + " } }"); | ||
|
|
||
| repositoryDefinitions = RootIndexesListService.getRootIndexDefinitions(store, "lucene"); | ||
| assertSameJson("{\n" |
There was a problem hiding this comment.
It's a shame Java 11 is a bit too early for text blocks :)
There was a problem hiding this comment.
I agree (btw. text blocks are not "raw" and still need escaping).
But I think it's readable as is.
| public void createDummy() { | ||
| // when enabling "deleteCreatesDummyIndex", then a dummy index is created | ||
| // (that indexes /dummy, which doesn't exist) | ||
| String merged = new DiffIndexMerger(new String[0], true, true, false).processMerge(JsonObject.fromJson("{}" |
There was a problem hiding this comment.
Which true is it ?
| String merged = new DiffIndexMerger(new String[0], true, true, false).processMerge(JsonObject.fromJson("{}" | |
| boolean deleteCreatesDummyIndex = true; | |
| String merged = new DiffIndexMerger(new String[0], deleteCreatesDummyIndex, true, false).processMerge(JsonObject.fromJson("{}" |
Would make it explicit
There was a problem hiding this comment.
Hm, "list of boolean flags" is not user friendly... thinking about an alternative.
There was a problem hiding this comment.
I added setters (there no real harm to not have the fields final in this case). Sure we could also add a Builder. Or a Factory, or AdapterFactoryBuilder... :-)
…/diff/DiffIndex.java Co-authored-by: Benjamin Habegger <benjamin@habegger.tech>
…/diff/DiffIndex.java Co-authored-by: Benjamin Habegger <benjamin@habegger.tech>
amit-jain
left a comment
There was a problem hiding this comment.
Overall looks good to me!!
A few minor suggestions added.
| * (input) | ||
| * @return whether a new version of an index was added | ||
| */ | ||
| public boolean processMerge(String indexName, JsonObject indexDiff, JsonObject newImageLuceneDefinitions, JsonObject combined) { |
There was a problem hiding this comment.
yes recommend breaking this method, example (from comments)
- findLatestVersions
- performMerge
- isChanged
- addMetadata
…/diff/DiffIndex.java Co-authored-by: Amit Jain <amitj@apache.org>
…/diff/DiffIndexMerger.java Co-authored-by: Amit Jain <amitj@apache.org>
…/diff/DiffIndex.java Co-authored-by: Amit Jain <amitj@apache.org>
…/diff/JsonNodeBuilder.java Co-authored-by: Benjamin Habegger <benjamin@habegger.tech>
…/diff/DiffIndex.java Co-authored-by: Amit Jain <amitj@apache.org>
|
ChlineSaurus
left a comment
There was a problem hiding this comment.
Overall looks good to me, 😌 good clean code
I added a few comments
There was a problem hiding this comment.
What's the purpose of the four files on the oak-core root level? For me it looks like duplicate code to code in /oak/plugins/diff and to the test code 🤔
There was a problem hiding this comment.
Thanks a lot! I committed them by mistake, now removed.
| log("Latest customized: {}", latestCustomizedKey); | ||
| if (latestProduct == null) { | ||
| if (indexName.indexOf('.') >= 0) { | ||
| // a fully custom index needs to contains a dot |
There was a problem hiding this comment.
Detail: Typo, should be "contain"
| merged = processMerge(latestProductIndex, indexDiff); | ||
| } | ||
|
|
||
| // compare to the latest version of the this index |
There was a problem hiding this comment.
Detail: Typo "the this index" to "the index"
| } | ||
| } | ||
| // store now, so a change is only processed once | ||
| diffContent.setProperty(DiffIndexMerger.LAST_PROCESSED, modified); |
There was a problem hiding this comment.
In my understanding, we always (even in case of failure) set the LAST_PROCESSED property, as it is set before the processing, and in the case of failure will be committed when the error is committed. Thus we don't have a retry in case of failure. Do I understand this right? And is this intentional?
There was a problem hiding this comment.
Retry wouldn't make sense: it would fail again in the same way.
* OAK-12010 Simplified index management (without optimizer) * OAK-12010 Simplified index management * OAK-12010 Simplified index management * OAK-12010 Simplified index management * Update oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java Co-authored-by: Benjamin Habegger <benjamin@habegger.tech> * Update oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java Co-authored-by: Benjamin Habegger <benjamin@habegger.tech> * Update oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java Co-authored-by: Amit Jain <amitj@apache.org> * Update oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndexMerger.java Co-authored-by: Amit Jain <amitj@apache.org> * Update oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java Co-authored-by: Amit Jain <amitj@apache.org> * Update oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/JsonNodeBuilder.java Co-authored-by: Benjamin Habegger <benjamin@habegger.tech> * Update oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java Co-authored-by: Amit Jain <amitj@apache.org> * OAK-12010 Simplified index management * OAK-12010 Simplified index management * OAK-12010 Simplified index management * OAK-12010 Simplified index management * OAK-12010 Simplified index management --------- Co-authored-by: Benjamin Habegger <benjamin@habegger.tech> Co-authored-by: Amit Jain <amitj@apache.org>



This is a subset of the (much) larger draft PR #2652
This is just support for the "diff.index"; without the optimizer.