on master help sign in
fix matrixRelation
d8264faAgentM
ProjectM36/Relation.hs+1−1
@@ -259,7 +259,7 @@ imageRelationJoin rel1@(Relation attrNameSet1 tupSet1) rel2@(Relation attrNameSe
259-- this is useful for performance and resource usage testing
259-- this is useful for performance and resource usage testing
260matrixRelation :: Int -> Int -> Either RelationalError Relation
260matrixRelation :: Int -> Int -> Either RelationalError Relation
261matrixRelation attributeCount tupleCount = do
261matrixRelation attributeCount tupleCount = do
262− let attrs = A.attributesFromList $ map (\c-> Attribute (show c) IntAtomType) [0 .. attributeCount]
262+ let attrs = A.attributesFromList $ map (\c-> Attribute (show c) IntAtomType) [0 .. attributeCount-1]
263 tuple tupleX = RelationTuple attrs (V.generate attributeCount (\_ -> IntAtom tupleX))
263 tuple tupleX = RelationTuple attrs (V.generate attributeCount (\_ -> IntAtom tupleX))
264 tupleSet <- mkTupleSet attrs $ map (\c -> tuple c) [0 .. tupleCount]
264 tupleSet <- mkTupleSet attrs $ map (\c -> tuple c) [0 .. tupleCount]
265 mkRelation attrs tupleSet
265 mkRelation attrs tupleSet
ProjectM36/Tuple.hs+8−3
@@ -145,8 +145,12 @@ tupleToMap (RelationTuple attrs tupVec) = M.fromList assocList
145 where
145 where
146 assocList = V.toList $ V.map (\(index, attr) -> (attributeName attr, tupVec V.! index)) (V.indexed attrs)
146 assocList = V.toList $ V.map (\(index, attr) -> (attributeName attr, tupVec V.! index)) (V.indexed attrs)
147
147
148−verifyTuple :: RelationTuple -> Either RelationalError RelationTuple
148+verifyTuple :: Attributes -> RelationTuple -> Either RelationalError RelationTuple
149+verifyTuple attrs tuple = if V.length attrs /= V.length (tupleAtoms tuple) then
150+ Left $ TupleAttributeCountMismatchError 0
151+ else
152+
149−verifyTuple tuple = V.foldr (\attr acc ->
153+ V.foldr (\attr acc ->
150 case atomForAttributeName (attributeName attr) tuple of
154 case atomForAttributeName (attributeName attr) tuple of
151 Left err -> Left err
155 Left err -> Left err
152 Right atom -> case atomTypeForAttributeName (attributeName attr) (tupleAttributes tuple) of
156 Right atom -> case atomTypeForAttributeName (attributeName attr) (tupleAttributes tuple) of
@@ -156,6 +160,7 @@ verifyTuple tuple = V.foldr (\attr acc ->
156 acc
160 acc
157 else
161 else
158 Left $ TupleAttributeTypeMismatchError (attributesFromList [attr])
162 Left $ TupleAttributeTypeMismatchError (attributesFromList [attr])
159− ) (Right tuple) (tupleAttributes tuple)
163+ ) (Right tuple) attrs
164+
160
165
161
166
ProjectM36/TupleSet.hs+1−1
@@ -17,7 +17,7 @@ singletonTupleSet = HS.singleton emptyTuple
17verifyTupleSet :: Attributes -> RelationTupleSet -> Either RelationalError RelationTupleSet
17verifyTupleSet :: Attributes -> RelationTupleSet -> Either RelationalError RelationTupleSet
18verifyTupleSet attrs tupleSet = do
18verifyTupleSet attrs tupleSet = do
19 --check that all tuples have the same types
19 --check that all tuples have the same types
20− tupleList <- forM (HS.toList tupleSet) verifyTuple
20+ tupleList <- forM (HS.toList tupleSet) (verifyTuple attrs)
21 return $ HS.fromList tupleList
21 return $ HS.fromList tupleList
22
22
23mkTupleSet :: Attributes -> [RelationTuple] -> Either RelationalError RelationTupleSet
23mkTupleSet :: Attributes -> [RelationTuple] -> Either RelationalError RelationTupleSet
ProjectM36/bigrelnew file

Binary file not shown.

ProjectM36/bigrel.hs → benchmark/bigrel.hsrenamed+3−2
@@ -15,14 +15,15 @@ import Control.DeepSeq
15dumpcsv :: Relation -> IO ()
15dumpcsv :: Relation -> IO ()
16dumpcsv = BS.putStrLn . relationAsCSV
16dumpcsv = BS.putStrLn . relationAsCSV
17
17
18+main = matrixRun
18−main = vectorMatrixRun
19+ --vectorMatrixRun
19 --intmapMatrixRun
20 --intmapMatrixRun
20
21
21-- takes 30 minutes to run and 1.1 GB
22-- takes 30 minutes to run and 1.1 GB
22matrixRun = do
23matrixRun = do
23 case matrixRelation 100 100000 of
24 case matrixRelation 100 100000 of
24 Left err -> putStrLn (show err)
25 Left err -> putStrLn (show err)
25− Right rel -> case restrict (\(RelationTuple tupMap) -> tupMap M.! "0" == IntAtom 5) rel of
26+ Right rel -> case restrict (\tuple -> atomForAttributeName "0" tuple == Right (IntAtom 5)) rel of
26 Left err -> putStrLn (show err)
27 Left err -> putStrLn (show err)
27 Right rel -> dumpcsv rel
28 Right rel -> dumpcsv rel
28
29
project-m36.cabal+11−1
@@ -21,7 +21,7 @@ Library
21 ProjectM36.StaticOptimizer,
21 ProjectM36.StaticOptimizer,
22 ProjectM36.Relation.Show.Term,
22 ProjectM36.Relation.Show.Term,
23 ProjectM36.Relation.Show.CSV
23 ProjectM36.Relation.Show.CSV
24− GHC-Options: -Wall
24+ GHC-Options: -Wall -rtsopts
25
25
26Executable tutd
26Executable tutd
27 Build-Depends: base
27 Build-Depends: base
@@ -32,6 +32,16 @@ Executable tutd
32 main-is: TutorialD/tutd.hs
32 main-is: TutorialD/tutd.hs
33 GHC-Options: -Wall
33 GHC-Options: -Wall
34
34
35+Executable bigrel
36+ Build-Depends: base,deepseq
37+ Other-Modules: ProjectM36.Base,
38+ ProjectM36.Relation
39+ ProjectM36.Tuple,
40+ ProjectM36.Error,
41+ ProjectM36.Relation.Show.CSV
42+ main-is: benchmark/bigrel.hs
43+ GHC-Options: -Wall
44+
35Test-Suite test-tutoriald
45Test-Suite test-tutoriald
36 type: exitcode-stdio-1.0
46 type: exitcode-stdio-1.0
37 main-is: test/TutorialD/Interpreter.hs
47 main-is: test/TutorialD/Interpreter.hs