@@ -29,6 +29,14 @@ tupleAttributes (RelationTuple tupAttrs _) = tupAttrs
2929tupleAssocs :: RelationTuple -> [(AttributeName, Atom)]
3030tupleAssocs (RelationTuple attrVec tupVec) = V.toList $ V.map (first attributeName) (V.zip attrVec tupVec)
3131
32+orderedTupleAssocs :: RelationTuple -> [(AttributeName, Atom)]
33+orderedTupleAssocs tup@(RelationTuple attrVec _) = map (\attr -> (attributeName attr, atomForAttr (attributeName attr))) oAttrs
34+ where
35+ oAttrs = orderedAttributes attrVec
36+ atomForAttr nam = case atomForAttributeName nam tup of
37+ Left _ -> TextAtom "<?>"
38+ Right val -> val
39+
3240-- return atoms in some arbitrary but consistent key order
3341tupleAtoms :: RelationTuple -> V.Vector Atom
3442tupleAtoms (RelationTuple _ tupVec) = tupVec
@@ -146,10 +154,6 @@ tupleAtomExtend newAttrName atom tupIn = tupleExtend tupIn newTup
146154 where
147155 newTup = RelationTuple (V.singleton $ Attribute newAttrName (atomTypeForAtom atom)) (V.singleton atom)
148156
149−{- sort the associative list to match the header sorting -}
150−tupleSortedAssocs :: RelationTuple -> [(AttributeName, Atom)]
151−tupleSortedAssocs (RelationTuple tupAttrs tupVec) = V.toList $ V.map (\(index,attr) -> (attributeName attr, tupVec V.! index)) $ V.indexed tupAttrs
152−
153157--this could be cheaper- it may not be wortwhile to update all the tuples for projection, but then the attribute management must be slightly different- perhaps the attributes should be a vector of association tuples [(name, index)]
154158tupleProject :: S.Set AttributeName -> RelationTuple -> RelationTuple
155159tupleProject projectAttrs (RelationTuple attrs tupVec) = RelationTuple newAttrs newTupVec