Commit 6df34663 authored by akucera's avatar akucera
Browse files

changes to the test bench + update to apache jena 3.2.0

parent d392ad5c
package cz.muni.fi.lasaris.sbms.semantics.logic;
import java.util.LinkedList;
import java.util.List;
import org.apache.jena.graph.NodeFactory;
......@@ -26,7 +25,7 @@ import cz.muni.fi.lasaris.sbms.semantics.api.request.GroupableRequest;
import cz.muni.fi.lasaris.sbms.semantics.api.request.TrendsRequest;
public class BodyBuilders {
/*
private static class TypeClauseContainer {
public String f1;
public String f2;
......@@ -40,7 +39,7 @@ public class BodyBuilders {
this.f4 = f4;
}
}
*/
public static ElementGroup getQueryBody(DataPointsRequest request) {
return getQueryBody(request.getDataPoint(), request);
}
......@@ -48,6 +47,8 @@ public class BodyBuilders {
private static ElementGroup getQueryBody(DataPoint dp, GroupableRequest request) {
ElementGroup body = new ElementGroup();
// https://gregheartsfield.com/2012/08/26/jena-arq-query-performance.html
// type clauses moved to the end of the query as it significantly decreases performance
//List<TypeClauseContainer> tcc = new LinkedList<TypeClauseContainer>();
......
......@@ -142,7 +142,6 @@ public class TdbConnector {
throw new IllegalStateException("Path not set");
}
logger.debug("Opening writable model...");
dataset.close();
dataset.begin(ReadWrite.WRITE);
return dataset.getDefaultModel();
}
......
......@@ -22,37 +22,42 @@ The aim of the benchmarking is to prove that the qeury performance is sufficent
a primary design goal during the development.
The prerequisities to run this benchmark are:
- Apache Jena - the distribution should be downloaded and extracted to the hard drive
- Apache Tomcat 9 - the distribution should be downloaded and extracted to the hard drive. Then, The JAVA_HOME environment variable must be set manually.
- Apache Jena 3.2.0 - the distribution should be downloaded and extracted to the hard drive
- Apache Tomcat 8.5 or higher - the distribution should be downloaded and extracted to the hard drive. Then, The JAVA_HOME environment variable must be set manually.
Usage:
0) If you intend to use the provided pre-generated data or custom dataset, proceed directly to step 3 and use the optional parameter to specify the correct input file.
1) [Optional] Run the script Generate-CSVs.ps1
The script generates CSV files into the CSV-Data folder.
Optional parameters:
-Sites [Default: 5] - number of sites in the dataset
-Buildings [Default: 5] - number of buildings in each site
-Floors [Default: 3] - number of floors in each building
-Rooms [Default: 10] - number of rooms in each floor
Pre-generated CSV files for the default configuration are available in the CSV-Data folder.
-Rooms [Default: 10] - number of rooms in each floor
2) [Optional] Run the script Generate-Triples.ps1
The script generates an N-Triples file into the NT-Data folder, based on the CSV files located in the .\CSV-Data folder.
Pre-generated NT file for the default test mock-up is available in the NT-Data folder.
Optional parameters:
-InFolder [Default: .\CSV-Data] - location of the source CSV files generated by Generate-CSVs script
-OutFile [Default: .\NT-Data\data.nt] - location of the output NT File
The process of Triples generation is universal and can be performed with existing CSV when using real facility data
instead of a generated mock-up created by Generate-CSVs script.
Pre-generated NT file for the test mock-up with the default size is available in the NT-Data folder as sample.nt.
3) Run the script Create-TDB.ps1
The script will create the TDB triplestore using the Apache Jena framework.
Optional parameters (no need to set them if they not differ from the defaults):
Optional parameters:
-TDBPath [Default: \apache-tomcat-9.0.0.M19\webapps\sbms\WEB-INF\tdb] - location of the resulting TDB directory
-NTPath [Default: .\NT-Data\data.nt] - Path to the source NT file
-JenaRoot [Default: \apache-jena-3.2.0] - Path to the directory with the Apache Jena distribution
If you intend to use pre-generated sample dataset, run the command as follows:
Create-TDB.ps1 -NTPath .\NT-Data\sample.nt
Statistics of the TDB can be found in the <Your tdb location>\stats.opt file
Statistics of the TDB can be found in the <Your tdb location>\stats.opt file.
4) Deploy the Semantic API into the Apache Tomcat (see Readme on the project site)
......@@ -71,6 +76,8 @@ Usage:
If you did not start the Apache Tomcat in the previous step, use the -ManageTomcat switch. You can also set the path to
the Apache Tomcat installation directory by the -TomcatHome param (Default is C:\apache-tomcat-9.0.0.M19)
8) [Optional] Stop the Apache Tomcat
Execute the bin\shutdown.bat script if you did not use the -ManageTomcat option and started the server manually in the step 6)
......
NT-Data/
CSV-Data/
test_runs.txt
/NT-Data/data.nt
/CSV-Data/
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
[CmdletBinding()]
Param()
Param(
[String]$InFolder = ".\CSV-Data",
[String]$OutFile = ".\NT-Data\data.nt"
)
.\Nt-Converters\Convert-Sites.ps1 -Csv .\CSV-Data\rooms.csv | Out-File -Encoding utf8 .\NT-Data\data.nt
.\Nt-Converters\Convert-Buildings.ps1 -Csv .\CSV-Data\rooms.csv | Out-File -Append -Encoding utf8 .\NT-Data\data.nt
.\Nt-Converters\Convert-Floors.ps1 -Csv .\CSV-Data\rooms.csv | Out-File -Append -Encoding utf8 .\NT-Data\data.nt
.\Nt-Converters\Convert-Rooms.ps1 -Csv .\CSV-Data\rooms.csv | Out-File -Append -Encoding utf8 .\NT-Data\data.nt
.\Nt-Converters\Convert-Devices.ps1 -Csv .\CSV-Data\devices.csv | Out-File -Append -Encoding utf8 .\NT-Data\data.nt
.\Nt-Converters\Convert-DataPoints.ps1 -Csv .\CSV-Data\datapoints.csv | Out-File -Append -Encoding utf8 .\NT-Data\data.nt
.\Nt-Converters\Convert-Trends.ps1 -Csv .\CSV-Data\trends.csv | Out-File -Append -Encoding utf8 .\NT-Data\data.nt
\ No newline at end of file
.\Nt-Converters\Convert-Sites.ps1 -Csv $InFolder\rooms.csv | Out-File -Encoding utf8 $OutFile
.\Nt-Converters\Convert-Buildings.ps1 -Csv $InFolder\rooms.csv | Out-File -Append -Encoding utf8 $OutFile
.\Nt-Converters\Convert-Floors.ps1 -Csv $InFolder\rooms.csv | Out-File -Append -Encoding utf8 $OutFile
.\Nt-Converters\Convert-Rooms.ps1 -Csv $InFolder\rooms.csv | Out-File -Append -Encoding utf8 $OutFile
.\Nt-Converters\Convert-Devices.ps1 -Csv $InFolder\devices.csv | Out-File -Append -Encoding utf8 $OutFile
.\Nt-Converters\Convert-DataPoints.ps1 -Csv $InFolder\datapoints.csv | Out-File -Append -Encoding utf8 $OutFile
.\Nt-Converters\Convert-Trends.ps1 -Csv $InFolder\trends.csv | Out-File -Append -Encoding utf8 $OutFile
\ No newline at end of file
This diff is collapsed.
......@@ -2,11 +2,12 @@
Param([switch]$ManageTomcat,
[String]$TomcatHome = "\apache-tomcat-9.0.0.M19",
[String]$User = "admin",
[String]$Pass = "nimda"
[String]$Pass = "nimda",
[String]$Server = "http://localhost:8080"
)
#Measure-Command { Invoke-WebRequest -URI http://localhost:8080/sbms/semantics/types/type } Select-Object TotalSeconds
#Measure-Command { Invoke-WebRequest -URI http://loca$Server:8080/sbms/semantics/types/type } Select-Object TotalSeconds
Function Get-Auth($user, $pass) {
$pair = "${user}:${pass}"
......@@ -22,10 +23,15 @@ Function Request($testName, $auth, $url) {
$r = Invoke-WebRequest -Method Get -URI $url -Headers $auth | Select-Object StatusCode, Content
$end = [System.DateTime]::Now.Subtract($start) #| Select-Object TotalSeconds
$dur = $end.TotalSeconds
$c = ConvertFrom-Json $r.Content
$count = 0
$cItems = 0
if($c.groups -ne $null) {
foreach($g in $c.groups) {
$count += $c.results.$g.Count
}
}
[System.String]::Format("{0:00.00}",$dur) + ";" + $testName + ";" + $r.StatusCode + ";" + $count
}
if($ManageTomcat) {
......@@ -36,27 +42,26 @@ if($ManageTomcat) {
$env:CATALINA_HOME=$TomcatHome
& $TomcatHome\bin\startup.bat
Pause
}
"duration;testName;statusCode;contentLength"
"duration;testName;statusCode;dataPoints"
#initial request -- to init the tdb and mode
Request "0: Init" $auth "http://localhost:8080/sbms/semantics/types/type"
Request "0: Init" $auth ($Server + "/sbms/semantics/types/type")
$auth = Get-Auth $User $Pass
Request "1: All information about a DP" $auth "http://localhost:8080/sbms/semantics/datapoints/?fields=bmsId%2Ctype%2Csource.bimId%2Csource.type%2Csource.location%2Cscope.bimId%2Cscope.type%2Cscope.location%2Csensing.type%2Csensing.window%2Cproperty.domain%2Cproperty.quality%2Cpublisher.bimId&bmsId=bacnet%3A%2F%2F04010306.AV1"
Request "1: All information about a DP" $auth ($Server + "/sbms/semantics/datapoints/?fields=bmsId%2Ctype%2Csource.bimId%2Csource.type%2Csource.location%2Cscope.bimId%2Cscope.type%2Cscope.location%2Csensing.type%2Csensing.window%2Cproperty.domain%2Cproperty.quality%2Cpublisher.bimId&bmsId=bacnet%3A%2F%2F04010306.AV1")
Request "2a: All DPs according to strict criteria + grouping" $auth "http://localhost:8080/sbms/semantics/datapoints/?fields=bmsId&grouping=scope.floor&type=Input&source.type=TemperatureSensor&source.location=S01B04&scope.type=Room&property.domain=Air&property.quality=temperature"
Request "2a: All DPs according to strict criteria + grouping" $auth ($Server + "/sbms/semantics/datapoints/?fields=bmsId&grouping=scope.floor&type=Input&source.type=TemperatureSensor&source.location=S01B04&scope.type=Room&property.domain=Air&property.quality=temperature")
Request "2b: Same query as above, different building" $auth "http://localhost:8080/sbms/semantics/datapoints/?fields=bmsId&grouping=scope.floor&type=Input&source.type=TemperatureSensor&source.location=S02B04&scope.type=Room&property.domain=Air&property.quality=temperature"
Request "2b: Same query as above, different building" $auth ($Server + "/sbms/semantics/datapoints/?fields=bmsId&grouping=scope.floor&type=Input&source.type=TemperatureSensor&source.location=S02B04&scope.type=Room&property.domain=Air&property.quality=temperature")
Request "3: Generic query with large number of results + grouping" $auth "http://localhost:8080/sbms/semantics/datapoints/?fields=bmsId&grouping=scope.building&source.type=HumiditySensor&property.domain=Air"
Request "3: Generic query with large number of results + grouping" $auth ($Server + "/sbms/semantics/datapoints/?fields=bmsId&grouping=scope.building&source.type=HumiditySensor&property.domain=Air")
Request "4: Generic query with large number of results + datapoint type + grouping" $auth "http://localhost:8080/sbms/semantics/datapoints/?fields=bmsId%2Ctype%2Cscope.bimId&grouping=scope.building&source.type=TemperatureSensor&property.domain=Air&property.quality=temperature"
Request "4: Generic query with large number of results + datapoint type + grouping" $auth ($Server + "/sbms/semantics/datapoints/?fields=bmsId%2Ctype%2Cscope.bimId&grouping=scope.building&source.type=TemperatureSensor&property.domain=Air&property.quality=temperature")
Request "5: Generic query with large number of results + all available information + grouping" $auth "http://localhost:8080/sbms/semantics/datapoints/?fields=bmsId%2Ctype%2Csource.bimId%2Csource.type%2Csource.location%2Cscope.bimId%2Cscope.type%2Cscope.location%2Csensing.type%2Csensing.window%2Cproperty.domain%2Cproperty.quality%2Cpublisher.bimId&grouping=scope.building&source.type=TemperatureSensor&property.domain=Air&property.quality=temperature"
Request "5: Generic query with large number of results + all available information + grouping" $auth ($Server + "/sbms/semantics/datapoints/?fields=bmsId%2Ctype%2Csource.bimId%2Csource.type%2Csource.location%2Cscope.bimId%2Cscope.type%2Cscope.location%2Csensing.type%2Csensing.window%2Cproperty.domain%2Cproperty.quality%2Cpublisher.bimId&grouping=scope.building&source.type=TemperatureSensor&property.domain=Air&property.quality=temperature")
if($ManageTomcat) {
......
AMD Athlon II X4 641 Quad-Core 2.8GHz
500 MB of RAM
One processor core at 100% during the query execution
82000 triples
sbim:EnergyMeter 25
sbim:Site 5
sbim:HumiditySensor 750
sbms:Input 2300
sbms:Observation 3050
sbim:TemperatureSensor 750
sbim:MovementSensor 750
sbms:ObservedProperty 3050
sbms:StatelessDirectSensing 3000
sbim:Building 25
sbim:ProgrammableController 775
sbms:UserDefined 750
sbms:Trend 6100
sbms:AggregateSumSensing 50
sbim:Room 750
sbim:Floor 75
sbim:hasRoom 750
sbms:hasBMSId 9150
sbms:observedProperty 3050
sbms:featureOfInterest 3050
sbim:hasBIMId 3905
sbim:isInstallationLocationOfDevice 3050
sbms:hasAggregationTimeWindow 50
sbim:isFloorOf 75
sbms:expressesObservation 3050
sbms:isPropertyOf 3050
sbim:isRoomOf 750
sbim:hasBuilding 25
sbms:publishedByDevice 3050
sbms:hasPropertyDomain 3050
rdfs:label 6100
sbim:hasInstallationInRoom 3050
rdf:type 22205
sbms:trends 6100
sbms:observedBy 3050
sbim:isBuildingOf 25
sbms:hasPhysicalQuality 3050
sbim:hasFloor 75
sbms:sensingMethodUsed 3050
#datapoint type clause at the end - fresh start
duration;testName;statusCode;contentLength
06,19;0: Init;200;68
02,17;1: All information about a DP;200;387
02,16;2a: All DPs according to strict criteria + grouping;200;1122
01,89;2b: Same query as above, different building;200;1122
02,06;3: Generic query with large number of results + grouping;200;26024
34,33;4: Generic query with large number of results + datapoint type + grouping;200;62024
147,43;5: Generic query with large number of results + all available information + grouping;200;249524
# all type clauses at the end - fresh start
duration;testName;statusCode;contentLength
06,64;0: Init;200;68
02,54;1: All information about a DP;200;387
02,20;2a: All DPs according to strict criteria + grouping;200;1122
02,11;2b: Same query as above, different building;200;1122
01,96;3: Generic query with large number of results + grouping;200;26024
67,96;4: Generic query with large number of results + datapoint type + grouping;200;62024
180,77;5: Generic query with large number of results + all available information + grouping;200;249524
#datapoint type clause at the end - fresh start
duration;testName;statusCode;contentLength
06,86;0: Init;200;68
02,18;1: All information about a DP;200;387
02,22;2a: All DPs according to strict criteria + grouping;200;1122
01,97;2b: Same query as above, different building;200;1122
02,09;3: Generic query with large number of results + grouping;200;26024
37,36;4: Generic query with large number of results + datapoint type + grouping;200;62024
151,19;5: Generic query with large number of results + all available information + grouping;200;249524
#datapoint type clause at the end - repeated
duration;testName;statusCode;contentLength
00,31;0: Init;200;68
01,03;1: All information about a DP;200;387
01,87;2a: All DPs according to strict criteria + grouping;200;1122
02,32;2b: Same query as above, different building;200;1122
01,94;3: Generic query with large number of results + grouping;200;26024
36,27;4: Generic query with large number of results + datapoint type + grouping;200;62024
155,71;5: Generic query with large number of results + all available information + grouping;200;249524
00,05;0: Init;200;0
00,49;1: All information about a DP;200;1
01,62;2a: All DPs according to strict criteria + grouping;200;30
01,91;2b: Same query as above, different building;200;30
01,72;3: Generic query with large number of results + grouping;200;750
37,54;4: Generic query with large number of results + datapoint type + grouping;200;750
145,99;5: Generic query with large number of results + all available information + grouping;200;750
---------------------------------------------------------------------------------------------------------
1 000 000 triples
760 MB of RAM
58,97;0: Init;200;0
12,60;1: All information about a DP;200;1
26,80;2a: All DPs according to strict criteria + grouping;200;100
27,47;2b: Same query as above, different building;200;100
27,08;3: Generic query with large number of results + grouping;200;10000
453,22;4: Generic query with large number of results + datapoint type + grouping;200;10000
-;5: Generic query with large number of results + all available information + grouping;-;-
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment