<!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>HAQWA: a Hash-based and Query Workload Aware Distributed RDF Store</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Olivier Cure</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Hubert Naacke</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mohamed-Amine Baazizi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Bernd Amann</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Sorbonne Universites</institution>
          ,
          <addr-line>UPMC Univ Paris 06, UMR 7606, LIP6, F-75005, Paris, CNRS, UMR 7606, LIP6, F-75005, Paris</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Like most data models encountered in the Big Data ecosystem, RDF stores are managing large data sets by partitioning triples across a cluster of machines. Nevertheless, the graphical nature of RDF data as well as its associated SPARQL query execution model makes the e cient data distribution more involved than in other data models, e.g., relational. In this paper, we propose a novel system that is characterized by a trade-o between complexity of data partitioning and e ciency of query answering in cases where a query workload is known. The prototype is implemented over the Apache Spark framework, ensuring high availability, fault tolerance and scalability. This short paper presents the main features of the system and highlights the omnipresence of parallel computation across data fragmentation and allocation, encoding and query processing tasks.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>The volume of produced RDF data keeps increasing, partly due to the popularity
of projects such as Linked Open Data (LOD) and Schema.org. In order to ful ll
the vision of the Web of data as well as of the Semantic Web, it is necessary to
manage such data in an e cient manner. With RDF graphs composed of
hundreds of millions to several billions of triples, a distributed approach is generally
necessary to address issues such as fault tolerance, high availability and
scalability. This analysis applies to all popular data models, e.g., relational, but the
case of RDF is more involved due to its graphical nature and its navigational
query characterization as well as its inherent need for reasoning services.</p>
      <p>
        The graphical aspect is related to the manner in which one partitions a graph
over a cluster. Usually one expects to obtain a properly balanced partitioning,
i.e., the graph triples are evenly distributed over the cluster nodes. But for
high availability, the system may also impose some data replication. This may
impact the query processing performance which is fundamentally navigational in
SPARQL. Intuitively, the system binds variables present in a query by matching
its pattern to a given RDF graph. These variables generally span several triple
patterns and thus provide a form of join. The number of joins generally exceeds
what one is used to encounter in queries of other data models, e.g., SQL in
the relational data model. Even, for a single machine RDF store [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], this aspect
implies specialized query optimization techniques to ensure the identi cation of
an e cient query plan. Several recent research works [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] and [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] claim that
these graphical and navigational aspects are not be considered independently. By
considering them together, one wants to address load-balancing and replication
on one side and to minimize exchanges across the network on the other side.
For instance, the graph satisfying a SPARQL query may be partitioned across
several machines thus requiring to transfer temporary results from one node to
another to perform a join. It is frequent in real-world cases that the cost of
network communication exceeds the cost of local query processing.
      </p>
      <p>The inference aspect is related to the presence of an ontology, e.g., RDFS or
OWL. It directly impacts data preparation and query processing. The two main
solutions are: (i) materialization where all possible entailments are persisted
in the store at data loading-time and hence allowing for a standard SPARQL
query processor or (ii) query-reformulation where queries are rewritten at query
run-time using a reasoner but where no extra data preparation is required.</p>
      <p>In the HAQWA (Hash-based and Query Workload Aware) system, we
propose a trade-o between data distribution complexity and query answering e
ciency together with an encoding approach supporting RDFS entailments with
a minimum of materialization and query reformulation. The performances of
the system are partly due to the usage of the Apache Spark framework and to
the best of our knowledge, our solution is the rst implementation of an RDF
store over this parallel computing system. In the following sections, we present
three main components, namely data fragmentation/allocation, data encoding
and query processing and highlight the impact of the Spark implementation.
2
2.1</p>
    </sec>
    <sec id="sec-2">
      <title>System components</title>
      <sec id="sec-2-1">
        <title>Fragmentation and Allocation</title>
        <p>
          Our fragmentation and allocation strategies are complementary and aim to
produce a compromise between query processing e ciency and data preparation
duration. In a rst step, a hash-based partitioning is performed using triples'
subjects as keys. This fragmentation ensures that star-shaped queries are
performed locally but they provide no guarantees on other query forms, e.g.,
property chains, tree, cycle or hybrid. This approach is much faster than other
solutions, e.g., based on a graph partitioner such as Metis [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ], [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ] or some machine
learning techniques [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ], e.g., k-means.
        </p>
        <p>
          The allocation approach is based on the analysis of frequent queries executed
over the dataset and is inspired from the WARP algorithm [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ]. Intuitively, the
system decomposes the query triple pattern into a set of local sub-queries which
are all evaluated locally. Each of those sub queries is a candidate to be the
starting point (seed query) to evaluate the entire query pattern. To prevent any
network communication across nodes, the missing triples are replicated into the
partitions that contains the triples of the seed. To do so, for each candidate and
partition, HAQWA computes the cost of transferring missing triples into the
current partition.
        </p>
        <p>These component's steps have been implemented as Spark programs using the
Scala programming language, thus ensuring parallel executions of the di erent
tasks, e.g., hash-based partitioning and query-aware distribution/replication.
2.2</p>
      </sec>
      <sec id="sec-2-2">
        <title>Data set encoding</title>
        <p>Once the data are allocated to cluster nodes, the system performs an encoding
steps which has two bene ts. First, it considerably reduces the volume of the data
set by storing subjects, properties and objects as integer values and not as strings
of characters. Moreover, operations over the integer-based triple representation
is also much more e cient that the one on strings.</p>
        <p>In the presence of an ontology, our encoding approach distinguishes between
the ontology and the set of instances. First, a smart binary encoding assigns
identi ers to concepts and properties of the ontology such that these identi ers
represent the corresponding hierarchies. These identi ers are used during query
processing to prevent query reformulation while ensuring answer completeness
for the RDFS entailment regime. The encoding system also addresses domain
and range RDFS properties through the creation of additional data structures.
The facts present in the RDF dataset are encoded in a traditional way by
producing two dictionaries (id to String and String to id) which enable to translate
the triple patterns of a query and the computed result set e ciently.</p>
        <p>The ontology encoding is performed on the Spark master node and thus
runs on a single machine (the only non parallel task of our system). It uses
the HermiT reasoner to compute concept classi cation of OWL ontologies. The
instance dictionaries are computed in parallel using a chain of map, reduce and
zip Spark operations reminiscent of functional programming. Compared to other
approaches, e.g., based on MapReduce, our approach is much more e cient due
to the intensive use of main-memory that Spark is doing, as opposed to disk
accesses with MapReduce.
2.3</p>
      </sec>
      <sec id="sec-2-3">
        <title>Query processing</title>
        <p>Our fragmentation and allocation strategy ensures that queries satisfying (up
to some generalization/specialization) any of the queries of the workload as well
as star-shaped queries are performed locally. Other queries may require some
network communication but that is a cost we are willing to pay for the e ciency
of the most frequent queries as well as the minimization of the memory-footprint.</p>
        <p>A SPARQL query sent to the HAQWA system is translated into a Spark
program. The generation of such a program is simpli ed (compared to what one
would have to implement over the Hadoop framework) due to the richness of the
Spark API. Example 1 emphasizes the use of the map, join and f ilter methods
to translate the graph patterns of a simple query.</p>
        <p>Example 1: In this example, we only concentrate on the triple pattern of
the query since displaying the result set is straight forward.</p>
        <p>SELECT ?x, ?y WHERE {?x rdf:type lubm:GraduateStudent.
?x lubm:name ?y. ?x lubm:advisor ?z.}
The elements of the graph patterns are translated using the dictionaries, e.g., the
identi ers for rdf : type, lubm : GraduateStudent, lubm : name are respectively
0 (from the ontology property dictionary), 956301312 (from the ontology
concept dictionary) and 671088640 (from the instances dictionary). This permits to
generate the following Scala command line where triples is a Spark Resilient
Distributed Dataset (RDD), a data distributed data container.
tr.filter(case(s,p,o)=&gt; p==0 &amp;&amp; o==956301312).</p>
        <p>map(case(s,p,o)=&gt;(s,(p,o))).
join(tr.filter(case(s,p,o)=&gt; p==671088640).
map(case(s,p,o)=&gt;(s,(p,o)))).map(case(s,(l1,l2))=&gt;(s,null)).
join(tr.filter(case(s,p,o)=&gt; p==1233125376).</p>
        <p>map(case(s,p,o)=&gt;(s,(p,o)))).map{case(s,(a,(p,o)))=&gt;(o,s))}
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Conclusion and future works</title>
      <p>
        In this paper, we have presented a rst implementation of an RDF store over
Apache Spark, an evolution of the Hadoop framework. The rst experiments [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]
highlight encouraging performances which are mainly due to selection of
particular strategies for the fragmentation and the allocation of the triples as well as
to intensive usage of the cluster's main memory. Our solution also integrates an
original encoding approach that supports the RDFS entailment regime without
the usual materialization and query reformulation heavy machinery. In future
works, we aim to implement a dedicated query optimizer for this Spark-based
implementation and to extend the supported entailment regime to a more
expressive ontology language, e.g. RDFS++.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>O.</given-names>
            <surname>Cure</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Naacke</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Baazizi</surname>
          </string-name>
          , and
          <string-name>
            <given-names>B.</given-names>
            <surname>Amann</surname>
          </string-name>
          .
          <article-title>On the evaluation of RDF distribution algorithms implemented over apache spark</article-title>
          .
          <source>CoRR, abs/1507.02321</source>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>M.</given-names>
            <surname>Hammoud</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. A.</given-names>
            <surname>Rabbou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Nouri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Beheshti</surname>
          </string-name>
          , and
          <string-name>
            <given-names>S.</given-names>
            <surname>Sakr</surname>
          </string-name>
          .
          <article-title>DREAM: distributed RDF engine with adaptive query planner and minimal communication</article-title>
          .
          <source>PVLDB</source>
          ,
          <volume>8</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>K.</given-names>
            <surname>Hose</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Schenkel</surname>
          </string-name>
          . WARP:
          <article-title>workload-aware replication and partitioning for RDF</article-title>
          .
          <source>In Workshops Proceedings of the 29th IEEE International Conference on Data Engineering, ICDE</source>
          <year>2013</year>
          , Brisbane, Australia, April 8-
          <issue>12</issue>
          ,
          <year>2013</year>
          , pages
          <issue>1{6</issue>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>J.</given-names>
            <surname>Huang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. J.</given-names>
            <surname>Abadi</surname>
          </string-name>
          , and
          <string-name>
            <given-names>K.</given-names>
            <surname>Ren</surname>
          </string-name>
          .
          <article-title>Scalable sparql querying of large rdf graphs</article-title>
          .
          <source>PVLDB</source>
          ,
          <volume>4</volume>
          (
          <issue>11</issue>
          ):
          <volume>1123</volume>
          {
          <fpage>1134</fpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>T.</given-names>
            <surname>Neumann</surname>
          </string-name>
          and
          <string-name>
            <surname>G. Weikum.</surname>
          </string-name>
          <article-title>The rdf-3x engine for scalable management of rdf data</article-title>
          .
          <source>VLDB J</source>
          .,
          <volume>19</volume>
          (
          <issue>1</issue>
          ):
          <volume>91</volume>
          {
          <fpage>113</fpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>B.</given-names>
            <surname>Wu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Yuan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Jin</surname>
          </string-name>
          , and
          <string-name>
            <given-names>L.</given-names>
            <surname>Liu</surname>
          </string-name>
          .
          <article-title>Semstore: A semantic-preserving distributed rdf triple store</article-title>
          .
          <source>In Proceedings of the 23rd ACM International Conference on Conference on Information and Knowledge Management</source>
          ,
          <source>CIKM '14</source>
          , pages
          <fpage>509</fpage>
          {
          <fpage>518</fpage>
          , New York, NY, USA,
          <year>2014</year>
          . ACM.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>