1module ProjectM36.TupleSet where
5import qualified Data.HashSet as HS
6import qualified Data.Vector as V
7import qualified Control.Parallel.Strategies as P
10emptyTupleSet :: RelationTupleSet
11emptyTupleSet = RelationTupleSet []
13singletonTupleSet :: RelationTupleSet
14singletonTupleSet = RelationTupleSet [emptyTuple]
16--ensure that all maps have the same keys and key count
18verifyTupleSet :: Attributes -> RelationTupleSet -> Either RelationalError RelationTupleSet
19verifyTupleSet attrs tupleSet = do
20 --check that all tuples have the same attributes and that the atom types match
21 let tupleList = map (verifyTuple attrs) (asList tupleSet) `P.using` P.parListChunk chunkSize P.r0
22 chunkSize = (length . asList) tupleSet `div` 24
23 --let tupleList = P.parMap P.rdeepseq (verifyTuple attrs) (HS.toList tupleSet)
24 if not (null (lefts tupleList)) then
25 Left $ head (lefts tupleList)
27 return $ RelationTupleSet $ (HS.toList . HS.fromList) (rights tupleList)
29mkTupleSet :: Attributes -> [RelationTuple] -> Either RelationalError RelationTupleSet
30mkTupleSet attrs tuples = verifyTupleSet attrs (RelationTupleSet tuples)
32mkTupleSetFromList :: Attributes -> [[Atom]] -> Either RelationalError RelationTupleSet
33mkTupleSetFromList attrs atomMatrix = mkTupleSet attrs $ map (mkRelationTuple attrs . V.fromList) atomMatrix
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list