<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>A Flexible N-Triples Loader for Hadoop</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Victor Anthony Arrascue Ayala</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Georg Lausen</string-name>
          <email>lauseng@informatik.uni-freiburg.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Freiburg</institution>
          ,
          <addr-line>Georges-Kohler Allee, Geb. 51, 79110 Freiburg</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The wide adoption of the RDF data model demands e cient and scalable query processing strategies. For this purpose distributed programming paradigms such as Apache Spark on top of Hadoop are increasingly being used. Unfortunately, the Hadoop ecosystem lacks support for Semantic Web standards, e.g. reading an RDF serialization format, and thus, bringing in RDF data still requires a large amount of e ort. We therefore present PRoST-loader, an application which, given a set of N-Triples documents, creates logical partitions according to three widely adopted strategies: Triple Table (TT), Wide Property Table (WPT) with a single row for each subject, and Vertical Partitioning (VP). Each strategy has its own advantages and limitations depending on the data characteristics and the task to be carried out. The loader thus leaves the strategy choice to the data engineer. The tool combines the exibility of Spark, the deserialization capabilities of Hive, as well as the compression power of Apache Parquet at the storage layer. We managed to process Dbpedia (approx. 257M triples) in 3.5 min for TT, in approx 3.1 days for VP, and in 16.8 min for WPT with up to 1,114 columns in a cluster with moderate resources. In this paper we aim to present the strategies followed, but also to expose the community to this open-source tool, which facilitates the usage of Semantic Web data within the Hadoop ecosystem and which makes it possible to carry out tasks such as the evaluation of SPARQL queries in a scalable manner.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        RDF is a widely used data model to build and publish knowledge graphs, many
of which are extremely large [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. To process and query such massive graphs,
centralized RDF processing models are not su cient and therefore there is a shift
towards distributed paradigms. Virtuoso, the de-facto industry standard
triplestore, is capable of operating on a cluster of computers but only in its commercial
form. Instead, the more general-purpose and open-source Hadoop ecosystem is
designed to e ciently process massive amounts of data while being capable of
scaling with commodity hardware. Technologies such as Spark and Hive allow
for e cient and distributed querying of data, but the capabilities go well beyond
this feature. Nowadays it is possible to train classi cation models, cluster data,
conduct statistical analysis, and much more. It is hence no surprise that there is
a growing interest in bringing Semantic Web data into that machinery to
execute important tasks such as evaluating SPARQL queries. However, there is still
a lack of support for Semantic Web standards within that ecosystem. The rst
step towards providing any possible analysis with a sound basis is loading the
data. This is the topic of the current poster presentation.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Background and Related Work</title>
      <p>
        The most adopted logical partitioning strategies for RDF are Triple Table (TT),
Wide Property Table (WPT), and Vertical Partitioning (VP) [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Each
strategy has strengths and weaknesses for SPARQL query evaluation. A Triple Table
is a single table for all triples with a schema (subject, predicate, object). This
table is typically complemented with indexes for faster retrieval, but querying
for long chains inevitably results in many self-joins. Systems such as Virtuoso1
and RDF-3X [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] implement this scheme. A Wide Property Table has one row
for each distinct subject and one column for each distinct predicate (properties).
The values of this table are the objects for a given (subject, predicate)
combination. Empty cells contain null values. WPTs can be very sparse, but in general
they are good for star-shaped queries. DB2RDF [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] is based on a sophisticated
variant of WPT. In Vertical Partitioning a table is created for each predicate
which stores a (subject, object) tuple. This strategy is good for queries with
bound predicates, whereas unbounded predicates cause all tables to be accessed.
Systems such as S2RDF [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] implement and extend this scheme. Other systems
leverage multiple partitioning schemes. This is the case for PRoST [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] which
keeps a WPT and VP and can exploit both to evaluate a single query.
PRoSTloader generates partitions following these three strategies, namely TT, WPT,
and VP, thus leaving open the possibility of leveraging any of them. To the best
of our knowledge no tools of this kind exist.
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Loading Stages</title>
      <sec id="sec-3-1">
        <title>1 https://virtuoso.openlinksw.com/ 2 https://wiki.dbpedia.org/.</title>
        <p>it by means of a HiveQL query. This is an opportunity to lter out di erent kinds
of erroneous entries. As one example, a line in the NT document which cannot
be matched by the three groups de ned in the regular expression results in null
values in the table. Moreover, when more than three elements are present in one
line, multiple resources or literals might end up being mapped all together within
the object column. We lter out these kinds of entries. Also, the predicate names
are used later as column names in the Property Table. The maximum length of
a column name in Hive is 128 characters. Therefore, predicates whose length
exceeds this limit are discarded by ltering out rows in which they appear.
The non-discarded rows are inserted into the Triple Table using the INSERT
OVERWRITE TABLE clause, which at the end is stored in Parquet format.
(C) To build the Wide Property Table rst we get a list of distinct predicates
from the Triple Table. We need to distinguish between predicates with cardinality
&lt;1,1&gt; and those with cardinality &lt;1,N&gt;. For the latter case the objects for a
given subject will be stored in an array (Spark's ArrayType), which is later
mapped to Parquet's logical types. Another control consists in making sure that
all predicates are distinct, even in a case-insensitive scenario, because these are
used as column names and Hive's table and column names are case-insensitive.
Finally, the list of predicates and their cardinalities is used to compose a query
and build the Property Table which is written to Parquet. Spark is used mainly
for this task since we needed a complex user-de ned aggregate function.
(D) Finally, using the list of predicates we build the VP tables, one at a time.
Each table is created and populated using HiveQL and stored using Parquet.</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Evaluation results</title>
      <p>We performed our tests on a small cluster of 10 machines, 1 master and 9
workers, connected via Gigabit Ethernet connection. Each machine is equipped with
32GB of memory, 4TB of disk space and with a 6 Core (12 virtual cores)
Intel Xeon E5-2420 processor. The cluster runs Cloudera CDH 5.10.0 with Spark
2.2 on Ubuntu 14.04. Yarn, the resource manager, in total uses 198 GB and
108 virtual cores. The most relevant settings of the cluster can be found in
our github repository along with the code3. We used our loader to create the
logical partitions for Dbpedia 3.5.1. This consists of 23 les (36.5 GB) loaded
into an HDFS folder. The overall number of triples is 257,869,688. In the rst
stage 126 triples were removed which contained predicates with more than 128
characters. The number of distinct predicates is 39,554, of which 13,336
predicates have cardinality &lt;1,N&gt;. The loader was able to identify 1,328 pairs of
predicates with colliding names in Hive, e.g. dbpedia:nationalchampion, and
dbpedia:nationalChampion, and removed one from each pair. The Triple Table was
written to HDFS in 3.55 minutes. The Vertical Partitioning nished in 3 days,
3 hours and 42 minutes. On average 8.7 tables were written per minute. For the
Wide Property Table we had to remove the infobox-properties which reduced
the number of properties to 1,114, since the cluster resources were not su cient
to run it on the 39K predicates. The limited WPT nished in 16.8 minutes.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusions and Future Work</title>
      <p>We believe there exists a de cit of tools for processing Semantic Web data in
distributed frameworks such as Hadoop. Our open-source tool shows that
choosing the right loading strategy is crucial to avoid wasting cluster resources and
time. Hive and Parquet compression enable fast building of the logical
partitions, while Spark's exibility in de ning distributed functions is essential to
model data. Our tool currently uses the default physical partitioning from Hive
and Spark. In the future we will explore other physical partitioning strategies.</p>
      <sec id="sec-5-1">
        <title>3 https://github.com/tf-dbis-uni-freiburg/PRoST.</title>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Abadi</surname>
            ,
            <given-names>D.J.</given-names>
          </string-name>
          , et al.:
          <article-title>Scalable semantic web data management using vertical partitioning</article-title>
          .
          <source>In: Conference on Very Large Data Bases</source>
          (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Bornea</surname>
            ,
            <given-names>M.A.</given-names>
          </string-name>
          , et al.:
          <article-title>Building an e cient RDF store over a relational database</article-title>
          .
          <source>In: ACM SIGMOD Conference on Management of Data</source>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Cossu</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          , et al.:
          <article-title>Prost: Distributed execution of SPARQL queries using mixed partitioning strategies</article-title>
          .
          <source>In: Conf. on Extending Database Technology</source>
          ,
          <string-name>
            <surname>EDBT</surname>
          </string-name>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. Farber,
          <string-name>
            <surname>M.</surname>
          </string-name>
          , et al.:
          <article-title>Linked data quality of dbpedia, freebase, opencyc, wikidata, and YAGO</article-title>
          . Semantic
          <string-name>
            <surname>Web</surname>
          </string-name>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Neumann</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          , et al.:
          <article-title>The RDF-3X engine for scalable management of RDF data</article-title>
          .
          <source>VLDB J</source>
          . (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. Schatzle,
          <string-name>
            <surname>A.</surname>
          </string-name>
          , et al.:
          <article-title>S2RDF: RDF querying with SPARQL on spark</article-title>
          .
          <source>PVLDB</source>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>