Search in sources :

Example 1 with BytesRank1OnlySuccinctBitVector

use of org.trie4j.bv.BytesRank1OnlySuccinctBitVector in project trie4j by takawitter.

the class MapDoubleArrayTest method investigate2.

public void investigate2() throws Exception {
    String[] words = { "!SHOUT!", "!_-attention-", "!wagero!", "![ai-ou]", "\"74ers\"_LIVE_IN_OSAKA-JO_HALL_2003" };
    Integer[] values = { 1, 3, 2, 6, 100 };
    MapDoubleArray<Integer> trie = (MapDoubleArray<Integer>) trieWithWordsAndValues(words, values);
    DoubleArray da = (DoubleArray) trie.getTrie();
    int n = words.length;
    BytesRank1OnlySuccinctBitVector bv = (BytesRank1OnlySuccinctBitVector) da.getTerm();
    System.out.println(bv.rank1(67));
    for (int i = 0; i < n; i++) {
        String s = words[i];
        System.out.println(String.format("%s, nid: %d, tid: %d, ev: %d, av: %d", s, da.getNodeId(s), da.getTermId(s), values[i], trie.get(s)));
        Assert.assertEquals(values[i], trie.get(words[i]));
    }
}
Also used : BytesRank1OnlySuccinctBitVector(org.trie4j.bv.BytesRank1OnlySuccinctBitVector)

Example 2 with BytesRank1OnlySuccinctBitVector

use of org.trie4j.bv.BytesRank1OnlySuccinctBitVector in project trie4j by takawitter.

the class MapTailLOUDSTrieWithConcatTailArrayTest method investigate2.

public void investigate2() throws Exception {
    String[] words = { "!SHOUT!", "!_-attention-", "!wagero!", "![ai-ou]", "\"74ers\"_LIVE_IN_OSAKA-JO_HALL_2003" };
    Integer[] values = { 1, 3, 2, 6, 100 };
    MapTailLOUDSTrie<Integer> trie = trieWithWordsAndValues(words, values);
    DoubleArray da = (DoubleArray) trie.getTrie();
    int n = words.length;
    BytesRank1OnlySuccinctBitVector bv = (BytesRank1OnlySuccinctBitVector) da.getTerm();
    System.out.println(bv.rank1(67));
    for (int i = 0; i < n; i++) {
        String s = words[i];
        System.out.println(String.format("%s, nid: %d, tid: %d, ev: %d, av: %d", s, da.getNodeId(s), da.getTermId(s), values[i], trie.get(s)));
        Assert.assertEquals(values[i], trie.get(words[i]));
    }
}
Also used : BytesRank1OnlySuccinctBitVector(org.trie4j.bv.BytesRank1OnlySuccinctBitVector) DoubleArray(org.trie4j.doublearray.DoubleArray)

Example 3 with BytesRank1OnlySuccinctBitVector

use of org.trie4j.bv.BytesRank1OnlySuccinctBitVector in project trie4j by takawitter.

the class MapTailLOUDSTrieWithSBVConcatTailArrayTest method investigate2.

public void investigate2() throws Exception {
    String[] words = { "!SHOUT!", "!_-attention-", "!wagero!", "![ai-ou]", "\"74ers\"_LIVE_IN_OSAKA-JO_HALL_2003" };
    Integer[] values = { 1, 3, 2, 6, 100 };
    MapTailLOUDSTrie<Integer> trie = (MapTailLOUDSTrie<Integer>) trieWithWordsAndValues(words, values);
    DoubleArray da = (DoubleArray) trie.getTrie();
    int n = words.length;
    BytesRank1OnlySuccinctBitVector bv = (BytesRank1OnlySuccinctBitVector) da.getTerm();
    System.out.println(bv.rank1(67));
    for (int i = 0; i < n; i++) {
        String s = words[i];
        System.out.println(String.format("%s, nid: %d, tid: %d, ev: %d, av: %d", s, da.getNodeId(s), da.getTermId(s), values[i], trie.get(s)));
        Assert.assertEquals(values[i], trie.get(words[i]));
    }
}
Also used : BytesRank1OnlySuccinctBitVector(org.trie4j.bv.BytesRank1OnlySuccinctBitVector) DoubleArray(org.trie4j.doublearray.DoubleArray)

Example 4 with BytesRank1OnlySuccinctBitVector

use of org.trie4j.bv.BytesRank1OnlySuccinctBitVector in project trie4j by takawitter.

the class MapTailLOUDSTrieWithSuffixTrieTailArrayTest method investigate2.

public void investigate2() throws Exception {
    String[] words = { "!SHOUT!", "!_-attention-", "!wagero!", "![ai-ou]", "\"74ers\"_LIVE_IN_OSAKA-JO_HALL_2003" };
    Integer[] values = { 1, 3, 2, 6, 100 };
    MapTailLOUDSTrie<Integer> trie = (MapTailLOUDSTrie<Integer>) trieWithWordsAndValues(words, values);
    DoubleArray da = (DoubleArray) trie.getTrie();
    int n = words.length;
    BytesRank1OnlySuccinctBitVector bv = (BytesRank1OnlySuccinctBitVector) da.getTerm();
    System.out.println(bv.rank1(67));
    for (int i = 0; i < n; i++) {
        String s = words[i];
        System.out.println(String.format("%s, nid: %d, tid: %d, ev: %d, av: %d", s, da.getNodeId(s), da.getTermId(s), values[i], trie.get(s)));
        Assert.assertEquals(values[i], trie.get(words[i]));
    }
}
Also used : BytesRank1OnlySuccinctBitVector(org.trie4j.bv.BytesRank1OnlySuccinctBitVector) DoubleArray(org.trie4j.doublearray.DoubleArray)

Example 5 with BytesRank1OnlySuccinctBitVector

use of org.trie4j.bv.BytesRank1OnlySuccinctBitVector in project trie4j by takawitter.

the class TrieWriter method writeSuccinctBitVector.

public void writeSuccinctBitVector(SuccinctBitVector sbv) throws IOException {
    if (sbv instanceof BytesSuccinctBitVector) {
        dos.writeShort(TYPE_SBV_BYTES);
        writeBytesSuccinctBitVector((BytesSuccinctBitVector) sbv);
    } else if (sbv instanceof BytesRank0OnlySuccinctBitVector) {
        dos.writeShort(TYPE_SBV_RANK0ONLY);
        writeRank0OnlySuccinctBitVector((BytesRank0OnlySuccinctBitVector) sbv);
    } else if (sbv instanceof BytesRank1OnlySuccinctBitVector) {
        dos.writeShort(TYPE_SBV_RANK1ONLY);
        writeRank1OnlySuccinctBitVector((BytesRank1OnlySuccinctBitVector) sbv);
    } else if (sbv instanceof BytesRank1OnlySuccinctBitVector) {
        dos.writeShort(TYPE_SBV_LONGS);
        writeLongsSuccinctBitVector((LongsSuccinctBitVector) sbv);
    } else {
        throw new IOException("unknown sbv: " + sbv.getClass().getName());
    }
}
Also used : BytesRank0OnlySuccinctBitVector(org.trie4j.bv.BytesRank0OnlySuccinctBitVector) BytesSuccinctBitVector(org.trie4j.bv.BytesSuccinctBitVector) BytesRank1OnlySuccinctBitVector(org.trie4j.bv.BytesRank1OnlySuccinctBitVector) IOException(java.io.IOException) LongsSuccinctBitVector(org.trie4j.bv.LongsSuccinctBitVector)

Aggregations

BytesRank1OnlySuccinctBitVector (org.trie4j.bv.BytesRank1OnlySuccinctBitVector)5 DoubleArray (org.trie4j.doublearray.DoubleArray)3 IOException (java.io.IOException)1 BytesRank0OnlySuccinctBitVector (org.trie4j.bv.BytesRank0OnlySuccinctBitVector)1 BytesSuccinctBitVector (org.trie4j.bv.BytesSuccinctBitVector)1 LongsSuccinctBitVector (org.trie4j.bv.LongsSuccinctBitVector)1