changeset 332:0b6248c67203 no-hierarchy

- StemIRI
author Alexandre Bertails <bertails@gmail.com>
date Sat, 12 Feb 2011 16:10:50 -0500
parents b13a84b588cf
children e01de9b8dfcd
files directmapping/src/main/scala/DirectMapping.scala
diffstat 1 files changed, 3 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/directmapping/src/main/scala/DirectMapping.scala	Sat Feb 12 16:01:37 2011 -0500
+++ b/directmapping/src/main/scala/DirectMapping.scala	Sat Feb 12 16:10:50 2011 -0500
@@ -17,32 +17,6 @@
      */
     type KeyMap = PartialFunction[CandidateKey, PartialFunction[List[CellValue], Node]]
 
-    // case class KeyMap(private val m:Map[CandidateKey,  Map[List[CellValue], Node]]) extends PartialFunction[CandidateKey, PartialFunction[List[CellValue], Node]] {
-    //   def ++(pairs:List[(CandidateKey, List[CellValue])], n:Node):KeyMap = {
-    //     val m2:Map[CandidateKey,  Map[List[CellValue], Node]] =
-    //       pairs.foldLeft(m) { case (m, (ck, cellValues)) => {
-    //         m.get(ck) match {
-    //           case Some(byKey) if byKey.get(cellValues).isDefined =>
-    //             error("tried to set " + ck + cellValues + " = " + n + "(was " + byKey(cellValues) + ")")
-    //           case Some(byKey) =>
-    //             m + (ck -> (byKey + (cellValues -> n)))
-    //           case None =>
-    //             m + (ck -> Map(cellValues -> n))
-    //         }
-    //       } }
-    //     KeyMap(m2)
-    //   }
-    // }
-
-    /** The NodeMap-generating functions: */
-    // def relation2KeyMap (r:Relation) : KeyMap = {
-    //   val m = KeyMap(Map[CandidateKey, Map[List[CellValue], Node]]())
-    //   r.body.foldLeft(m) { (m, t) => {
-    //     val (pairs, node) = rdfNodeForTuple(t, r)
-    //     m ++ (pairs, node)
-    //   } }
-    // }
-
     def KeyMap(r:Relation):KeyMap = {
       def ++(m:Map[CandidateKey,  Map[List[CellValue], Node]],
 	     pairs:List[(CandidateKey, List[CellValue])],
@@ -59,10 +33,8 @@
         } }  
       }
       val m = Map[CandidateKey, Map[List[CellValue], Node]]()
-      r.body.foldLeft(m) { (m, t) => {
-        val (pairs, node) = rdfNodeForTuple(t, r)
-        ++(m, pairs, node)
-      } }
+      val tuples = r.body map { t => rdfNodeForTuple(t, r) }
+      tuples.foldLeft(m){ case (m, (pairs, node)) => ++(m, pairs, node) }
     }
 
     type NodeMap = PartialFunction[RelName, KeyMap]
@@ -71,12 +43,7 @@
       val idxables = db.keySet filter { rn => db(rn).candidates nonEmpty }
       idxables map { rn:RelName => rn -> KeyMap(db(rn)) } toMap
     }
-  
-    /** The direct mapping requires one parameter: the StemIRI */
-    case class StemIRI(stem:String) {
-      def +(path:String):IRI = IRI(stem + path)
-    }
-  
+    
     /**
      * The mapping functions implementing
      * <http://www.w3.org/2001/sw/rdb2rdf/directGraph/>
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.