如何在 Data.Array.Repa 中存储 int [[Int]] 列表的列表,以启用并行操作?
我正在研究表示交易数据库的方法,该数据库可以被视为列表元素的列表,这些列表上的未来操作将意味着:投影、减少、获取最大值、分割、减少一些元素等等。 我看过以前
type Item = int
transaction :: [Item]
database :: [transaction]
for example [[1,2,3], [2,3,4]]
的作品,使用 trie 来表示这样的数据结构,
data LexicoTreeItem = Nil | Node item LexicoTreeItem LexicoTreeItem int
-- lexicoTreeItem item next alt weigth
-- item is the item of the node
-- next is the rest of the transaction, each path of the trie is a transaction
-- alt is another transaction starting with the item
-- weigth is the number of transactions which use this item
例如表示 [[1,2,3],[1,2,3,4]] ,
1 - 2 - 3
|
3 - 4
人们会
Node 1 (Node 2 (Node 3 Nil Nil 1) (Node 3 (Node 4 Nil Nil 1) Nil 1 ) 2 ) Nil 2
写问题是这种数据结构在处理 Haskell 中的并行性时效率不高。 我了解到,Data.Array.Repa
比 Data.Array
和 Node
更有效地处理并行性。
但我不知道如何表示上面的数据库。以能够执行诸如投影、缩减、列表、最大值、抑制等操作的方式,但是...使用 Haskell 并行
感谢任何人的回复
I'm working on the way to represent a database of transaction which can be view as a list of list elements, future operations on those lists will imply: projection, reduction, get the maximum, spliting, reduce some elements and so on ...
type Item = int
transaction :: [Item]
database :: [transaction]
for example [[1,2,3], [2,3,4]]
i've seen previous works which used trie to represent such a data structures
data LexicoTreeItem = Nil | Node item LexicoTreeItem LexicoTreeItem int
-- lexicoTreeItem item next alt weigth
-- item is the item of the node
-- next is the rest of the transaction, each path of the trie is a transaction
-- alt is another transaction starting with the item
-- weigth is the number of transactions which use this item
for example to represent [[1,2,3],[1,2,3,4]]
1 - 2 - 3
|
3 - 4
one will write
Node 1 (Node 2 (Node 3 Nil Nil 1) (Node 3 (Node 4 Nil Nil 1) Nil 1 ) 2 ) Nil 2
The problem is that this data structure is not efficient when dealing with parallelism in haskell.
I've learn that Data.Array.Repa
handled the parallelism more efficiently than Data.Array
and Node
.
But I don't know how to represent the above database. In the way to be able to do operation such as : projection, reduction, listting, maximum, suppression an more but ... in parallel using Haskell
Thanks for anyone's reply
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Data.Array.Repa 可以处理二维数组,但它们必须是矩形的。 [[Int]] 形式不强制使用矩形形状。如果它是矩形,那么您可以使用 Data.Array.Reap.fromList 将扁平的 [Int] 转换为数组。
Data.Array.Repa can handle 2-D arrays, but they must be rectangular. The [[Int]] form does not enforce a rectangular shape. If it is rectangular then you can use Data.Array.Reap.fromList to convert from a flattened [Int] to the Array.