Search in sources :

Example 1 with SuffixTrieDenseTailArrayBuilder

use of org.trie4j.tail.SuffixTrieDenseTailArrayBuilder in project trie4j by takawitter.

the class TrieWriterTest method test.

@Test
public void test() throws Exception {
    LapTimer lt = new LapTimer();
    PatriciaTrie origTrie = new PatriciaTrie();
    new WikipediaTitles().insertTo(origTrie);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    TrieWriter tw = new TrieWriter(baos);
    Trie trie = new TailLOUDSTrie(origTrie, new LOUDSPPBvTree(origTrie.nodeSize()), new SuffixTrieDenseTailArrayBuilder());
    lt.reset();
    tw.write(trie);
    tw.flush();
    lt.lapMillis("trie saved.");
    System.out.println(baos.size() + " bytes");
    TrieReader tr = new TrieReader(new ByteArrayInputStream(baos.toByteArray()));
    lt.reset();
    Trie trie2 = tr.read();
    lt.lapMillis("trie loaded.");
    long d = new WikipediaTitles().assertAllContains(trie2);
    System.out.println("[" + d + "ms]: verified");
}
Also used : TailLOUDSTrie(org.trie4j.louds.TailLOUDSTrie) LOUDSPPBvTree(org.trie4j.louds.bvtree.LOUDSPPBvTree) ByteArrayInputStream(java.io.ByteArrayInputStream) PatriciaTrie(org.trie4j.patricia.PatriciaTrie) SuffixTrieDenseTailArrayBuilder(org.trie4j.tail.SuffixTrieDenseTailArrayBuilder) WikipediaTitles(org.trie4j.test.WikipediaTitles) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Trie(org.trie4j.Trie) PatriciaTrie(org.trie4j.patricia.PatriciaTrie) TailLOUDSTrie(org.trie4j.louds.TailLOUDSTrie) LapTimer(org.trie4j.test.LapTimer) Test(org.junit.Test)

Example 2 with SuffixTrieDenseTailArrayBuilder

use of org.trie4j.tail.SuffixTrieDenseTailArrayBuilder in project trie4j by takawitter.

the class BytesConstantTimeSelect0TailLOUDSPPTrieWithSuffixTrieDenseTailArrayWikipediaSerializeTest method secondTrie.

@Override
protected Trie secondTrie(Trie firstTrie) {
    Trie t = new TailLOUDSTrie(firstTrie, new LOUDSPPBvTree(new BytesRank0OnlySuccinctBitVector(), new BytesConstantTimeSelect0SuccinctBitVector()), new SuffixTrieDenseTailArrayBuilder());
    t.trimToSize();
    return t;
}
Also used : LOUDSPPBvTree(org.trie4j.louds.bvtree.LOUDSPPBvTree) BytesRank0OnlySuccinctBitVector(org.trie4j.bv.BytesRank0OnlySuccinctBitVector) SuffixTrieDenseTailArrayBuilder(org.trie4j.tail.SuffixTrieDenseTailArrayBuilder) BytesConstantTimeSelect0SuccinctBitVector(org.trie4j.bv.BytesConstantTimeSelect0SuccinctBitVector) Trie(org.trie4j.Trie)

Example 3 with SuffixTrieDenseTailArrayBuilder

use of org.trie4j.tail.SuffixTrieDenseTailArrayBuilder in project trie4j by takawitter.

the class LongsConstantTimeSelect0TailLOUDSPPTrieWithSuffixTrieDenseTailArrayWikipediaSerializeTest method secondTrie.

@Override
protected Trie secondTrie(Trie firstTrie) {
    Trie t = new TailLOUDSTrie(firstTrie, new LOUDSPPBvTree(new LongsRank0OnlySuccinctBitVector(), new LongsConstantTimeSelect0SuccinctBitVector()), new SuffixTrieDenseTailArrayBuilder());
    t.trimToSize();
    return t;
}
Also used : LOUDSPPBvTree(org.trie4j.louds.bvtree.LOUDSPPBvTree) SuffixTrieDenseTailArrayBuilder(org.trie4j.tail.SuffixTrieDenseTailArrayBuilder) Trie(org.trie4j.Trie) LongsConstantTimeSelect0SuccinctBitVector(org.trie4j.bv.LongsConstantTimeSelect0SuccinctBitVector) LongsRank0OnlySuccinctBitVector(org.trie4j.bv.LongsRank0OnlySuccinctBitVector)

Example 4 with SuffixTrieDenseTailArrayBuilder

use of org.trie4j.tail.SuffixTrieDenseTailArrayBuilder in project trie4j by takawitter.

the class LongsTailLOUDSPPTrieWithSuffixTrieDenseTailArrayWikipediaSerializeTest method secondTrie.

@Override
protected Trie secondTrie(Trie firstTrie) {
    Trie t = new TailLOUDSTrie(firstTrie, new LOUDSPPBvTree(new LongsRank0OnlySuccinctBitVector(), new LongsSuccinctBitVector()), new SuffixTrieDenseTailArrayBuilder());
    t.trimToSize();
    return t;
}
Also used : LOUDSPPBvTree(org.trie4j.louds.bvtree.LOUDSPPBvTree) SuffixTrieDenseTailArrayBuilder(org.trie4j.tail.SuffixTrieDenseTailArrayBuilder) Trie(org.trie4j.Trie) LongsRank0OnlySuccinctBitVector(org.trie4j.bv.LongsRank0OnlySuccinctBitVector) LongsSuccinctBitVector(org.trie4j.bv.LongsSuccinctBitVector)

Aggregations

Trie (org.trie4j.Trie)4 LOUDSPPBvTree (org.trie4j.louds.bvtree.LOUDSPPBvTree)4 SuffixTrieDenseTailArrayBuilder (org.trie4j.tail.SuffixTrieDenseTailArrayBuilder)4 LongsRank0OnlySuccinctBitVector (org.trie4j.bv.LongsRank0OnlySuccinctBitVector)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Test (org.junit.Test)1 BytesConstantTimeSelect0SuccinctBitVector (org.trie4j.bv.BytesConstantTimeSelect0SuccinctBitVector)1 BytesRank0OnlySuccinctBitVector (org.trie4j.bv.BytesRank0OnlySuccinctBitVector)1 LongsConstantTimeSelect0SuccinctBitVector (org.trie4j.bv.LongsConstantTimeSelect0SuccinctBitVector)1 LongsSuccinctBitVector (org.trie4j.bv.LongsSuccinctBitVector)1 TailLOUDSTrie (org.trie4j.louds.TailLOUDSTrie)1 PatriciaTrie (org.trie4j.patricia.PatriciaTrie)1 LapTimer (org.trie4j.test.LapTimer)1 WikipediaTitles (org.trie4j.test.WikipediaTitles)1