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]));
}
}
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]));
}
}
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]));
}
}
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]));
}
}
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());
}
}
Aggregations