Skip to content

Commit

Permalink
Update result data format (#254)
Browse files Browse the repository at this point in the history
* Fix result datatypes

* Rename method

* Update iguana.owl

* Remove unused properties

* Add missing relations

* Properly add query ids to the result data

* Remove unused properties

* Fix tests

* Fix ontology

* Exchange intersection with unions

* Add disjoints

* Fix more things

* Generate schema file with protege

* Save as OWL/XML file

* Change ontology name

* Switch from xsd:dayTimeDuration to xsd:duration

* Change file extension

* Remove unused prefixes
  • Loading branch information
nck-mlcnv authored Jul 26, 2024
1 parent f85fe77 commit 695e5e1
Show file tree
Hide file tree
Showing 26 changed files with 1,708 additions and 743 deletions.
449 changes: 0 additions & 449 deletions schema/iguana.owl

This file was deleted.

1,393 changes: 1,393 additions & 0 deletions schema/iguana.owx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import org.aksw.iguana.cc.metrics.Metric;
import org.aksw.iguana.cc.metrics.ModelWritingMetric;
import org.aksw.iguana.cc.worker.HttpWorker;
import org.aksw.iguana.commons.rdf.IONT;
import org.aksw.iguana.commons.rdf.IPROP;
import org.aksw.iguana.commons.rdf.IRES;
import org.aksw.iguana.commons.time.TimeUtils;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.vocabulary.RDF;

import java.math.BigInteger;
import java.util.List;
Expand All @@ -31,6 +33,7 @@ public Model createMetricModel(List<HttpWorker> workers, List<HttpWorker.Executi
for (HttpWorker.ExecutionStats exec : data[(int) worker.getWorkerID()][i]) {
Resource runRes = iresFactory.getWorkerQueryRunResource(worker, i, run);
m.add(workerQueryResource, IPROP.queryExecution, runRes);
m.add(runRes, RDF.type, IONT.queryExecution);
m.add(runRes, IPROP.time, TimeUtils.createTypedDurationLiteral(exec.duration()));
m.add(runRes, IPROP.startTime, TimeUtils.createTypedInstantLiteral(exec.startTime()));
m.add(runRes, IPROP.success, ResourceFactory.createTypedLiteral(exec.successful()));
Expand All @@ -41,12 +44,13 @@ public Model createMetricModel(List<HttpWorker> workers, List<HttpWorker.Executi
if (exec.responseBodyHash().isPresent()) {
Resource responseBodyRes = IRES.getResponsebodyResource(exec.responseBodyHash().getAsLong());
m.add(runRes, IPROP.responseBody, responseBodyRes);
m.add(responseBodyRes, RDF.type, IONT.responseBody);
m.add(responseBodyRes, IPROP.responseBodyHash, ResourceFactory.createTypedLiteral(exec.responseBodyHash().getAsLong()));
}
if (exec.error().isPresent())
m.add(runRes, IPROP.exception, ResourceFactory.createTypedLiteral(exec.error().get().toString()));
if (exec.httpStatusCode().isPresent())
m.add(runRes, IPROP.httpCode, ResourceFactory.createTypedLiteral(exec.httpStatusCode().get().toString()));
m.add(runRes, IPROP.httpCode, ResourceFactory.createTypedLiteral(exec.httpStatusCode().get()));
run = run.add(BigInteger.ONE);
}
}
Expand Down
23 changes: 18 additions & 5 deletions src/main/java/org/aksw/iguana/cc/storage/impl/CSVStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void storeResult(Model data) {
try {
Path file = createCSVFile("query", "summary", "worker", workerID);
Path file2 = createCSVFile("each", "execution", "worker", workerID);
storeSummarizedQueryResults(workerRes, file, data, this.metrics);
storeSummarizedQueryResults(workerRes, file, data, this.metrics, false);
storeEachQueryResults(workerRes, file2, data, this.metrics);
} catch (IOException e) {
LOGGER.error("Error while storing the query results of a worker in a csv file.", e);
Expand All @@ -178,7 +178,7 @@ public void storeResult(Model data) {

try {
Path file = createCSVFile("query", "summary", "task");
storeSummarizedQueryResults(taskRes, file, data, this.metrics);
storeSummarizedQueryResults(taskRes, file, data, this.metrics, true);
} catch (IOException e) {
LOGGER.error("Error while storing the query results of a task result in a csv file.", e);
} catch (NoSuchElementException e) {
Expand Down Expand Up @@ -287,13 +287,24 @@ private Path createCSVFile(String... nameValues) throws IOException {
return file;
}

private static void storeSummarizedQueryResults(Resource parentRes, Path file, Model data, List<Metric> metrics) throws IOException, NoSuchElementException {
/**
* Store the summarized query results for the given rdf resource into a CSV file.
*
* @param parentRes the parent resource inside the model that contains the query results
* @param file the file where the results should be stored
* @param data the model that contains the data
* @param metrics the metrics that should be stored
* @param summarizeForTask if true, the query results will be summarized for a task, therefore, for each query
* its full ID will be used (otherwise the query ids could clash with each other)
*/
private static void storeSummarizedQueryResults(Resource parentRes, Path file, Model data, List<Metric> metrics, boolean summarizeForTask) throws IOException, NoSuchElementException {
boolean containsAggrStats = !metrics.stream().filter(AggregatedExecutionStatistics.class::isInstance).toList().isEmpty();
Metric[] queryMetrics = metrics.stream().filter(x -> QueryMetric.class.isAssignableFrom(x.getClass())).toArray(Metric[]::new);

SelectBuilder sb = new SelectBuilder();
sb.addWhere(parentRes, IPROP.query, "?eQ");
queryProperties(sb, "?eQ", IPROP.queryID);
sb.addWhere("?eQ", IPROP.queryID, "?query");
sb.addVar("queryID").addWhere("?query", summarizeForTask ? IPROP.fullID : IPROP.id, "?queryID");
if (containsAggrStats) {
queryProperties(sb, "?eQ", IPROP.succeeded, IPROP.failed, IPROP.totalTime, IPROP.resultSize, IPROP.wrongCodes, IPROP.timeOuts, IPROP.unknownException);
}
Expand All @@ -314,7 +325,9 @@ private static void storeEachQueryResults(Resource parentRes, Path file, Model d
.addOptional(new WhereBuilder().addWhere("?exec", IPROP.responseBody, "?rb").addWhere("?rb", IPROP.responseBodyHash, "?responseBodyHash"))
.addOptional(new WhereBuilder().addWhere("?exec", IPROP.exception, "?exception"))
.addOptional(new WhereBuilder().addWhere("?exec", IPROP.httpCode, "?httpCode"));
queryProperties(sb, "?exec", IPROP.queryID, IPROP.run, IPROP.success, IPROP.startTime, IPROP.time, IPROP.resultSize, IPROP.code);
sb.addWhere("?eQ", IPROP.queryID, "?query");
sb.addVar("queryID").addWhere("?query", IPROP.id, "?queryID");
queryProperties(sb, "?exec", IPROP.run, IPROP.success, IPROP.startTime, IPROP.time, IPROP.resultSize, IPROP.code);
sb.addVar("httpCode").addVar("exception").addVar("responseBodyHash");
executeAndStoreQuery(sb, file, data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.RDFS;

import java.math.BigInteger;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.function.Supplier;
Expand Down Expand Up @@ -109,7 +110,7 @@ public void calculateAndSaveMetrics(Calendar start, Calendar end) {
m.add(suiteRes, IPROP.task, taskRes);
m.add(taskRes, RDF.type, IONT.task);
m.add(taskRes, RDF.type, IONT.stresstest);
m.add(taskRes, IPROP.noOfWorkers, ResourceFactory.createTypedLiteral(workers.size()));
m.add(taskRes, IPROP.noOfWorkers, toInfinitePrecisionIntegerLiteral(workers.size()));

for (HttpWorker worker : workers) {
HttpWorker.Config config = worker.config();
Expand All @@ -125,12 +126,12 @@ public void calculateAndSaveMetrics(Calendar start, Calendar end) {

m.add(taskRes, IPROP.workerResult, workerRes);
m.add(workerRes, RDF.type, IONT.worker);
m.add(workerRes, IPROP.workerID, ResourceFactory.createTypedLiteral(worker.getWorkerID()));
m.add(workerRes, IPROP.workerID, toInfinitePrecisionIntegerLiteral(worker.getWorkerID()));
m.add(workerRes, IPROP.workerType, ResourceFactory.createTypedLiteral(worker.getClass().getSimpleName()));
m.add(workerRes, IPROP.noOfQueries, ResourceFactory.createTypedLiteral(config.queries().getQueryCount()));
m.add(workerRes, IPROP.noOfQueries, toInfinitePrecisionIntegerLiteral(config.queries().getQueryCount()));
m.add(workerRes, IPROP.timeOut, TimeUtils.createTypedDurationLiteral(config.timeout()));
if (config.completionTarget() instanceof HttpWorker.QueryMixes)
m.add(workerRes, IPROP.noOfQueryMixes, ResourceFactory.createTypedLiteral(((HttpWorker.QueryMixes) config.completionTarget()).number()));
m.add(workerRes, IPROP.noOfQueryMixes, toInfinitePrecisionIntegerLiteral(((HttpWorker.QueryMixes) config.completionTarget()).number()));
if (config.completionTarget() instanceof HttpWorker.TimeLimit)
m.add(workerRes, IPROP.timeLimit, TimeUtils.createTypedDurationLiteral(((HttpWorker.TimeLimit) config.completionTarget()).duration()));
m.add(workerRes, IPROP.connection, connectionRes);
Expand All @@ -142,6 +143,14 @@ public void calculateAndSaveMetrics(Calendar start, Calendar end) {
}
}

// Create Query nodes with their respective queryIDs
for (String queryID : queryIDs) {
Resource queryRes = IRES.getResource(queryID);
m.add(queryRes, RDF.type, IONT.query);
m.add(queryRes, IPROP.fullID, ResourceFactory.createTypedLiteral(queryID));
m.add(queryRes, IPROP.id, ResourceFactory.createTypedLiteral(BigInteger.valueOf(Long.parseLong(queryID.split(":")[1]))));
}

// Connect task and workers to the Query nodes, that store the triple stats.
for (var worker : workers) {
var config = worker.config();
Expand Down Expand Up @@ -277,4 +286,8 @@ private Model createMetricModel(Metric metric) {

return m;
}

private static Literal toInfinitePrecisionIntegerLiteral(long value) {
return ResourceFactory.createTypedLiteral(BigInteger.valueOf(value));
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/aksw/iguana/commons/rdf/IONT.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public class IONT {
public static final Resource stresstest = ResourceFactory.createResource(NS + "Stresstest");
public static final Resource worker = ResourceFactory.createResource(NS + "Worker");
public static final Resource executedQuery = ResourceFactory.createResource(NS + "ExecutedQuery");
public static final Resource queryExecution = ResourceFactory.createResource(NS + "QueryExecution");
public static final Resource responseBody = ResourceFactory.createResource(NS + "ResponseBody");
public static final Resource query = ResourceFactory.createResource(NS + "Query");
public static final Resource metric = ResourceFactory.createResource(NS + "Metric");

public static Resource getMetricClass(Metric metric) {
// TODO: compare with stresstest class (stresstest class as a subclass of Task is iont:Stresstest while QPS for example is iont:metric/QPS)
return ResourceFactory.createResource(NS + "metric/" + metric.getAbbreviation());
}
}
14 changes: 2 additions & 12 deletions src/main/java/org/aksw/iguana/commons/rdf/IPROP.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,16 @@ public static Property createMetricProperty(Metric metric) {
public static final Property variable = ResourceFactory.createProperty(NS, "variable");
public static final Property exception = ResourceFactory.createProperty(NS, "exception");

// SPARQL query properties
public static final Property aggregations = ResourceFactory.createProperty(NS, "aggregations");
public static final Property filter = ResourceFactory.createProperty(NS, "filter");
public static final Property groupBy = ResourceFactory.createProperty(NS, "groupBy");
public static final Property having = ResourceFactory.createProperty(NS, "having");
public static final Property offset = ResourceFactory.createProperty(NS, "offset");
public static final Property optional = ResourceFactory.createProperty(NS, "optional");
public static final Property orderBy = ResourceFactory.createProperty(NS, "orderBy");
public static final Property triples = ResourceFactory.createProperty(NS, "triples");
public static final Property union = ResourceFactory.createProperty(NS, "union");

// Query Stats
public static final Property failed = ResourceFactory.createProperty(NS, "failed");
public static final Property penalizedQPS = ResourceFactory.createProperty(NS, "penalizedQPS");
public static final Property QPS = ResourceFactory.createProperty(NS, "QPS");
public static final Property queryExecution = ResourceFactory.createProperty(NS, "queryExecution");
public static final Property timeOuts = ResourceFactory.createProperty(NS, "timeOuts");
public static final Property totalTime = ResourceFactory.createProperty(NS, "totalTime");
public static final Property unknownException = ResourceFactory.createProperty(NS, "unknownException");
public static final Property wrongCodes = ResourceFactory.createProperty(NS, "wrongCodes");
public static final Property fullID = ResourceFactory.createProperty(NS, "fullID");
public static final Property id = ResourceFactory.createProperty(NS, "id");

// Each Query Stats
public static final Property code = ResourceFactory.createProperty(NS, "code");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public String getLexicalForm() {

@Override
public String getURI() {
return XSD.getURI() + "dayTimeDuration";
return XSD.getURI() + "duration";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
queryID,run,success,startTime,time,resultSize,code,httpCode,exception,responseBodyHash
http://iguana-benchmark.eu/resource/MockQueryHandler0:6,1,true,2023-10-21T20:48:25.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:6,3,false,2023-10-21T20:48:27.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:6,2,false,2023-10-21T20:48:26.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:3,3,false,2023-10-21T20:48:18.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:3,1,true,2023-10-21T20:48:16.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:3,2,false,2023-10-21T20:48:17.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:4,3,false,2023-10-21T20:48:21.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:4,1,true,2023-10-21T20:48:19.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:4,2,false,2023-10-21T20:48:20.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:9,3,false,2023-10-21T20:48:36.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:9,2,false,2023-10-21T20:48:35.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:9,1,true,2023-10-21T20:48:34.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:7,3,false,2023-10-21T20:48:30.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:7,2,false,2023-10-21T20:48:29.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:7,1,true,2023-10-21T20:48:28.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:1,3,false,2023-10-21T20:48:12.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:1,2,false,2023-10-21T20:48:11.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:1,1,true,2023-10-21T20:48:10.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:8,1,true,2023-10-21T20:48:31.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:8,2,false,2023-10-21T20:48:32.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:8,3,false,2023-10-21T20:48:33.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:2,1,true,2023-10-21T20:48:13.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:2,3,false,2023-10-21T20:48:15.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:2,2,false,2023-10-21T20:48:14.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:0,3,false,2023-10-21T20:48:09.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
http://iguana-benchmark.eu/resource/MockQueryHandler0:0,2,false,2023-10-21T20:48:08.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:0,1,true,2023-10-21T20:48:07.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:5,1,true,2023-10-21T20:48:22.399Z,PT2S,1000,0,200,,123
http://iguana-benchmark.eu/resource/MockQueryHandler0:5,2,false,2023-10-21T20:48:23.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
http://iguana-benchmark.eu/resource/MockQueryHandler0:5,3,false,2023-10-21T20:48:24.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
6,1,true,2023-10-21T20:48:25.399Z,PT2S,1000,0,200,,123
6,3,false,2023-10-21T20:48:27.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
6,2,false,2023-10-21T20:48:26.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
3,3,false,2023-10-21T20:48:18.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
3,1,true,2023-10-21T20:48:16.399Z,PT2S,1000,0,200,,123
3,2,false,2023-10-21T20:48:17.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
4,3,false,2023-10-21T20:48:21.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
4,1,true,2023-10-21T20:48:19.399Z,PT2S,1000,0,200,,123
4,2,false,2023-10-21T20:48:20.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
9,3,false,2023-10-21T20:48:36.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
9,2,false,2023-10-21T20:48:35.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
9,1,true,2023-10-21T20:48:34.399Z,PT2S,1000,0,200,,123
7,3,false,2023-10-21T20:48:30.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
7,2,false,2023-10-21T20:48:29.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
7,1,true,2023-10-21T20:48:28.399Z,PT2S,1000,0,200,,123
1,3,false,2023-10-21T20:48:12.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
1,2,false,2023-10-21T20:48:11.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
1,1,true,2023-10-21T20:48:10.399Z,PT2S,1000,0,200,,123
8,1,true,2023-10-21T20:48:31.399Z,PT2S,1000,0,200,,123
8,2,false,2023-10-21T20:48:32.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
8,3,false,2023-10-21T20:48:33.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
2,1,true,2023-10-21T20:48:13.399Z,PT2S,1000,0,200,,123
2,3,false,2023-10-21T20:48:15.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
2,2,false,2023-10-21T20:48:14.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
0,3,false,2023-10-21T20:48:09.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
0,2,false,2023-10-21T20:48:08.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
0,1,true,2023-10-21T20:48:07.399Z,PT2S,1000,0,200,,123
5,1,true,2023-10-21T20:48:22.399Z,PT2S,1000,0,200,,123
5,2,false,2023-10-21T20:48:23.399Z,PT0.5S,-1,111,404,java.lang.Exception: httperror,
5,3,false,2023-10-21T20:48:24.399Z,PT5S,-1,1,200,java.lang.Exception: io_exception,456
Loading

0 comments on commit 695e5e1

Please sign in to comment.