<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:space="preserve" xmlns="http://www.tei-c.org/ns/1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.tei-c.org/ns/1.0 https://raw.githubusercontent.com/kermitt2/grobid/master/grobid-home/schemas/xsd/Grobid.xsd"
 xmlns:xlink="http://www.w3.org/1999/xlink">
	<teiHeader xml:lang="en">
		<fileDesc>
			<titleStmt>
				<title level="a" type="main">Triple Pattern Join Cardinality Estimations over HDT with Enhanced Metadata</title>
			</titleStmt>
			<publicationStmt>
				<publisher/>
				<availability status="unknown"><licence/></availability>
			</publicationStmt>
			<sourceDesc>
				<biblStruct>
					<analytic>
						<author>
							<persName><forename type="first">Elena</forename><surname>Wössner</surname></persName>
							<affiliation key="aff0">
								<orgName type="department">Institute AIFB</orgName>
								<orgName type="institution">Karlsruhe Institute of Technology (KIT)</orgName>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Chang</forename><surname>Qin</surname></persName>
							<affiliation key="aff0">
								<orgName type="department">Institute AIFB</orgName>
								<orgName type="institution">Karlsruhe Institute of Technology (KIT)</orgName>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Javier</forename><forename type="middle">D</forename><surname>Fernández</surname></persName>
							<affiliation key="aff1">
								<orgName type="institution">Vienna University of Economics and Business</orgName>
							</affiliation>
							<affiliation key="aff2">
								<orgName type="department">Complexity Science Hub</orgName>
								<address>
									<settlement>Vienna</settlement>
								</address>
							</affiliation>
						</author>
						<author role="corresp">
							<persName><forename type="first">Maribel</forename><surname>Acosta</surname></persName>
							<email>maribel.acosta@kit.edu</email>
							<affiliation key="aff0">
								<orgName type="department">Institute AIFB</orgName>
								<orgName type="institution">Karlsruhe Institute of Technology (KIT)</orgName>
							</affiliation>
						</author>
						<title level="a" type="main">Triple Pattern Join Cardinality Estimations over HDT with Enhanced Metadata</title>
					</analytic>
					<monogr>
						<imprint>
							<date/>
						</imprint>
					</monogr>
					<idno type="MD5">F2AA9925A7D2C7E72149DD0B621192F9</idno>
				</biblStruct>
			</sourceDesc>
		</fileDesc>
		<encodingDesc>
			<appInfo>
				<application version="0.7.2" ident="GROBID" when="2023-03-19T15:52+0000">
					<desc>GROBID - A machine learning software for extracting information from scholarly documents</desc>
					<ref target="https://github.com/kermitt2/grobid"/>
				</application>
			</appInfo>
		</encodingDesc>
		<profileDesc>
			<abstract>
<div xmlns="http://www.tei-c.org/ns/1.0"><p>In this work, we present hdt-stats, an extension to the hdt operations, to compute further metadata when evaluating triple patterns over RDF graphs represented with hdt. Then, we propose a novel model that relies on the hdt-stats metadata, as well as the distinct position of SPARQL variables, to estimate the cardinality of joins between triple patterns. Our preliminary results suggest that our approach produces more accurate cardinality estimations than existing solutions.</p></div>
			</abstract>
		</profileDesc>
	</teiHeader>
	<text xml:lang="en">
		<body>
<div xmlns="http://www.tei-c.org/ns/1.0"><p>hdt (Header, Dictionary, Triples) <ref type="bibr" target="#b1">[2]</ref> is a compact serialization format for RDF graphs. hdt supports triple-pattern-based querying and provides metadata about the estimated number of matched RDF triples. Therefore, the execution of SPARQL queries over hdt requires the combination of the results of evaluating individual triple patterns. Current query engines against interfaces over hdt (e.g., nLDE <ref type="bibr" target="#b0">[1]</ref>) implement optimization techniques that rely on simple cardinality estimations to devise query plans that reduce execution time. However, the cardinality estimation of join operators with insufficient metadata is rather challenging and, in most cases, may lead to inefficient query plans. To assist query engines in devising more effective query plans, in this work, we propose hdtstats, a novel interface that enhances the metadata provided by hdt. Besides cardinality estimations for triple patterns, our approach provides the number of distinct subjects, predicates, and objects in result sets. Then, we propose a novel model for estimating the cardinality of joins of triple patterns, based on the available metadata provided by hdt-stats. This work covers the estimation of the cardinality of subject-subject, object-object, and subject-object joins. In contrast to state-of-the-art cost models for SPARQL query optimization, e.g., CostFed <ref type="bibr" target="#b2">[3]</ref>, our approach combines the hdt-stats metadata in a novel way that produces more accurate estimates. To evaluate our solution, we conducted an empirical study using 287 joins between triple patterns over DBpedia.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1">Evaluation of Triple Patterns with HDT-STATS</head><p>hdt supports rank and select operations <ref type="bibr" target="#b1">[2]</ref>, which allow for accessing triples in the compressed RDF graph. With these operations, hdt is able to evaluate triple patterns and compute cardinality estimates of the number of triples that belong the solution. In this work, we propose hdt-stats, an interface to support the retrieval of further metadata about the evaluation of triple patterns over hdt data structures. Formally, the evaluation of a triple pattern over an HDT graph using the hdt-stats is defined as follows. hdt-stats is able to compute the metadata (ds, dp, do) efficiently, as it relies on light-weight extensions to the hdt operations. This metadata is then exploited by the the cardinality estimation model for joins between triple patterns.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">Cardinality Estimation Model</head><p>One of the key components in cost-based query optimization techniques is the estimation of the number of intermediate results produced by the operators in a query plan. In this work, we focus on the estimation of cardinalities when joining triple patterns, i.e., card(tp i tp j ) with tp i and tp j triple patterns. To estimate the cardinality of joins, we propose a light-weight model that considers the novel metadata retrieved with hdt-stats, i.e., distinct subjects, distinct predicates, and distinct objects contained in a result set. Considering this metadata, our proposed model distinguishes between the different types of joins that may occur when joining triple patterns. In this work, we focus on subject-subject, object-object, and subject-object joins. In the following, we propose separate estimations for each join type. Subject-Subject Joins. Subject-subject joins occur when two triple patterns exclusively share a common variable in their subject position. To estimate the cardinality of subject-subject joins, our proposed model considers the number of distinct subjects contained in the solutions of the joined triple patterns. The number of distinct subjects allows for estimating the selectivity of each triple pattern in terms of subjects. In this case, the selectivity of subjects represents the number of times (on average) that an arbitrary subject occurs in the solution of a triple pattern. For example, subject selectivity equals to 1 indicates that every subject occurs exactly one time in the solution set. To calculate such a selectivity, we just divide the number of solutions by the number of distinct subjects. Then, to calculate the cardinality of the join, our model divides the total number of possible answers by the maximum number of distinct subjects, which represents an upper bound on the number of subjects that will match. Based on this, we define our proposed model in the following.</p><p>Given triple patterns tp i = (?x, pi, oi) and tp j = (?x, pj, oj). Assume that (Ψ i , card i , ds i , dp i , do i ) and (Ψ j , card j , ds j , dp j , do j ) are the results of evaluating triple patterns tp i and tp j over a graph G, respectively. The estimated cardinality of performing tp i tp j , denoted card(tp i tp j ), is defined as follows:</p><formula xml:id="formula_0">card(tp i tp j ) = card i • card j max(ds i , ds j )<label>(1)</label></formula><p>Object-Object Joins. Object-object joins occur when two triple patterns exclusively share a common variable in their object position, i.e., tp i = (si, pi, ?x) and tp j = (sj, pj, ?x). Analogous to the subject-subject estimation, we proposed a model that considers the selectivity of objects in the result sets, as follows:</p><formula xml:id="formula_1">card(tp i tp j ) = card i • card j max(do i , do j )<label>(2)</label></formula><p>Subject-Object Joins. Subject-object joins occur when two triple patterns exclusively share a common variable in a subject position in one triple pattern and in object position in the other triple pattern, i.e., tp i = (?x, pi, oi) and tp j = (sj, pj, ?x). Similarly to previous cases, our model considers the number of distinct subjects and the number of distinct objects involved in the join. The maximum number of subjects or objects corresponds to an upper bound on the number of resources that match. The proposed estimation is as follows:</p><formula xml:id="formula_2">card(tp i tp j ) = card i • card i max(ds i , do j )<label>(3)</label></formula></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">Experimental Study</head><p>Dataset and Queries. We used the benchmark queries over DBpedia (v.2015) presented in the work by Acosta and Vidal <ref type="bibr" target="#b0">[1]</ref>. Per query, we generated all possible pairs of triple patterns that share variables in common. This resulted in 287 triple pattern joins, with the following distributions: 255 subject-subject joins, 23 object-object joins, and 9 subject-object joins. Approaches. To measure the effectiveness of our proposed cardinality estimation model, we compare our approach with the model computed by CostFed <ref type="bibr" target="#b2">[3]</ref>.</p><p>Metrics. We report on the absolute error (AE) and the relative error (RE) of the models. AE is the absolute difference between the estimated cardinality and the actual number of answers produced by the join. RE is computed as AE divided by the actual number of answers. In addition, we report on the Pearson correlation coefficient between the estimated and real cardinalities. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">Effectiveness of the Proposed Cardinality Estimations</head><p>In this study, we compare the effectiveness of our proposed cardinality estimation with the model computed by CostFed. CostFed is a SPARQL federated engine that implements a cost model based on cardinality estimations, which relies on similar statistics. Therefore, a direct comparison with our techniques is possible. Table <ref type="table" target="#tab_1">1</ref> reports on the effectiveness of the studied approaches, measured by absolute and relative errors. The results indicate that, on average, our proposed model produces more accurate estimations for all types of joins than the ones implemented by CostFed. In particular, our approach performs best in predicting the cardinalities of object-object joins followed by subject-subject-joins.</p><p>A closer look into the raw results reveals that there is a particular case when both models produce the same estimation: when the selectivity of subjects or objects in a result set is equal to 1. For the other cases, our proposed cost model typically produce estimates smaller than the ones by CostFed. This indicates that even when both models overestimate the cardinality of a join, our prediction is still closer to the real number of answers. This is confirmed by the mean relative errors achieved in all types of joins (cf. Table <ref type="table" target="#tab_1">1</ref>).</p><p>Lastly, our study reveals that both CostFed and our approach produce more accurate estimates for the cardinality of object-object joins than for subjectsubject joins. This could be a result of the topology of the DBpedia graph, where estimating the number of subjects that match the triple patterns drastically change when using different constants in the patterns. Still, as the number of object-object joins in our evaluation is rather low (23 joins), we need to conduct further experiments to derive concrete conclusions about the behavior of the approaches in the object-object case.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">Analysis per Join Type</head><p>In this study, we focus on understanding the behavior of our proposed cardinality estimation model. We compare the estimated cardinality of our approach with the actual number of answers produced by the joins. Figure <ref type="figure" target="#fig_0">1</ref> reports on the actual number of answers vs. the estimated cardinalities by our approach.</p><p>For subject-subject joins, we first realize that a few data points allows our approach to achieve very high correlation. This is the case when joins produce a large number of results and that our model was able to estimate accordingly. To be able to properly analyze the results on the majority of the triple patterns, we focused on the results for joins that produce less than 1M answers (cf. The results for subject-object joins are reported in Figure <ref type="figure" target="#fig_0">1</ref>(c). We observe that the model also tends to overestimate the cardinalities. In this case, the correlation achieved is 0.863. Still, these results are considered preliminary as the benchmark did not have sufficient occurrences of this type of join.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">Conclusions and Future Work</head><p>We have presented hdt-stats to support the retrieval of further metadata during the evaluation of triple patterns over RDF graphs compressed with hdt. Based on this metadata, we propose a novel cardinality estimation model that considers the type of the join between pairs of triple patterns. Our results on over 287 joins indicate that our proposed model outperforms state-of-the-art solutions. For future work, we plan to extend our model to cover further join types and to conduct further experimental studies over other RDF graphs.</p></div><figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_0"><head>Fig. 1 .</head><label>1</label><figDesc>Fig. 1. Behavior of the proposed model per join type. Correlation between the real cardinality (x-axis) and estimated cardinality with our approach (y-axis).</figDesc><graphic coords="5,137.84,115.83,107.20,80.40" type="bitmap" /></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_1"><head></head><label></label><figDesc>Figure 1(a)). In this case, the Pearson correlation achieved is 0.543. Despite the moderate positive correlation, we observe that our model tends to overestimate the cardinality of subject-subject joins over DBpedia.Figure 1(b) reports the results of object-object joins. Despite achieving the lowest errors (AE and RE) in this type of join, our proposed model is still volatile, i.e., there are no clear patterns of under-or over-estimations. This is confirmed by the Pearson correlation coefficient (0.175).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_0"><head>1</head><label></label><figDesc>Given a triple pattern tp, an hdt RDF graph G, the solution of evaluating a tp over G with hdt-stats is a 5-tuple (Ψ, card, ds, dp, do), where:-Ψ : the result set, i.e., the subset of RDF triples in the graph G that match the triple pattern tp, i.e., Ψ = {µ(tp) | dom(µ) = vars(tp) and µ(tp) ∈ G}, card: estimated value for the total number of solutions |Ψ |, ds: estimated number of distinct subjects in Ψ , i.e., |{s | (s, p, o) ∈ Ψ }|, dp: estimated number of distinct predicates in Ψ , i.e., |{p | (s, p, o) ∈ Ψ }|, do: estimated number of distinct objects in Ψ , i.e., |{o | (s, p, o) ∈ Ψ }|.</figDesc><table /></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_1"><head>Table 1 .</head><label>1</label><figDesc>Effectiveness of the proposed model. Mean absolute error (Mean AE) and mean relative error (Mean RE) of cardinality estimations of different join types: subject-subject (S-S), object-object (O-O), subject-object (S-O). (Lower is better).</figDesc><table><row><cell>Metrics</cell><cell cols="2">CostFed Our Model</cell><cell cols="2">CostFed Our Model</cell><cell cols="2">CostFed Our Model</cell></row><row><cell></cell><cell>S-S</cell><cell>S-S</cell><cell>O-O</cell><cell>O-O</cell><cell>S-O</cell><cell>S-O</cell></row><row><cell>Mean AE</cell><cell>1.90E+6</cell><cell>4.82E+4</cell><cell>6.84E+6</cell><cell>4.75E+6</cell><cell>4.28E+4</cell><cell>1.67E+4</cell></row><row><cell>Mean RE</cell><cell>14.01</cell><cell>4.54</cell><cell>11.68</cell><cell>1.65</cell><cell>9.34</cell><cell>7.21</cell></row></table></figure>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0">We assume the terminology of SPARQL query evaluation as in the literature.</note>
		</body>
		<back>
			<div type="references">

				<listBibl>

<biblStruct xml:id="b0">
	<analytic>
		<title level="a" type="main">Networks of linked data eddies: An adaptive web query processing engine for rdf data</title>
		<author>
			<persName><forename type="first">Maribel</forename><surname>Acosta</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Maria-Esther</forename><surname>Vidal</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">ISWC</title>
				<imprint>
			<date type="published" when="2015">2015</date>
			<biblScope unit="page" from="111" to="127" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b1">
	<analytic>
		<title level="a" type="main">Binary RDF representation for publication and exchange (HDT)</title>
		<author>
			<persName><forename type="first">Javier</forename><forename type="middle">D</forename><surname>Fernández</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Miguel</forename><forename type="middle">A</forename><surname>Martínez-Prieto</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Claudio</forename><surname>Gutiérrez</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Axel</forename><surname>Polleres</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Mario</forename><surname>Arias</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">J. Web Semant</title>
		<imprint>
			<biblScope unit="volume">19</biblScope>
			<biblScope unit="page" from="22" to="41" />
			<date type="published" when="2013">2013</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b2">
	<analytic>
		<title level="a" type="main">Costfed: Cost-based query optimization for SPARQL endpoint federation</title>
		<author>
			<persName><forename type="first">Muhammad</forename><surname>Saleem</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Alexander</forename><surname>Potocki</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Tommaso</forename><surname>Soru</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Olaf</forename><surname>Hartig</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Axel-Cyrille Ngonga</forename><surname>Ngomo</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">SEMANTICS</title>
				<imprint>
			<date type="published" when="2018">2018</date>
			<biblScope unit="page" from="163" to="174" />
		</imprint>
	</monogr>
</biblStruct>

				</listBibl>
			</div>
		</back>
	</text>
</TEI>
