--- 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/>