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:chain6 [13/09/2016 23:03] hubert |
en:site:recherche:logiciels:sparqlwithspark:chain6 [16/09/2016 23:11] (current) hubert [Chain6 query plans] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{indexmenu_n>7}} | ||
+ | |||
====== Chain6 query plans ====== | ====== Chain6 query plans ====== | ||
The plans produced by each method are: | The plans produced by each method are: | ||
* SPARQL RDD: | * SPARQL RDD: | ||
- | <code> | + | <code scala> |
val d1 = triples.filter{case(s,(p,o))=> p==P1}.map{case(x1,(p, x2))=> (x2, x1)} | val d1 = triples.filter{case(s,(p,o))=> p==P1}.map{case(x1,(p, x2))=> (x2, x1)} | ||
val d2 = triples.filter{case(s,(p,o))=> p==P2}.mapValues{case(p,x3) => x3} | val d2 = triples.filter{case(s,(p,o))=> p==P2}.mapValues{case(p,x3) => x3} | ||
Line 19: | Line 21: | ||
* SPARQL DF: | * SPARQL DF: | ||
- | <code> | + | <code scala> |
val t1 = df.where(s"p =$P1").select("s","o").withColumnRenamed("s", "x1").withColumnRenamed("o", "x2") | val t1 = df.where(s"p =$P1").select("s","o").withColumnRenamed("s", "x1").withColumnRenamed("o", "x2") | ||
val t2 = df.where(s"p=$P2").select("s","o").withColumnRenamed("s", "x2").withColumnRenamed("o", "x3") | val t2 = df.where(s"p=$P2").select("s","o").withColumnRenamed("s", "x2").withColumnRenamed("o", "x3") | ||
Line 31: | Line 33: | ||
* SPARQL Hybrid DF: | * SPARQL Hybrid DF: | ||
- | <code> | + | <code scala> |
+ | val subg = df.where(s"p in ($P1, $P2, $P3, $P4, $P5, $P6)") | ||
+ | subg.persist | ||
+ | subg.count | ||
+ | val st1 = subg.where(s"p= $P1").select("s","o").withColumnRenamed("s", "x1").withColumnRenamed("o", "x2") | ||
+ | val st2 = subg.where(s"p= $P2").select("s","o").withColumnRenamed("s", "x2").withColumnRenamed("o", "x3") | ||
+ | val st3 = subg.where(s"p= $P3").select("s","o").withColumnRenamed("s", "x3").withColumnRenamed("o", "x4") | ||
+ | val st4 = subg.where(s"p= $P4").select("s","o").withColumnRenamed("s", "x4").withColumnRenamed("o", "x5") | ||
+ | val st5 = subg.where(s"p= $P5").select("s","o").withColumnRenamed("s", "x5").withColumnRenamed("o", "x6") | ||
+ | val st6 = subg.where(s"p= $P6").select("s","o").withColumnRenamed("s", "x6").withColumnRenamed("o", "x7") | ||
+ | val res = st1.join(st2,Seq("x2")).join(st3,Seq("x3")).join(st4,Seq("x4")).join(st5,Seq("x5")).join(st6,Seq("x6")) | ||
+ | res.count | ||
</code> | </code> | ||
- | Go to [[en:site:recherche:logiciels:sparqlwithspark| other queries]] | + | Go to [[en:site:recherche:logiciels:sparqlwithspark]] |