@@ -3,14 +3,10 @@
33module Relation where
44import qualified Data.Map as M
55import qualified Data.Set as S
6−import qualified Data.List as L
76import qualified Data.HashSet as HS
8−import qualified Data.Hashable as Hash
97import qualified Control.Monad.Error as Err
108
11−import Debug.Trace
129import RelationType
13−import RelationAtom
1410import RelationTuple
1511import RelationAttribute
1612import RelationTupleSet
@@ -153,7 +149,6 @@ group groupAttrNames newAttrName rel@(Relation attrs tupleSet) = do
153149 newAttrs = M.insert newAttrName groupAttr (attributesForNames nonGroupAttrNames rel)
154150 groupAttr = Attribute newAttrName (RelationAtomType (attributesForNames nonGroupAttrNames rel))
155151 nonGroupAttrNames = nonMatchingAttributeNameSet groupAttrNames (attributeNames rel)
156− newAttrNames = S.insert newAttrName nonGroupAttrNames
157152 folder tupleIn acc = case acc of
158153 Left err -> Left err
159154 Right acc -> union acc (Relation newAttrs (HS.singleton (tupleExtend tupleIn (matchingRelTuple tupleIn))))
@@ -174,7 +169,6 @@ restrictEq (RelationTuple tupMap) rel = restrict filter rel
174169ungroup :: AttributeName -> Relation -> Either RelationalError Relation
175170ungroup relvalAttrName rel = relFold relFolder (Right $ Relation newAttrs emptyTupleSet) rel
176171 where
177− newAttrNames = M.keysSet newAttrs
178172 newAttrs = M.union (attributesForRelval relvalAttrName rel) nonGroupAttrs
179173 nonGroupAttrs = M.delete relvalAttrName (attributes rel)
180174 relFolder :: RelationTuple -> Either RelationalError Relation -> Either RelationalError Relation
@@ -191,7 +185,6 @@ tupleUngroup :: AttributeName -> Attributes -> RelationTuple -> Either Relationa
191185tupleUngroup relvalAttrName newAttrs tuple@(RelationTuple tupMap) = case (tupMap M.! relvalAttrName) of
192186 (RelationAtom relvalRelation) -> relFold folder (Right $ Relation newAttrs emptyTupleSet) relvalRelation
193187 where
194− newAttrNameSet = M.keysSet newAttrs
195188 nonGroupTupleProjection = tupleProject nonGroupAttrNames tuple
196189 nonGroupAttrNames = M.keysSet newAttrs
197190 folder tupleIn acc = case acc of
@@ -207,7 +200,6 @@ tupleUngroup relvalAttrName newAttrs tuple@(RelationTuple tupMap) = case (tupMap
207200attributesForRelval :: AttributeName -> Relation -> Attributes
208201attributesForRelval relvalAttrName relIn@(Relation attrs tupleSet) = attributes relvalRelation
209202 where
210− relvalRelationAttrs = attributes relvalRelation
211203 --this is only temporarily needed until the Relation stores the types of the columns as data- hack alert
212204 --find a tuple with attributes to steal to ungroup
213205 oneTuple :: RelationTupleSet -> RelationTuple