on master help sign in
create NFData instances for base types for memory profiling
1964c90AgentM
ProjectM36/Base.hs+23−10
@@ -1,4 +1,4 @@
1−{-# LANGUAGE GADTs #-}
1+{-# LANGUAGE GADTs,DeriveGeneric #-}
2module ProjectM36.Base where
2module ProjectM36.Base where
3import qualified Data.Map as M
3import qualified Data.Map as M
4import qualified Data.HashSet as HS
4import qualified Data.HashSet as HS
@@ -6,17 +6,23 @@ import qualified Data.Hashable as Hash
6import qualified Data.Set as S
6import qualified Data.Set as S
7import Control.Monad.State hiding (join)
7import Control.Monad.State hiding (join)
8import Data.UUID (UUID)
8import Data.UUID (UUID)
9+import Control.DeepSeq (NFData, rnf)
10+import Control.DeepSeq.Generics (genericRnf)
11+import GHC.Generics (Generic)
9
12
10data Atom = StringAtom String |
13data Atom = StringAtom String |
11 IntAtom Int |
14 IntAtom Int |
12− RelationAtom Relation deriving (Show, Eq)
15+ RelationAtom Relation deriving (Show, Eq, Generic)
13−
16+
17+instance NFData Atom where rnf = genericRnf
14
18
15data AtomType = StringAtomType |
19data AtomType = StringAtomType |
16 IntAtomType |
20 IntAtomType |
17− RelationAtomType Attributes deriving (Eq, Show)
21+ RelationAtomType Attributes deriving (Eq, Show, Generic)
18
22
23+instance NFData AtomType where rnf = genericRnf
24+
19−atomTypeForAtom :: Atom -> AtomType
25+atomTypeForAtom :: Atom -> AtomType
20atomTypeForAtom (StringAtom _) = StringAtomType
26atomTypeForAtom (StringAtom _) = StringAtomType
21atomTypeForAtom (IntAtom _) = IntAtomType
27atomTypeForAtom (IntAtom _) = IntAtomType
22atomTypeForAtom (RelationAtom (Relation attributes _)) = RelationAtomType attributes
28atomTypeForAtom (RelationAtom (Relation attributes _)) = RelationAtomType attributes
@@ -24,7 +30,9 @@ atomTypeForAtom (RelationAtom (Relation attributes _)) = RelationAtomType attrib
24type AttributeName = String
30type AttributeName = String
25type AtomName = String
31type AtomName = String
26
32
27−data Attribute = Attribute AttributeName AtomType deriving (Eq, Show)
33+data Attribute = Attribute AttributeName AtomType deriving (Eq, Show, Generic)
34+
35+instance NFData Attribute where rnf = genericRnf
28
36
29type Attributes = M.Map AttributeName Attribute --attributes keys by attribute name for ease of access
37type Attributes = M.Map AttributeName Attribute --attributes keys by attribute name for ease of access
30
38
@@ -32,11 +40,16 @@ type RelationTupleSet = HS.HashSet RelationTuple
32
40
33instance Hash.Hashable RelationTuple where
41instance Hash.Hashable RelationTuple where
34 hashWithSalt salt tup = Hash.hashWithSalt salt (show tup)
42 hashWithSalt salt tup = Hash.hashWithSalt salt (show tup)
35−
43+
36−data RelationTuple = RelationTuple (M.Map AttributeName Atom) deriving (Eq, Show)
44+data RelationTuple = RelationTuple (M.Map AttributeName Atom) deriving (Eq, Show, Generic)
37
45
46+instance NFData RelationTuple where rnf = genericRnf
47+
38−data Relation = Relation Attributes RelationTupleSet deriving (Show, Eq)
48+data Relation = Relation Attributes RelationTupleSet deriving (Show, Eq, Generic)
49+
50+instance NFData Relation where rnf = genericRnf
51+
39−data RelationCardinality = Uncountable | Countable Int deriving (Eq, Show)
52+data RelationCardinality = Uncountable | Countable Int deriving (Eq, Show, Generic)
40data RelationSizeInfinite = RelationSizeInfinite
53data RelationSizeInfinite = RelationSizeInfinite
41
54
42data RelationalExpr where
55data RelationalExpr where
project-m36.cabal+1−1
@@ -7,7 +7,7 @@ Category: Relational Algebra
7Cabal-Version: >= 1.2
7Cabal-Version: >= 1.2
8
8
9Library
9Library
10− Build-Depends: base,mtl,containers,unordered-containers,parsec,hashable,haskeline,directory,uuid,cassava,text,bytestring
10+ Build-Depends: base,mtl,containers,unordered-containers,parsec,hashable,haskeline,directory,uuid,cassava,text,bytestring,deepseq,deepseq-generics
11 Exposed-Modules: ProjectM36.Error,
11 Exposed-Modules: ProjectM36.Error,
12 ProjectM36.Transaction,
12 ProjectM36.Transaction,
13 ProjectM36.Transaction.Show,
13 ProjectM36.Transaction.Show,