高性能并发MultiMap

高性能并发MultiMap

本文介绍了高性能并发MultiMap Java / Scala的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个高性能,并发,MultiMap。我已经在所有地方搜索,但我根本找不到一个解决方案,使用与ConcurrentHashMap相同的方法(只锁定一个段的哈希数组)。

I am looking for a high-performance, concurrent, MultiMap. I have searched everywhere but I simply cannot find a solution that uses the same approach as ConcurrentHashMap (Only locking a segment of the hash array).

多图将被读取

多重映射键将是一个字符串,其值将是任意的。

The multimap key will be a String and it's value will be arbitrary.

我需要O(1)找到给定键的所有值,O(N)可以删除,但O(logN)将是首选。

I need O(1) to find all values for a given key, O(N) is OK for removal, but O(logN) would be preferred.

至关重要的是,删除给定键的最后一个值将从键中删除值的容器,以避免泄漏内存。

It is crucial that removal of the last value for a given key will remove the container of values from the key, as to not leak memory.

这里的解决方案我建立,在ApacheV2下可用:

HERE'S THE SOLUTION I BUILT, availbable under ApacheV2:Index (multimap)

推荐答案

为什么不打包ConcurrentHashMap [T,ConcurrentLinkedQueue [ U]]与一些漂亮的Scala类方法(例如隐式转换为Iterable或任何你需要的,和一个更新方法)?

Why not wrap ConcurrentHashMap[T,ConcurrentLinkedQueue[U]] with some nice Scala-like methods (e.g. implicit conversion to Iterable or whatever it is that you need, and an update method)?

这篇关于高性能并发MultiMap Java / Scala的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 18:12