@Override public void dump(PrintStream out) { out.println("TrieDictionaryForest"); out.println("baseId:" + baseId); StringBuilder sb = new StringBuilder(); sb.append("value divide:"); for (ByteArray ba : valueDivide) sb.append(bytesConvert.convertFromBytes(ba.array(), 0, ba.length()) + " "); sb.append("\noffset divide:"); for (Integer offset : accuOffset) sb.append(offset + " "); out.println(sb.toString()); for (int i = 0; i < trees.size(); i++) { out.println("----tree " + i + "--------"); trees.get(i).dump(out); } }
@Test public void testSuperLongStringValue() { String longPrefix = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" + "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; TrieDictionaryBuilder<String> b = new TrieDictionaryBuilder<String>(new StringBytesConverter()); String v1 = longPrefix + "xyz"; b.addValue(v1); String strLen200 = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghid"; b.addValue(strLen200); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 25; i++) { sb.append(strLen200); } String strLen5000 = sb.toString(); b.addValue(strLen5000); TrieDictionary<String> dict = b.build(0); dict.dump(System.out); sb.setLength(0); for (int j = 0; j < 7; j++) { sb.append(strLen5000); } String strLen35000 = sb.toString(); b.addValue(strLen35000); Exception ex = null; try { b.build(0); } catch (Exception e) { ex = e; } Assert.assertNotNull(ex); }
private DictionaryInfo makeSharedDict() throws IOException { TableSignature signature = new TableSignature(); signature.setSize(100); signature.setLastModifiedTime(System.currentTimeMillis()); signature.setPath("fake_common_dict"); DictionaryInfo newDictInfo = new DictionaryInfo("", "", 0, "string", signature, ""); List<byte[]> values = new ArrayList<byte[]>(); values.add(new byte[] { 101, 101, 101 }); values.add(new byte[] { 102, 102, 102 }); Dictionary<?> dict = DictionaryGenerator.buildDictionaryFromValueList(newDictInfo, values); dictionaryManager.trySaveNewDict(dict, newDictInfo); ((TrieDictionary) dict).dump(System.out); return newDictInfo; }
@Test public void testSuperLongStringValue() { String longPrefix = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" + "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; TrieDictionaryBuilder<String> b = new TrieDictionaryBuilder<String>(new StringBytesConverter()); String v1 = longPrefix + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; String v2 = longPrefix + "xyz"; b.addValue(v1); b.addValue(v2); TrieDictionary<String> dict = b.build(0); dict.dump(System.out); }
@Override public void dump(PrintStream out) { out.println("TrieDictionaryForest"); out.println("baseId:" + baseId); StringBuilder sb = new StringBuilder(); sb.append("value divide:"); for (ByteArray ba : valueDivide) sb.append(bytesConvert.convertFromBytes(ba.array(), 0, ba.length()) + " "); sb.append("\noffset divide:"); for (Integer offset : accuOffset) sb.append(offset + " "); out.println(sb.toString()); for (int i = 0; i < trees.size(); i++) { out.println("----tree " + i + "--------"); trees.get(i).dump(out); } }
Dictionary<?> dict = DictionaryGenerator.buildDictionaryFromValueList(newDictInfo, values); dictionaryManager.trySaveNewDict(dict, newDictInfo); ((TrieDictionary) dict).dump(System.out);
public static void main(String[] args) throws Exception { TrieDictionaryBuilder<String> b = new TrieDictionaryBuilder<String>(new StringBytesConverter()); b.addValue(""); b.print(); b.addValue("part"); b.print(); b.addValue("part"); b.print(); b.addValue("par"); b.print(); b.addValue("partition"); b.print(); b.addValue("party"); b.print(); b.addValue("parties"); b.print(); b.addValue("paint"); b.print(); TrieDictionary<String> dict = b.build(0); dict.dump(System.out); dict.getIdFromValueBytes(new byte[10], 0, 0); } }