<!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>Decentralizing the Persistence and Querying of RDF Datasets Through Browser-Based Technologies</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Blake Regalia - blake@geog.ucsb.edu</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>STKO Lab, University of California</institution>
          ,
          <addr-line>Santa Barbara</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Even though linked open data are inherently capable of persisting in a decentralized fashion, the Semantic Web community is currently lacking effective workflows for seamlessly sharing and querying RDF datasets beyond relatively small scales. The most accessible methods for cloning and subsequently querying an RDF dataset are quite involved, often requiring users to locate and download a data dump, install and run a local SPARQL engine, load data into the triplestore, and then query their endpoint using some interface. While these actions may qualify as the first step towards decentralization, the incentive for such a user to then make their local endpoint available to the World Wide Web and thus act as an auxiliary host or 'mirror' is hard to surmise. In this work, we answer the intelligent client challenge by presenting a browser-based RDF query engine coupled with web-based peer-to-peer networks to illustrate the decentralized persistence and use of RDF datasets via intelligent peers.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        It is no surprise that in recent years, web services and standalone web applications
have been introduced as viable competitors to desktop native applications thanks to
innovative Web technologies [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. When it comes to hosting and querying RDF datasets
however, native applications are almost always involved, typically on the server side.
While this technique is trivial for centralized architectures, it does not promote the
decentralization of persisting and querying RDF datasets. [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] demonstrates the value
that decentralization has on the Semantic Web by thoroughly examining the methods
and applications found at the intersection of the Semantic Web and Peer-to-Peer.
Additionally, as several previous works have demonstrated [
        <xref ref-type="bibr" rid="ref12">12,13</xref>
        ], intelligent clients play
an important role when it comes to improving both the acessibility to RDF datasets as
well as the reliability of obtaining query results. In this work, we strive towards the
decentralization of persisting and querying RDF datasets by creating intelligent peers
that may simultaneously act as data publishers, data hosts and data consumers.
Using peer-to-peer (p2p) networks to disseminate large RDF datasets has two main
advantages for the Semantic Web community: (1) data publishers who operate with
limited resources may circumvent hosting costs once their dataset reaches a sufficient
demand, i.e., a substantial number of seeds1 and (2) data consumers should see an
in1A peer that is uploading content for other peers
creased availability of datasets correlate with larger swarm2 sizes. From the data
publisher’s perspective, a p2p content delivery network (CDN) operates at a fraction of the
cost compared to the equivalent centralized approach because a p2p CDN only requires
the cost of initial seeds. From the data consumer’s perspective, as the number of seeds
increases, so does the probability of faster content delivery for any new peer. While
other works in the literature have focused on distributed RDF repositories [
        <xref ref-type="bibr" rid="ref1 ref2 ref3 ref4">2,3,1,4</xref>
        ], our
approach is to deliver the entire dataset, or a complete selection of the dataset, to each
peer so that applications can continue to function offline. We have also yet to see a p2p
implementation of RDF persistence or querying in the browser.
      </p>
      <p>Web Real-Time Communication (WebRTC)3 is a set of protocols and APIs that is
currently being standardized by W3C to enable communication between clients, within
the browser, over p2p connections. A demonstration of this technology, already
implemented in most major browsers, is made available by the open-source JavaScript library
WebTorrent4, which offers many of the same features as traditional torrent programs.
For example, incoming torrent data are available to use on-arrival, meaning that
applications can start operating on fragments of a dataset before the full file is downloaded.
Although our prototype does not yet take advantage of this capability, a use case is
demonstrated by the streaming video playback on the WebTorrent home page. We
employ the WebTorrent library to demonstrate how WebRTC can be used to deliver RDF
dataset content to clients within the browser.
3</p>
    </sec>
    <sec id="sec-2">
      <title>Querying RDF Datasets in the Browser</title>
      <p>
        While there are several existing browser-based triplestores and query engines [
        <xref ref-type="bibr" rid="ref11 ref6 ref8">8,11,6,13</xref>
        ],
the major shortcomings of these JavaScript libraries have to do with the size of datasets
they can reliably handle, query performance, or the overhead time of acquiring a dataset
prior to querying. The cause for these shortcomings can be narrowed down to the fact
that no client-side implementation is making use of a binary serialization format that
applies succinct data structures. Such serializations are intended to create compact
storage footprints while also enabling high-performance query operations without the need
for decompression. HDT [
        <xref ref-type="bibr" rid="ref5 ref9">5,9</xref>
        ] is the pioneer binary serialization format for encoding
RDF datasets using compact data structures that can be queried in-place, i.e., without
transformations. In order to drive forward real-time Semantic Web applications that
take place in the browser, intelligent clients should be able to quickly and efficiently
transmit, receive and query RDF datasets with little overhead.
      </p>
      <p>As a proof of concept, we provide here5 a working prototype that combines our
browser-based RDF query engine, a connection to a p2p network, and the use of RDF
datasets that have been encoded using a custom binary serialization format based on
HDT. The web application initially downloads an RDF dataset by connecting to a p2p
network via WebTorrent. We don’t go into details about our custom binary serialization
format here, but the encoding software is written entirely in JavaScript and is therefore
2All active peers in a p2p network sharing the same torrent
3https://webrtc.org
4https://webtorrent.io
5http://phuzzy.link/query/
also capable of being used by intelligent peers to create new RDF datasets from within
the browser. Result times will vary depending on the machine used to trial our web
application demo, but we believe that its performance illustrates the potential that this
type of approach has.</p>
      <p>In its current state, our query engine works exclusively on basic graph patterns, i.e.,
sets of triple patterns and filters. In order to generate graph patterns, we designed a
JavaScript API that follows a graph traversal query paradigm, much like the Gremlin
Graph Traversal Language6. This low-level approach of using an API to build queries
offers several compelling advantages to us over the more user-friendly alternative of a
query language such as SPARQL. First of all, the data structures we are using to store
RDF terms and RDF triples, as well as their complementary search algorithms, make the
API-built queries straightforward to construct and evaluate. More importantly however,
supporting a high-level query language such as SPARQL requires that some library will
handle parsing, query planning and query optimization. With a graph traversal query
paradigm, the costs associated with these processes are either voided or significantly
mitigated by virtue of the query paradigm itself, e.g., parsing is handled by the runtime
system directly and query planning is essentially performed by the query author.
Reducing costs at this stage of query execution is pivotal to our goal of competing with the
time it takes distant endpoints to return query results. In the broader scheme of
providing a usable query engine, we wish to start by offering the bare essentials for querying
in the form of an API. Support for a more advanced query language such as SPARQL
is therefore supplemental and appropriate for future work. A sample query is shown in
Listing 1, and its equivalent SPARQL query shown in Listing 2. Documentation about
our query API is available online7.
(graph) =&gt; graph.pattern()
.object(’dbo:City’).edgeIn(’rdf:type’)
.subjects().mark(’city’)
.forkOut({
’dbo:isPartOf’: e =&gt; e.object(’dbr:California’),
’rdfs:label’: e =&gt; e.literals()</p>
      <p>.data(’language’, k =&gt; k.in(’en’)).mark(’name’),
’dbo:populationTotal’: e =&gt; e.literals()</p>
      <p>.data(’number’, k =&gt; k.is(’&gt;=’,1e5).is(’&lt;’,2e5).save(’population’)),
})
.exit();
Listing 1 A sample query that shows how our low-level JavaScript API is used to create graph
patterns. This query selects all cities in California that have a population between 100,000 and
200,000 from a selection of the DBpedia dataset.</p>
      <p>select * {
?city a dbo:City ;
dbo:isPartOf dbr:California ;
rdfs:label ?name ;
dbo:populationTotal ?population .
}
filter(isLiteral(?name))
filter(langMatches(lang(?name), "en"))
filter(isNumeric(?population))
filter(?population &gt;= 100000 &amp;&amp; ?population &lt; 200000)
6http://tinkerpop.apache.org/gremlin.html
7http://phuzzy.link/query/documentation</p>
      <p>Listing 2 The equivalent SPARQL query to the graph pattern shown in Listing 1.</p>
      <p>To illustrate how such an RDF query engine compares to a traditional triplestore,
the query shown in Listing 1 yielded 45 results from a dataset consisting of 4.15 million
triples (all things of type dbo:City) in 329ms on a modern laptop while consuming
421M iB in memory, shown in Figure 1, compared to the 45 results obtained in 365ms
on a cold, local Fuseki instance with the exact same dataset while consuming 2:43GiB
in memory. The most likely explanation for why we see comparable performance and
a smaller memory footprint out of our browser-based query engine, and the reason that
such comparisons are not fair to draw conclusions from, could be due to the fact that
our system operates on a read-only snapshot of an efficiently packed dataset file with
pre-built indexes. Nonetheless, the comparable query result times are a good indication
that browser-based query engines may indeed have the strength to compete with distant
endpoints where clients would normally be confronted by network latency, network
throughput, and server-side resource limitations.</p>
      <p>As these tools are still under active research and development, we are not yet ready
to publish an evaluation of this work. However, we hope to demonstrate the potential
implications that the associated methods have. The source code is made available under
the development branch on GitHub8.
4</p>
    </sec>
    <sec id="sec-3">
      <title>Closing Remarks</title>
      <p>In this work, we took steps towards decentralizing the Semantic Web from entirely
within the browser. We combined the concepts of intelligent clients with peer-to-peer
communication to create intelligent peers. We introduced our RDF query engine that
operates on binary serializations of RDF in an effort to compete with the round trip
times it takes distant endpoints to process and return query results to the client. We hope
to continue our research in this direction so that datasets persisting in a decentralized
architecture can come to fruition within the browser and so that they may be used and
queried by data consumers offline.
8https://github.com/blake-regalia/graphy.js/tree/development
13. Verborgh, R., Vander Sande, M., Hartig, O., Van Herwegen, J., De Vocht, L., De Meester,
B., Haesendonck, G., Colpaert, P.: Triple pattern fragments: A low-cost knowledge graph
interface for the web. Web Semantics: Science, Services and Agents on the World Wide Web
37, 184–206 (2016)</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Arumugam</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sheth</surname>
            ,
            <given-names>A.P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Arpinar</surname>
            ,
            <given-names>I.B.</given-names>
          </string-name>
          :
          <article-title>Towards peer-to-peer semantic web: A distributed environment for sharing semantic knowledge on the web (</article-title>
          <year>2002</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Cai</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Frank</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Rdfpeers: a scalable distributed rdf repository based on a structured peerto-peer network</article-title>
          .
          <source>In: Proceedings of the 13th international conference on World Wide Web</source>
          , pp.
          <fpage>650</fpage>
          -
          <lpage>657</lpage>
          . ACM (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Cai</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Frank</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yan</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>MacGregor</surname>
          </string-name>
          , R.:
          <article-title>A subscribable peer-to-peer rdf repository for distributed metadata management</article-title>
          .
          <source>Web Semantics: Science, Services and Agents on the World Wide Web</source>
          <volume>2</volume>
          (
          <issue>2</issue>
          ),
          <fpage>109</fpage>
          -
          <lpage>130</lpage>
          (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Dimartino</surname>
            ,
            <given-names>M.M.</given-names>
          </string-name>
          , Cal`ı,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Poulovassilis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Wood</surname>
          </string-name>
          , P.T.:
          <article-title>Peer-to-peer semantic integration of linked data</article-title>
          .
          <source>In: CEUR Workshop Proceedings</source>
          , vol.
          <volume>1330</volume>
          , pp.
          <fpage>213</fpage>
          -
          <lpage>220</lpage>
          . CEUR Workshop Proceedings (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5. Ferna´ndez, J.D.,
          <article-title>Mart´ınez-</article-title>
          <string-name>
            <surname>Prieto</surname>
            ,
            <given-names>M.A.</given-names>
          </string-name>
          , Gutie´rrez,
          <string-name>
            <given-names>C.</given-names>
            ,
            <surname>Polleres</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Arias</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          :
          <article-title>Binary rdf representation for publication and exchange (hdt)</article-title>
          .
          <source>Web Semantics: Science, Services and Agents on the World Wide Web</source>
          <volume>19</volume>
          ,
          <fpage>22</fpage>
          -
          <lpage>41</lpage>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. Herna´ndez,
          <string-name>
            <surname>A.G.</surname>
          </string-name>
          , GARCıA,
          <string-name>
            <surname>M.:</surname>
          </string-name>
          <article-title>A javascript rdf store and application library for linked data client applications</article-title>
          . In:
          <article-title>Devtracks of the, WWW2012, conference</article-title>
          . Lyon, France (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Kun</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xiao-Ling</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ao-Ying</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          :
          <article-title>Underlying techniques for web services: A survey</article-title>
          .
          <source>In: Journal of software. Citeseer</source>
          (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Maccioni</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Collina</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Graph databases in the browser: using levelgraph to explore new delhi</article-title>
          .
          <source>Proceedings of the VLDB Endowment</source>
          <volume>9</volume>
          (
          <issue>13</issue>
          ),
          <fpage>1469</fpage>
          -
          <lpage>1472</lpage>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Mart</surname>
          </string-name>
          <article-title>´ınez-</article-title>
          <string-name>
            <surname>Prieto</surname>
            ,
            <given-names>M.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gallego</surname>
            ,
            <given-names>M.A.</given-names>
          </string-name>
          , Ferna´ndez, J.D.:
          <article-title>Exchange and consumption of huge rdf data</article-title>
          .
          <source>In: Extended Semantic Web Conference</source>
          , pp.
          <fpage>437</fpage>
          -
          <lpage>452</lpage>
          . Springer (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Staab</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stuckenschmidt</surname>
          </string-name>
          , H.:
          <article-title>Semantic Web and Peer-to-peer: decentralized management and exchange of knowledge and information</article-title>
          . Springer (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Uchida</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Swick</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sambra</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>The web browser personalization with the client side triplestore</article-title>
          .
          <source>In: International Semantic Web Conference</source>
          , pp.
          <fpage>470</fpage>
          -
          <lpage>485</lpage>
          . Springer (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Verborgh</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Vander</given-names>
            <surname>Sande</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Colpaert</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            ,
            <surname>Coppens</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            ,
            <surname>Mannens</surname>
          </string-name>
          , E., Van de Walle, R.:
          <article-title>Web-scale querying through linked data fragments</article-title>
          .
          <source>In: LDOW</source>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>