Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3078340
commit 3387704
Showing
7 changed files
with
133 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 48 additions & 1 deletion
49
...ry-spark/src/main/scala/net/sansa_stack/query/spark/api/impl/QueryEngineFactoryBase.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,59 @@ | ||
package net.sansa_stack.query.spark.api.impl | ||
|
||
import org.aksw.sparqlify.core.sql.common.serialization.{SqlEscaper, SqlEscaperBacktick, SqlEscaperDoubleQuote} | ||
import org.apache.jena.graph | ||
import org.apache.jena.rdf.model.ModelFactory | ||
import org.apache.spark.rdd.RDD | ||
import org.apache.spark.sql.SparkSession | ||
|
||
import net.sansa_stack.query.spark.api.domain.QueryEngineFactory | ||
import net.sansa_stack.query.spark.api.domain.{QueryEngineFactory, QueryExecutionFactorySpark} | ||
import net.sansa_stack.rdf.common.partition.core.{RdfPartitionStateDefault, RdfPartitioner, RdfPartitionerComplex, RdfPartitionerDefault} | ||
import net.sansa_stack.rdf.common.partition.r2rml.R2rmlUtils | ||
import net.sansa_stack.rdf.spark.partition.core.{RdfPartitionUtilsSpark, SQLUtils, SparkTableGenerator} | ||
|
||
/** | ||
* @author Lorenz Buehmann | ||
*/ | ||
abstract class QueryEngineFactoryBase(spark: SparkSession) extends QueryEngineFactory { | ||
|
||
protected def createWithPartitioning(triples: RDD[graph.Triple], | ||
partitioner: RdfPartitioner[RdfPartitionStateDefault] = RdfPartitionerDefault, | ||
explodeLanguageTags: Boolean = false, | ||
sqlEscaper: SqlEscaper = new SqlEscaperBacktick(), | ||
escapeIdentifiers: Boolean = false): QueryExecutionFactorySpark = { | ||
// apply vertical partitioning | ||
val partitions2RDD = RdfPartitionUtilsSpark.partitionGraph(triples, partitioner) | ||
|
||
val tableNameFn: RdfPartitionStateDefault => String = p => SQLUtils.escapeTablename(R2rmlUtils.createDefaultTableName(p)) | ||
|
||
partitions2RDD.foreach { | ||
case (p, rdd) => | ||
println(p) | ||
rdd.collect().foreach(println) | ||
} | ||
|
||
// create the Spark tables | ||
SparkTableGenerator(spark).createAndRegisterSparkTables(partitioner, | ||
partitions2RDD, | ||
extractTableName = tableNameFn) | ||
|
||
// create the mappings model | ||
val mappingsModel = ModelFactory.createDefaultModel() | ||
R2rmlUtils.createR2rmlMappings( | ||
partitioner, | ||
partitions2RDD.keySet.toSeq, | ||
tableNameFn, | ||
sqlEscaper, | ||
mappingsModel, | ||
explodeLanguageTags, | ||
escapeIdentifiers) | ||
|
||
create(null, mappingsModel) | ||
|
||
} | ||
|
||
override def create(triples: RDD[graph.Triple]): QueryExecutionFactorySpark = { | ||
createWithPartitioning(triples) | ||
} | ||
|
||
} |
25 changes: 24 additions & 1 deletion
25
...uery-spark/src/main/scala/net/sansa_stack/query/spark/ontop/QueryEngineFactoryOntop.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters