<!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>Change data capture of large-scale RDF data</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>MSD Czech Republic s.r.o.</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Svornosti</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Prague</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Czech Republic</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>name.surname}@merck.com</string-name>
        </contrib>
      </contrib-group>
      <fpage>2</fpage>
      <lpage>6</lpage>
      <abstract>
        <p>We designed and implemented a method for change data capture tracking large-scale RDF datasets that change in time. The method allows efficient offline reconstruction of a view of data valid at a given time from a backlog of explicit change events. It operates on a temporal data model based on RDF and named graphs. It is built with semantic web standards and implemented via SPARQL 1.1 Update. We provide an efficient open-source implementation of the method in Halyard Bulk Update, a MapReduce application for the Halyard RDF store. This implementation allows to synchronize data via change data capture in a horizontally-scalable cluster on commodity hardware. We demonstrate the method on PUBMED, a public dataset aggregating rich metadata on biomedical literature.</p>
      </abstract>
      <kwd-group>
        <kwd>change data capture</kwd>
        <kwd>SPARQL Update</kwd>
        <kwd>named graphs</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        We present a method for change data capture (CDC) tracking large-scale RDF
datasets that change in time. CDC covers software design patterns to track and
replicate changes from remote data sources. The method can replay incremental
changes in RDF datasets that are structured according to our proposed temporal
data model. We focus on efficient offline reconstruction of a view of data valid at
a given time from a backlog of explicit change events.
There is an extensive research on versioning RDF and change detection in
knowledge bases. Considering the related work, [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], surveying approaches for
change propagation in RDF, gave us our point of departure. Research on CDC
typically focuses on relational data, such as in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], so it has only a high-level
similarity to our work. An RDF version of PUBMED, which is our use case, was
included in Bio2RDF [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], however, it supported only loading in bulk.
      </p>
    </sec>
    <sec id="sec-2">
      <title>Data model</title>
      <p>
        We propose a CDC data model that is based on named graphs [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. The model
represents changes as ordered sets of Snapshots of Targets. What is a Target
depends on the granularity of Snapshots in the source data. In general, target is
“a stable logical entity associated with a series of different values over time.” 1 It
can be a single statement, a container of statements, or a whole dataset, so long
it has a unique persistent identifier, such as an IRI. Snapshot is a named graph
that represents the state of a Target at some time. Snapshots are described by
Change Events. Change Event has a Target, a timestamp, and a Snapshot to
insert, or a Snapshot to delete, or both. Change Events to be replayed in a single
synchronization run are stored in a Metadata Graph, a named graph with a
known IRI. The combination of Metadata Graphs and Snapshots forms Backlog.
This model is formalized as a small RDF vocabulary (Fig. 1).
In order to produce a view of a dataset valid at a given date, we replay Backlog’s
Change Events the timestamp of which precedes the date. For example, we replay
all Change Events to get the current view. We keep the replayed Change Events
to enable tracing the origin of changes and reconstructing past versions of the
dataset. To replay Backlog, we filter Change Events preceding a given timestamp,
order them by timestamp, and for each Change Event delete the triples from its
delete graph, and insert the triples from its insert graph. Deletions are run prior
to insertions to avoid retaining their intersections. Snapshot to delete need not
be explicit, it may be inferred to be the Snapshot to insert of the immediately
preceding Change Event for the same Target.
      </p>
      <sec id="sec-2-1">
        <title>1 https://clojure.org/about/state#_working_models_and_identity</title>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Method implementation</title>
      <p>
        We implemented the method as an extension of Halyard [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], a
horizontallyscalable RDF store based on Apache HBase and Eclipse RDF4J. In order to
replay Backlog efficiently we extended Halyard Bulk Update2, a MapReduce
tool that executes SPARQL Update [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] operations in parallel. The SPARQL 1.1
Update specification defines updates via set operations. Query solutions to delete
or insert are first collected, deletes are removed via set difference, and inserts
are added via set union. Consequently, the order of deletes and inserts within an
update operation is left undefined. Order can be expressed at the level of update
operations by the sequence they appear in an update request. To replay Change
Events ordered by timestamp a compliant SPARQL Update engine thus needs a
separate update operation for each Change Event.
      </p>
      <p>Since Halyard Bulk Update diverges from the specification, it can replay
Change Events in a single update operation. It applies deletes and inserts
in the order the query pattern from the WHERE clause produces them,
allowing streaming execution. The order can be overridden by the predefined
?HALYARD_TIMESTAMP_SPECIAL_VARIABLE, which we bind to Change Events’
timestamps when replaying Backlog. Explicit timestamps allow to decouple the
order the update operations are applied from the order they are read. Halyard
Bulk Update accepts timestamps bound to any data type that can be cast to
xsd:long, so that both numeric data types and dates that can be represented as
Unix time work.</p>
      <p>Halyard Bulk Update allows update operations to specify how many
concurrent forks they can be split into via the custom SPARQL function
halyard:forkAndFilterBy(). The function’s arguments specify the number of
forks and one or more variables. Data to update is partitioned by the chosen
variables’ bindings among the forks. The example 1.1 shows an update operation
to replay Backlog described by the :metadata Metadata Graph by using 30
forks. Halyard Bulk Update generates the changes for HBase in the Map phase,
sorts and groups the changes in the Reduce phase, and applies them in bulk
during asynchronous database compaction. The parallel replay of Backlog is
deterministic when timestamps of Change Events are distinct. When Change
Events of multiple Targets share the same timestamp, the Targets must be
disjoint for the replay to be deterministic. Each update operation is run as a
transaction with read committed isolation to avoid conflicts.
6</p>
    </sec>
    <sec id="sec-4">
      <title>Change data capture for PUBMED</title>
      <p>Our primary use case for CDC is PUBMED. PUBMED3 is a dataset maintained
by the National Library of Medicine that aggregates rich metadata on vast</p>
      <sec id="sec-4-1">
        <title>2 https://merck.github.io/Halyard/tools#Halyard_Bulk_Update 3 https://www.ncbi.nlm.nih.gov/pubmed</title>
        <p>Listing 1.1 SPARQL Update operation to replay Backlog
PREFIX : &lt;http://example.com/&gt;
PREFIX halyard: &lt;http://merck.github.io/Halyard/ns#&gt;
PREFIX backlog: &lt;https://data.gin.merck.com/vocabulary/backlog#&gt;
DELETE { ?deleteS ?deleteP ?deleteO . }
INSERT { ?insertS ?insertP ?insertO . }
WHERE {</p>
        <p>GRAPH :metadata {
?change backlog:timestamp ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE .</p>
        <p>FILTER halyard:forkAndFilterBy(30, ?change)
}
{
}
}</p>
        <p>GRAPH :metadata { ?change backlog:insertGraph ?insertGraph . }
GRAPH ?insertGraph { ?insertS ?insertP ?insertO . }
} UNION {</p>
        <p>GRAPH :metadata { ?change backlog:deleteGraph ?deleteGraph . }
GRAPH ?deleteGraph { ?deleteS ?deleteP ?deleteO . }
amounts of biomedical literature. PUBMED data is distributed in XML via an
FTP server. Each year a baseline snapshot of the data is produced and followed
by incremental updates published daily.</p>
        <p>PUBMED represents updates explicitly as versions of articles, so change detection
is not needed. We treat the articles as Targets of Change Events and their versions
as Snapshots. Snapshots for a Target, especially the consecutive ones, may contain
overlapping RDF triples, which can be removed to save storage space. However,
in our case computing the intersections of Snapshots is more expensive than the
extra storage. Articles to delete, specified by the XML element DeleteCitation,
are represented as Change Events with no inserts and the maximum timestamp
for their date, causing their preceding Snapshot to be deleted.</p>
        <p>
          Each day we pull PUBMED updates, transform them to RDF, and replay them.
Since PUBMED is available in XML, we use XSLT to transform it to RDF, as
it is a native XML processing language. As our temporal data model requires
named graphs, we opted for the TriX RDF syntax [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], which is a verbose low-level
data format, but unlike RDF/XML it allows named graphs. As of January 2019,
the current reconciled RDF version of PUBMED we produce contains 2.2 billion
triples, while its backlog amounts to 2.8 billion quads. Using an Amazon Web
Services EMR cluster with 8 i3.2xlarge (8 CPU cores, 60 GB RAM) instances
plus 2 i3.2xlarge instances as task nodes, the complete replay of this dataset
takes 9 hours and costs $30. The incremental daily replay runs in minutes. We
use the RDF version of PUBMED for various tasks, such as custom business
intelligence queries or training text classifiers on abstracts.
7
        </p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Conclusion</title>
      <p>We designed and implemented a standards-based method for CDC of large-scale
RDF datasets. The method is implemented by a SPARQL Update operation run
by Halyard Bulk Update, a MapReduce application for the Halyard RDF store.
Its implementation can replay large datasets, such as PUBMED with billions of
RDF triples, in a horizontally-scalable cluster with commodity hardware. A future
work to consider is how to make post-processing data, such as deduplication of
PUBMED authors, work with the proposed temporal data model.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Seaborne</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Davis</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>Supporting change propagation in RDF</article-title>
          .
          <source>In: Proceedings of the W3C</source>
          workshop
          <article-title>- RDF next steps</article-title>
          ., Palo Alto, CA, USA (
          <year>2010</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Das</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Botev</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Surlaker</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ghosh</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Varadarajan</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Nagaraj</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhang</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gao</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Westerman</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ganti</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Shkolnik</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Topiwala</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pachev</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Somasundaram</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Subramaniam</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>All aboard the databus!: Linkedin's scalable consistent change data capture platform</article-title>
          .
          <source>In: Proceedings of the third ACM symposium on cloud computing</source>
          . pp.
          <volume>18</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>18</lpage>
          :
          <fpage>14</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          , New York, NY, USA (
          <year>2012</year>
          ). https://doi.org/10.1145/2391229.2391247.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Belleau</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Nolin</surname>
            , M.-
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tourigny</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rigault</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Morissette</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>Bio2iRDF: Towards a mashup to build bioinformatics knowledge systems</article-title>
          .
          <source>Journal of Biomedical Informatics</source>
          .
          <volume>41</volume>
          ,
          <fpage>706</fpage>
          -
          <lpage>716</lpage>
          (
          <year>2008</year>
          ). https://doi.org/https://doi.org/10.1016/j. jbi.
          <year>2008</year>
          .
          <volume>03</volume>
          .004.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Carroll</surname>
            ,
            <given-names>J.J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bizer</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hayes</surname>
            ,
            <given-names>P.J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stickler</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Named graphs, provenance and trust</article-title>
          .
          <source>In: Proceedings of the 14th international conference on world wide web</source>
          . pp.
          <fpage>613</fpage>
          -
          <lpage>622</lpage>
          ., Chiba, Japan (
          <year>2005</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Sotona</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Negru</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>How to feed Apache HBase with petabytes of RDF data: An extremely scalable RDF store based on Eclipse RDF4J</article-title>
          . In: Kawamura,
          <string-name>
            <given-names>T.</given-names>
            and
            <surname>Paulheim</surname>
          </string-name>
          , H. (eds.)
          <article-title>Proceedings of the ISWC 2016 posters &amp; demonstrations track</article-title>
          .,
          <string-name>
            <surname>Kobe</surname>
          </string-name>
          , Japan (
          <year>2016</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Gearon</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Passant</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Polleres</surname>
          </string-name>
          , A. eds
          <source>: SPARQL 1.1 update</source>
          . (
          <year>2013</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Carroll</surname>
            ,
            <given-names>J.J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stickler</surname>
            ,
            <given-names>P.:</given-names>
          </string-name>
          <article-title>TriX: RDF triples in XML. Hewlett-Packard (</article-title>
          <year>2004</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>