This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:site:recherche:logiciels:sparqlwithspark:utility [15/09/2016 15:41] hubert [Utilities] |
en:site:recherche:logiciels:sparqlwithspark:utility [16/09/2016 23:05] (current) hubert [Utilities] |
||
---|---|---|---|
Line 6: | Line 6: | ||
=== Data loading utilities=== | === Data loading utilities=== | ||
- | <code> | + | <code scala> |
// TIMER | // TIMER | ||
Line 73: | Line 73: | ||
=== QUERY utilities === | === QUERY utilities === | ||
- | <code> | + | <code scala> |
case class v(n:Int) | case class v(n:Int) | ||
Line 86: | Line 86: | ||
} | } | ||
- | // encode property and literal | + | // encode properties and literals in a query |
def sparqlEncode(splittedSparql: List[(Any, (String, String), Any)]): List[(Any, Int, Any)] = { | def sparqlEncode(splittedSparql: List[(Any, (String, String), Any)]): List[(Any, Int, Any)] = { | ||
return splittedSparql.map{ case (s,(ns,p),o) => | return splittedSparql.map{ case (s,(ns,p),o) => | ||
Line 99: | Line 99: | ||
+ | // generate selection operator for each triple pattern | ||
def tpOperators(encodedQuery: List[(Any, Int, Any)], d: Map[Int, DataFrame]) = | def tpOperators(encodedQuery: List[(Any, Int, Any)], d: Map[Int, DataFrame]) = | ||
encodedQuery.map{ case(v(a), p, v(b))=> ( (v(a), p, v(b)), d(p).withColumnRenamed("o", s"v$b")) | encodedQuery.map{ case(v(a), p, v(b))=> ( (v(a), p, v(b)), d(p).withColumnRenamed("o", s"v$b")) |