private void initMaxId() { if (trees.isEmpty()) { this.maxId = baseId - 1; return; } int index = trees.size() - 1; this.maxId = accuOffset.get(index) + trees.get(index).getMaxId() + baseId; }
private void initSizeOfId() { if (trees.isEmpty()) { this.sizeOfId = 1; return; } int maxOffset = accuOffset.get(accuOffset.size() - 1); TrieDictionary<T> lastTree = trees.get(trees.size() - 1); this.sizeOfId = BytesUtil.sizeForValue(baseId + maxOffset + lastTree.getMaxId() + 1L); }
private void initMaxValueForEachTrie() { //init max value this.maxValue = new ArrayList<>(); if (this.trees == null || trees.isEmpty()) { return; } for (int i = 0; i < trees.size(); i++) { T curTreeMax = trees.get(i).getValueFromId(trees.get(i).getMaxId()); byte[] b1 = bytesConvert.convertToBytes(curTreeMax); ByteArray ba1 = new ByteArray(b1, 0, b1.length); this.maxValue.add(ba1); } }
private void addTree(TrieDictionary<T> tree) { trees.add(tree); int minId = tree.getMinId(); accuOffset.add(curOffset); byte[] valueBytes = tree.getValueBytesFromIdWithoutCache(minId); valueDivide.add(new ByteArray(valueBytes, 0, valueBytes.length)); curOffset += (tree.getMaxId() + 1); checkDictSize(); }
for (int i = 0; i <= dict.getMaxId(); i++) { System.out.println(Bytes.toString(dict.getValueBytesFromIdWithoutCache(i)));
private void assertSameBehaviorAsTrie(TrieDictionaryForest<String> dict, ArrayList<String> strs, int baseId) { TrieDictionaryBuilder<String> trieBuilder = new TrieDictionaryBuilder<>(new StringBytesConverter()); for (String s : strs) { if (s != null) trieBuilder.addValue(s); } TrieDictionary<String> trie = trieBuilder.build(baseId); assertEquals(trie.getMaxId(), dict.getMaxId()); assertEquals(trie.getMinId(), dict.getMinId()); assertEquals(trie.getSize(), dict.getSize()); assertEquals(trie.getSizeOfId(), dict.getSizeOfId()); assertEquals(trie.getSizeOfValue(), dict.getSizeOfValue()); }
private void initMaxId() { if (trees.isEmpty()) { this.maxId = baseId - 1; return; } int index = trees.size() - 1; this.maxId = accuOffset.get(index) + trees.get(index).getMaxId() + baseId; }
private void initSizeOfId() { if (trees.isEmpty()) { this.sizeOfId = 1; return; } int maxOffset = accuOffset.get(accuOffset.size() - 1); TrieDictionary<T> lastTree = trees.get(trees.size() - 1); this.sizeOfId = BytesUtil.sizeForValue(baseId + maxOffset + lastTree.getMaxId() + 1L); }
private void initMaxValueForEachTrie() { //init max value this.maxValue = new ArrayList<>(); if (this.trees == null || trees.isEmpty()) { return; } for (int i = 0; i < trees.size(); i++) { T curTreeMax = trees.get(i).getValueFromId(trees.get(i).getMaxId()); byte[] b1 = bytesConvert.convertToBytes(curTreeMax); ByteArray ba1 = new ByteArray(b1, 0, b1.length); this.maxValue.add(ba1); } }
private void addTree(TrieDictionary<T> tree) { trees.add(tree); int minId = tree.getMinId(); accuOffset.add(curOffset); byte[] valueBytes = tree.getValueBytesFromIdWithoutCache(minId); valueDivide.add(new ByteArray(valueBytes, 0, valueBytes.length)); curOffset += (tree.getMaxId() + 1); checkDictSize(); }
for (int i = 0; i <= dict.getMaxId(); i++) { System.out.println(Bytes.toString(dict.getValueBytesFromIdWithoutCache(i)));