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

COLLECTIONS-873: create PatriciaTrieSet #589

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ekuvardin
Copy link

According to https://issues.apache.org/jira/browse/COLLECTIONS-873

MR is basically a draft or discussion of what to do.

I make PatriciaTrieSet based on PatriciaTrie under the hood.

Below I type what I don't like. Please give some advice.

The main problem is when I access PatriciaTrie, I have to return SortedSet.
But all collections under the hood of PatriciaTrie don't use SortedSet.
Thus, I wrap call under TreeSet.

For example

@Override
    public SortedSet<String> headSet(String toElement) {
        return new TreeSet<>(trie.headMap(toElement).keySet());
    }

This is overwhelming because the keySet is already sorted, and adding to a TreeSet also takes time.

To improve the situation, I make two approaches:

  1. Fully rewrite PatriciaTrieSet, copying logic with bit operations to the corresponding class.
    The drawback is that a change (bug) in bit operations leads to a rewrite in PatriciaTrieSet and PatriciaTrie independently.
  2. Extend the internal PatricaiTrie class to implement NavigableMap (PrefixRangeMap and RangeEntryMap + some other classes).
    public interface NavigableMap<K,V> extends SortedMap<K,V>
    From NavigableMap, I can get navigableKeySet and work with it in PatriciaTrieSet.

@garydgregory
Copy link
Member

Hello @ekuvardin
The build fails, it seems you did not read or follow the steps in https://github.com/apache/commons-collections/blob/master/.github/pull_request_template.md

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.

2 participants