Skip to content
Cannot retrieve contributors at this time
64 lines (46 sloc) 1.69 KB
package net.sansa_stack.examples.spark.rdf
import scala.collection.mutable
import net.sansa_stack.rdf.spark.stats._
import org.apache.jena.riot.Lang
import org.apache.spark.sql.SparkSession
object RDFStats {
def main(args: Array[String]) {
parser.parse(args, Config()) match {
case Some(config) =>
run(, config.out)
case None =>
def run(input: String, output: String): Unit = {
val rdf_stats_file = new File(input).getName
val spark = SparkSession.builder
.appName(s"RDF Dataset Statistics example $rdf_stats_file")
.config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
println("| RDF Statistic example |")
val lang = Lang.NTRIPLES
val triples = spark.rdf(lang)(input)
// compute criterias
val stats = triples.stats
.voidify(rdf_stats_file, output)
// the config object
case class Config(in: String = "", out: String = "")
// the CLI parser
val parser = new scopt.OptionParser[Config]("RDF Dataset Statistics Example") {
head("RDF Dataset Statistics Example")
opt[String]('i', "input").required().valueName("<path>").
action((x, c) => c.copy(in = x)).
text("path to file that contains the data (in N-Triples format)")
opt[String]('o', "out").required().valueName("<directory>").
action((x, c) => c.copy(out = x)).
text("the output directory")
help("help").text("prints this usage text")
You can’t perform that action at this time.