changeset 340:fd36781876e2 no-hierarchy

~ getting rid of the last use of RelName
author Alexandre Bertails <bertails@gmail.com>
date Sun, 13 Feb 2011 00:55:48 -0500
parents 44e6d81cb429
children acbc6ab3c0b5
files directmapping/src/main/scala/DirectMapping.scala rdb/src/main/scala/RDB.scala
diffstat 2 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/directmapping/src/main/scala/DirectMapping.scala	Sun Feb 13 00:29:29 2011 -0500
+++ b/directmapping/src/main/scala/DirectMapping.scala	Sun Feb 13 00:55:48 2011 -0500
@@ -27,13 +27,13 @@
 
     /**
      * given:
-     *   - rn a RelName
-     *   - ck a CandidateKey <- ck must be part of the relation rn with name rn
+     *   - r a Relation
+     *   - ck a CandidateKey <- ck must be part of the relation r
      *   - vs a list of values <- vs should correspond to the values for ck
      * a function of type NodeMap maps these elements to a unique RDF node
      * it's type is equivalent to the following curried function:
-     *   RelName -> CandidateKey -> List[CellValue] -> Node
-     * it verifies the following axiom:
+     *   Relation -> CandidateKey -> List[CellValue] -> Node
+     * the following property holds:
      *   ∀ r:Relation, ∀ ck:CandidateKey, ck ∊ Relation, ∀ t1:Tuple, ∀ t2:Tuple,
      *   t1 ≠ t2 -> l1 = t1(ck) -> l2 = t2(ck) -> l1 = l2 -> nodemap(r)(ck)(l1) ≠ nodemap(r)(ck)(l1)
      */
@@ -61,10 +61,14 @@
 	     n:Node):Map[CandidateKey,  Map[List[CellValue], Node]] = {
 	pairs.foldLeft(m) { case (m, (ck, cellValues)) => {
           m.get(ck) match {
+	    // if a tuple is already mapped to a node, it's an error
             case Some(byKey) if byKey.get(cellValues).isDefined =>
               error("tried to set " + ck + cellValues + " = " + n + "(was " + byKey(cellValues) + ")")
+	    // if this candidate key is already known,
+	    // we just have to add the information for these values and this particular node
             case Some(byKey) =>
               m + (ck -> (byKey + (cellValues -> n)))
+	    // if this is the first time we meet the candidate key, we initialize the map
             case None =>
               m + (ck -> Map(cellValues -> n))
           }
@@ -100,7 +104,7 @@
     def databaseSemantics(db:Database):Graph = {
       NextBNode = 97
       val nodemap = dbToNodeMap(db)
-      Graph(db.relNames flatMap { rn:RelName => relationSemantics(db, nodemap, db(rn)) })
+      Graph(db.relations flatMap { r => relationSemantics(db, nodemap, r) })
     }
   
     def relationSemantics(db:Database, nodemap:NodeMap, r:Relation):Graph =
@@ -128,7 +132,6 @@
 	  }
         }
       val fromFKs = t.references(r) map { fk => referenceSemantics(r, nodemap, t, fk) }
-      // 
       val fromLexicalValues = t.scalars(r) flatMap { a => lexicalValueSemantics(r, t, a) }
       // the relation provenance is mapped to an RDF type information, computed from the relation itself
       val fromRelation = (PredicateIRI(IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")),
--- a/rdb/src/main/scala/RDB.scala	Sun Feb 13 00:29:29 2011 -0500
+++ b/rdb/src/main/scala/RDB.scala	Sun Feb 13 00:55:48 2011 -0500
@@ -21,8 +21,8 @@
 
     def apply(rn:RelName) = m(rn)
     def isDefinedAt(rn:RelName) = m isDefinedAt rn
-    /** returns all the relation names */
-    def relNames:Set[RelName] = m.keySet.toSet
+    /** returns all the relations */
+    def relations:Set[Relation] = m.values.toSet
     /** return all the relations with at least on Candidate Key */
     def indexables = m collect { case (rn, r) if r.isIndexable => r }
   }
Set up and maintained by W3C Systems Team, please report bugs to sysreq@w3.org.

W3C would like to thank Microsoft who donated the server that allows us to run this service.