takawitter / trie4j

PATRICIA, Double Array, LOUDS Trie implementations for Java
Apache License 2.0
174 stars 31 forks source link

Exception when looking up particular strings in MapDoubleArray #22

Closed amake closed 8 years ago

amake commented 8 years ago

The following produces an ArrayIndexOutOfBoundsException:

MapPatriciaTrie<Object> mpt = new MapPatriciaTrie<>();
mpt.insert("FOO");
mpt.get("F");
mpt.get("f");

MapDoubleArray<Object> mda = new MapDoubleArray<>(mpt);
mda.get("F");
mda.get("f"); // exception here
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
    at org.trie4j.bv.BytesRank1OnlySuccinctBitVector.isOne(BytesRank1OnlySuccinctBitVector.java:90)
    at org.trie4j.bv.BytesRank1OnlySuccinctBitVector.get(BytesRank1OnlySuccinctBitVector.java:80)
    at org.trie4j.doublearray.DoubleArray.getTermId(DoubleArray.java:243)
    at org.trie4j.AbstractTermIdMapTrie.get(AbstractTermIdMapTrie.java:141)

I would expect this to simply return null rather than throw an exception. My use case is (natural-language) dictionary lookup with mixed-case keys.

takawitter commented 8 years ago

Thanks Aaron,

Which version did you use? I tested your code with 0.9.2 and got no error (mda.get("f") returns null).

amake commented 8 years ago

My apologies, it was 0.9.1. I updated to 0.9.2 and the issue seems to be resolved.

Thanks!