开发者

How to store list of list of int [[Int]] in Data.Array.Repa, to enable parallel operations?

开发者 https://www.devze.com 2023-02-20 16:48 出处:网络
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, spliti

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 parall开发者_高级运维el using Haskell

Thanks for anyone's reply


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消