java如何访问ApachePatriciaTrieEntry密钥?
在我的应用程序中,我有大约50Mb的字符串,其中有很多公共部分。 我想通过使用基数Trie(Patricia Tree)来减少内存消耗,例如apachecollections impl
目标是保留对条目的引用,并在需要时获取完整字符串:
val trie = PatriciaTrie()
val node1 = trie.put("Long string #1", null) // what's the method to add and return TrieEntry?
someObject1.setNode(node1)
val node2 = trie.put("Long string #2", null)
someObject2.setNode(node2)
val node3 = trie.put("Long string #3", null)
someObject3.setNode(node3)
因此,我希望它存储在内存中,如下所示:
root
\
"Long string #"
\"1"
\"2"
\"3"
需要时,我应该能够获取完整字符串(在someObjectN中):
val fullString = node.getKey(); // How can i do it?
有两个问题:
如何将字符串放入trie并获取
TrieEntry
实例?由于它实现了java.util.map
,put
method返回值:public V put(final K key, final V value)
如何从
TrieEntry
实例获取完整字符串
值(节点负载)在我的用例中是无用的,因为主要目标只是节省内存(没有任何负载)
Apache's PatriciaTrie是否适合该用例? 有什么想法吗
共 (0) 个答案