~ simplifications (db not needed most of the time) no-hierarchy
authorAlexandre Bertails <bertails@gmail.com>
Sun, 13 Feb 2011 18:09:52 -0500
branchno-hierarchy
changeset 342 05d5a585b109
parent 341 acbc6ab3c0b5
child 343 b4679fb25560
~ simplifications (db not needed most of the time)
directmapping/src/main/scala/DirectMapping.scala
rdb/src/main/scala/RDB.scala
--- a/directmapping/src/main/scala/DirectMapping.scala	Sun Feb 13 01:06:00 2011 -0500
+++ b/directmapping/src/main/scala/DirectMapping.scala	Sun Feb 13 18:09:52 2011 -0500
@@ -104,17 +104,17 @@
     def databaseSemantics(db:Database):Graph = {
       NextBNode = 97
       val nodemap = dbToNodeMap(db)
-      Graph(db.relations flatMap { r => relationSemantics(db, nodemap, r) })
+      Graph(db.relations flatMap { r => relationSemantics(nodemap, r) })
     }
   
-    def relationSemantics(db:Database, nodemap:NodeMap, r:Relation):Graph =
+    def relationSemantics(nodemap:NodeMap, r:Relation):Graph =
       /* flatMap.toSet assumes that no two triples from directT would be the same.
        * We know this because relations with candidate keys are mapped to unique
        * subjects, and potentially redundant rows get unique blank node subjects.
        */
-      Graph(r.body flatMap { t => tupleSemantics(db, nodemap, r, t) })
+      Graph(r.body flatMap { t => tupleSemantics(nodemap, r, t) })
   
-    def tupleSemantics (db:Database, nodemap:NodeMap, r:Relation, t:Tuple):Set[Triple] = {
+    def tupleSemantics (nodemap:NodeMap, r:Relation, t:Tuple):Set[Triple] = {
       val s:SubjectNode =
 	// look for the first candidate key if available
         r.candidates.headOption match {
--- a/rdb/src/main/scala/RDB.scala	Sun Feb 13 01:06:00 2011 -0500
+++ b/rdb/src/main/scala/RDB.scala	Sun Feb 13 18:09:52 2011 -0500
@@ -60,7 +60,6 @@
   case class Header(private val m:Map[AttrName, Datatype]) extends PartialFunction[AttrName, Datatype] {
     def apply(a:AttrName) = m(a)
     def isDefinedAt(a:AttrName) = m isDefinedAt a
-    def attrNames:Set[AttrName] = m.keySet.toSet
   }
 
   object Header {
@@ -139,10 +138,7 @@
    * the expected operation are available
    */
   case class ForeignKeys (private val fks:Set[ForeignKey]) {
-    def has(as:AttrList) = fks exists { _.attrs == as }
-    def getFK(as:AttrList):ForeignKey = fks find { _.attrs == as } get
-    def unaryFKs:Set[ForeignKey] = fks filter { _.isUnary }
-    def definesActuallyUnaryFK(a:AttrName):Boolean = unaryFKs exists { _.attrs contains a }
+    def definesActuallyUnaryFK(a:AttrName):Boolean = fks filter { _.isUnary } exists { _.attrs contains a }
     def filter(p: ForeignKey => Boolean):Set[ForeignKey] = fks filter p
     def foreach(f:ForeignKey => Unit) = fks foreach f
   }