on master help sign in
fix matrixRelation

move bigrel to benchmark directory

commitd8264fa9e035c6d895f217d4e547eb57176eb407 authorAgentM <agentm@themactionfaction.com> dateSun 3 May 2015, 10:39 (11 years ago) parent03c23d9
6 files changed+24−8
ProjectM36/Relation.hs+1−1 ProjectM36/Tuple.hs+8−3 ProjectM36/TupleSet.hs+1−1 ProjectM36/bigrel ProjectM36/bigrel.hs → benchmark/bigrel.hs+3−2 project-m36.cabal+11−1
ProjectM36/Relation.hs+1−1
@@ -259,7 +259,7 @@ imageRelationJoin rel1@(Relation attrNameSet1 tupSet1) rel2@(Relation attrNameSe
259259-- this is useful for performance and resource usage testing
260260matrixRelation :: Int -> Int -> Either RelationalError Relation
261261matrixRelation 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]
263263 tuple tupleX = RelationTuple attrs (V.generate attributeCount (\_ -> IntAtom tupleX))
264264 tupleSet <- mkTupleSet attrs $ map (\c -> tuple c) [0 .. tupleCount]
265265 mkRelation attrs tupleSet
ProjectM36/Tuple.hs+8−3
@@ -145,8 +145,12 @@ tupleToMap (RelationTuple attrs tupVec) = M.fromList assocList
145145 where
146146 assocList = V.toList $ V.map (\(index, attr) -> (attributeName attr, tupVec V.! index)) (V.indexed attrs)
147147
148−verifyTuple :: RelationTuple -> Either RelationalError RelationTuple
149−verifyTuple tuple = V.foldr (\attr acc ->
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+
153+ V.foldr (\attr acc ->
150154 case atomForAttributeName (attributeName attr) tuple of
151155 Left err -> Left err
152156 Right atom -> case atomTypeForAttributeName (attributeName attr) (tupleAttributes tuple) of
@@ -156,6 +160,7 @@ verifyTuple tuple = V.foldr (\attr acc ->
156160 acc
157161 else
158162 Left $ TupleAttributeTypeMismatchError (attributesFromList [attr])
159− ) (Right tuple) (tupleAttributes tuple)
163+ ) (Right tuple) attrs
164+
160165
161166
ProjectM36/TupleSet.hs+1−1
@@ -17,7 +17,7 @@ singletonTupleSet = HS.singleton emptyTuple
1717verifyTupleSet :: Attributes -> RelationTupleSet -> Either RelationalError RelationTupleSet
1818verifyTupleSet attrs tupleSet = do
1919 --check that all tuples have the same types
20− tupleList <- forM (HS.toList tupleSet) verifyTuple
20+ tupleList <- forM (HS.toList tupleSet) (verifyTuple attrs)
2121 return $ HS.fromList tupleList
2222
2323mkTupleSet :: 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
1515dumpcsv :: Relation -> IO ()
1616dumpcsv = BS.putStrLn . relationAsCSV
1717
18−main = vectorMatrixRun
18+main = matrixRun
19+ --vectorMatrixRun
1920 --intmapMatrixRun
2021
2122-- takes 30 minutes to run and 1.1 GB
2223matrixRun = do
2324 case matrixRelation 100 100000 of
2425 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
2627 Left err -> putStrLn (show err)
2728 Right rel -> dumpcsv rel
2829
project-m36.cabal+11−1
@@ -21,7 +21,7 @@ Library
2121 ProjectM36.StaticOptimizer,
2222 ProjectM36.Relation.Show.Term,
2323 ProjectM36.Relation.Show.CSV
24− GHC-Options: -Wall
24+ GHC-Options: -Wall -rtsopts
2525
2626Executable tutd
2727 Build-Depends: base
@@ -32,6 +32,16 @@ Executable tutd
3232 main-is: TutorialD/tutd.hs
3333 GHC-Options: -Wall
3434
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+
3545Test-Suite test-tutoriald
3646 type: exitcode-stdio-1.0
3747 main-is: test/TutorialD/Interpreter.hs