Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support trie implemention for FieldIndex #18673

Conversation

thu-david
Copy link
Contributor

What changes are proposed in this pull request?

I have added new implemention for fieldIndex when use pageid as key.

Why are the changes needed?

Because the hashmap use much memory when save so many same prefix id.

Does this PR introduce any user facing changes?

No.

*/
public NonUniqueFieldIndexInTrie(IndexDefinition<T, V> indexDefinition) {
// Wrap the PatriciaTrie with Collections.synchronizedMap to make it thread-safe
mIndexTrie = new PatriciaTrie<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the default parameters if you use an empty parameter list to create PatriciaTrie?

synchronized (mIndexTrie) { // Synchronize on the trie map to ensure thread safety
mIndexTrie.compute(fieldValueStr, (key, set) -> {
if (set == null) {
set = Collections.newSetFromMap(new ConcurrentHashMap<>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not directly using a ConcurrentHashSet?

@alluxio-bot
Copy link
Contributor

Automated checks report:

  • PR title follows the conventions: FAIL
    • The title of the PR does not pass all the checks. Please fix the following issues:
      • Title must not end with punctuation
  • Commits associated with Github account: PASS

Some checks failed. Please fix the reported issues and reply
alluxio-bot, check this please
to re-run checks.

* @param <T> the type of object
*/
@ThreadSafe
public class IndexedSetTrie<T> extends AbstractSet<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the only methods you modified is the ctor and the getByPrefix, why not regarding IndexedSetTrie as a descedant of IndexedSet? Then you just need to change ctor and gerByPrefix, instead of copying all the methods.

@@ -1039,15 +1038,11 @@ public void searchPagesByPrefix() throws Exception {
}

private void checkPrefixSearch(UfsUrl rootUrl, UfsUrl prefixUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should remove the @Ignore annotation of searchPagesByPrefix(), so the test will be run on github CICD.

@thu-david thu-david changed the title Support trie implemention for FieldIndex. Support trie implemention for FieldIndex Sep 3, 2024
@alluxio-bot
Copy link
Contributor

Automated checks report:

  • PR title follows the conventions: PASS
  • Commits associated with Github account: PASS

All checks passed!

@thu-david thu-david closed this Oct 21, 2024
@thu-david thu-david force-pushed the feature/WorkerMemoryOptimization branch from 76435ee to 56d54fd Compare October 21, 2024 06:18
@thu-david thu-david reopened this Oct 21, 2024
@thu-david
Copy link
Contributor Author

I have fixed the conflict.

@YichuanSun
Copy link
Contributor

alluxio-bot, merge this please.

@alluxio-bot
Copy link
Contributor

merge failed:
Merge refused because pull request does not have label start with type-

@YichuanSun YichuanSun added the type-feature This issue is a feature request label Oct 21, 2024
@YichuanSun
Copy link
Contributor

alluxio-bot, merge this please.

@alluxio-bot alluxio-bot merged commit 4aeca16 into Alluxio:feature/WorkerMemoryOptimization Oct 21, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature This issue is a feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants