Skip to content

OAK-12010 Simplified index management (without optimizer)#2689

Merged
thomasmueller merged 16 commits intotrunkfrom
OAK-12010-subset
Feb 10, 2026
Merged

OAK-12010 Simplified index management (without optimizer)#2689
thomasmueller merged 16 commits intotrunkfrom
OAK-12010-subset

Conversation

@thomasmueller
Copy link
Copy Markdown
Member

@thomasmueller thomasmueller commented Jan 19, 2026

This is a subset of the (much) larger draft PR #2652

This is just support for the "diff.index"; without the optimizer.

Copy link
Copy Markdown
Contributor

@bhabegger bhabegger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There probably is. I agree we are not consistently using these constants, so there is a risk of typos.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing that OAK has it's own JSON processing library for historical reasons ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

+ " } }");

repositoryDefinitions = RootIndexesListService.getRootIndexDefinitions(store, "lucene");
assertSameJson("{\n"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a shame Java 11 is a bit too early for text blocks :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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("{}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which true is it ?

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, "list of boolean flags" is not user friendly... thinking about an alternative.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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... :-)

thomasmueller and others added 2 commits February 2, 2026 16:18
…/diff/DiffIndex.java

Co-authored-by: Benjamin Habegger <benjamin@habegger.tech>
…/diff/DiffIndex.java

Co-authored-by: Benjamin Habegger <benjamin@habegger.tech>
Copy link
Copy Markdown
Contributor

@amit-jain amit-jain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me!!
A few minor suggestions added.

Comment thread oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexName.java Outdated
* (input)
* @return whether a new version of an index was added
*/
public boolean processMerge(String indexName, JsonObject indexDiff, JsonObject newImageLuceneDefinitions, JsonObject combined) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes recommend breaking this method, example (from comments)

  • findLatestVersions
  • performMerge
  • isChanged
  • addMetadata

thomasmueller and others added 8 commits February 6, 2026 15:25
…/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>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Feb 6, 2026

@thomasmueller thomasmueller merged commit b00658b into trunk Feb 10, 2026
Copy link
Copy Markdown
Contributor

@ChlineSaurus ChlineSaurus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, 😌 good clean code
I added a few comments

Comment thread oak-core/DiffIndex.java
Copy link
Copy Markdown
Contributor

@ChlineSaurus ChlineSaurus Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detail: Typo, should be "contain"

merged = processMerge(latestProductIndex, indexDiff);
}

// compare to the latest version of the this index
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detail: Typo "the this index" to "the index"

}
}
// store now, so a change is only processed once
diffContent.setProperty(DiffIndexMerger.LAST_PROCESSED, modified);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retry wouldn't make sense: it would fail again in the same way.

reschke pushed a commit that referenced this pull request Feb 15, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants