Part 1 : RDF Stream Processing with CSPARQL Engine

In this part of the tutorial, we will see how to query RDF Streams using an RDF Stream Processing (RSP) engine. The CSPARQL engine is an RSP engine that does not offer reasoning capabilities. Although extensions have been proposed, in this part of the tutorial we focus on plain continuous query answering.

RDFLib

RSPLib is the python library that we are going to use in our tutorial. It offers abstrations to manipulate RSPSources, e.g. RDF Streams and to interact with RSP Engines, e.g. registering streams and queries.

RSPLib APIs are still under development. In this tutorial we are going to use version 0.3.4 which is available at https://pypi.python.org/pypi/rsplib/.

to upgrade it just type !pip instal rsplib --upgrade in a cell

source code available at https://github.com/streamreasoning/rsplib


In [4]:
from IPython.display import Image
from IPython.core.display import HTML  
from rsplib.processing import RSPSource, RSPEngine

RDF Streams with TripleWave

TripleWave is a resource designed to publish RDF Stream on the web. RSPLab integrates TripleWave as a default tool for stream provisioning.

Did you already started the streams in the streamer/citybench folder?

Notably, since we are deal with replayed RDF streams, we need to start them using a specific API. Wild Streams, i.e. those naturally available on the web like WikiPedia changes), do not require to be started.


In [33]:
stream0 = RSPSource("http://aarhustrafficdata182955", 4000);
stream0.sgraph()


Out[33]:
{'@context': {'generatedAt': {'@id': 'http://www.w3.org/ns/prov#generatedAtTime',
   '@type': 'http://www.w3.org/2001/XMLSchema#dateTime'},
  'sld': 'http://streamreasoning.org/ontologies/SLD4TripleWave#'},
 '@id': 'tr:sGraph',
 'sld:contains': {'@list': [{'@id': 'http://aarhustrafficdata182955:4000/20784581-ETc1c2bfa9d858284d55495dedf00b0bbf',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:26.670+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20784581-CL480af360b106131076ade0499ab7eab4',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:26.675+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20784581-AS92a4ebbf3b1ec8d6acf6ae9e16a412fc',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:26.835+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20784581-VC61882443e514edab1296a9b26122edfe',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:26.972+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20784581-MT41163724368d727de6733881a50c75bf',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:27.091+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785030-ET197a674051822b87cb47ee3d26cd91da',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:27.250+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785030-CL47e43e8144920906d99fc2769c6b26ab',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:27.259+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785030-MT1954a6c0978bf5288c0592c2c1952411',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:27.418+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785030-VCa9f036e3cd0379a740c9d659fe5dcc89',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:27.541+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785030-AS406c048f1cea2a0967568eb810a06dab',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:27.670+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785479-ETab9f07bb20d17b460424d8866433c6a0',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:44:27.857+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785479-CLa4a81e1ef92d1d57065c8e6330ee8a29',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:44:27.861+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785479-ASaad745d5cce1756c71fd8469f2c09eb5',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:44:27.985+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785479-VC2662dccb38b30b25fcc5beb9e9f4b535',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:44:28.109+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785479-MT966f6305ce9805d27e412b7c2d8587b9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:44:28.229+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785928-ETae6139d5e70dfc6f7a67b661eecb157a',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:45:28.411+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785928-CL79653e953312fc38d2742794e155b299',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:45:28.421+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785928-MT7a6f8e70d819747f6e8e274e9154ab32',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:45:28.547+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785928-VC706a21d6e75e03a905194ffaa7e77b6e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:45:28.670+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20785928-AS18468d1156358e768fdf97b745b80818',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:45:28.791+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786377-ET36fc5f2dafbd88c8037860871d13e095',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:28.979+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786377-CLd7f20bd140eb56c41b7e56eca6f748c0',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:28.994+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786377-AS986126e7ebb07fc109d8a7e2587fab36',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:29.190+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786377-VC24043d06cf799f2d6d6113877d9e3f76',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:29.353+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786377-MTbe6d543764322cf7fd1997a4b0cd2dc7',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:29.527+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786826-ET271eb3f676fd8322830725f1855e4bcd',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:29.712+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786826-CL19d309e815bcd4d319a9b42aa869e76f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:29.717+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786826-MT25abfa198065efcdcc4274e6af348e71',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:29.854+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786826-VCc07af01957211afff8b71d3f7143859e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:29.985+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20786826-AScaaf7156e809947161a2e43f7bfe6269',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:30.116+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787275-ETbb45f0447a757d7fe06ccb55f4605af9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:30.291+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787275-CLd0ea4f6471682a159b3bb85549d63ae0',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:30.300+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787275-AS5c209f450b43bdbb069857e5e600bc5a',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:30.447+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787275-VC6bea2a3c62dc92910146131a4d7d786b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:30.651+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787275-MTf086970303696fb665ec0bead288f976',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:30.812+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787724-ETbcd7eeaa1cef0fa9ef515dfd576c9a0e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:30.990+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787724-CL6faabba809e634ffd5f36c2e074fc537',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:30.997+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787724-MT8c0056b7ba687e68a67e8c458508bd24',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:31.151+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787724-VC65e6c77398842ce16e8814ba88263014',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:31.307+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20787724-AS1656f5a68077aec4b7c147a7ba04aad9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:31.480+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788173-CL4b5cccc27bdffd51a82f0da5b050f8b3',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:32.058+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788173-ET64aef137d11f7b8ad9d3db49451f6bdd',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:32.061+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788173-AS883c62de00c301b144f4c5016bbcd124',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:32.213+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788173-VC8666964cc3861912d47f32b2ad4d4ca5',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:32.344+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788173-MT5f9aa5ed72014c48dcf96dfb709507ad',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:32.463+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788622-CL7a1818c31b2bbb702021611603a82a22',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:33.078+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788622-VC37c111dc263ce372652a25afef08e3e2',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:33.096+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788622-MTb8a86b49b7001e9634e8469f560f6b6b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:33.249+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788622-ET2de5f9a4fe563713ef336a8bf36a7138',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:33.375+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20788622-ASf8fcc0be5d35035a27bd34d4cf6facd0',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:33.508+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789071-ETbcd1e5fccb776744e23fab91d9026b34',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:33.662+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789071-CL2552d228157c1a3c18da76e9983fa78b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:33.666+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789071-ASafcbd966ee2441f4e5110b5552cb839d',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:33.869+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789071-VCa1ef1fe84009d2a60a69132830135322',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:34.094+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789071-MT5a02f4822b3327413f7c7f511dc54d2b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:34.250+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789520-ET52adde477e1a3066cb9f15d575f3a6d5',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:34.453+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789520-CL59ef43b8728e9b273e6315d856284ae4',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:34.462+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789520-MT962171edd10e37bf8a96a0a1cb223d68',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:34.594+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789520-VCb6fdf54f607481401582d3e7365b0aae',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:34.717+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789520-AS1a69fb02a678fd5da21ab2504cb81dee',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:34.851+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789969-ETf8a97164c512f9ce0835d4e5fc6a419a',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:35.047+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789969-CL3563a9a794413cee9e072939d450083d',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:35.051+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789969-AS1800d274edd456214bcc023b1cf04c90',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:35.213+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789969-VC6256b88106bec6f3b7653ae70f3eb226',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:35.332+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20789969-MT28c51b24edc80ed567e087d11effcd1e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:35.481+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790418-ETd2a8c3269b33000bdeda8b3df9f27953',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:35.658+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790418-CL6dcf8d19d871f11d3e438429dc879f54',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:35.662+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790418-MTd76f4a2256b66f5f54fce40b3ba990e1',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:35.806+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790418-VC80e73822f69dcc125e094cb0bfaf2f51',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:35.942+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790418-AS8334ecb5b9a23861e872d72b797c7cfc',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:36.090+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790867-ET8c033baa889d5c34f0449819ea2776f3',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:36.253+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790867-CL24dc6b421d81d796de73b08025276db1',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:36.258+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790867-ASd2cae9e2c3f08ffe884222adc156fd7a',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:36.394+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790867-VCa79ba6faa39816c93f2879565dc0586e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:36.517+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20790867-MT9516ba95286db2c606b64b7e2148702e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:36.638+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791316-ETe2f35b0bb1ada7be5642cda1a49b0d9b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:36.818+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791316-CLe4476a29eb7b4d88e5c925c9dc30077f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:36.823+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791316-MTcf17c9b8bb703956b373ff6f9197f487',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:36.959+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791316-VC46effff2bb8ce18a29473ada2df3e16b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:37.129+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791316-AS56c7e0cf91c87226e579089c980e3375',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:37.298+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791765-ETf8a9084d230fb03afb9aea524774b6e7',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:37.510+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791765-CL8bb839111ac34a5fcb4c6082d6d6bf8c',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:37.518+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791765-AS6028e80acc02cb181d7c0134047a5b27',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:37.678+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791765-VC1142f71cf70650de695f5406ce76bac4',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:37.803+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20791765-MT676ecd99d427717fd7050d49f8e596ca',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:37.923+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792214-ETb3876e43eb98d1fe6a9f37596a2c1658',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:38.099+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792214-CL9153df34b5ea18b09a067d0d8ad270de',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:38.102+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792214-MT8b6d6790955dcfdc9bc270e1c0882347',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:38.231+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792214-VC18af5250248a4ae3d1a636aa68de643f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:38.357+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792214-AS0efb5f0c9484f5e04445f3e40b496b1f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:38.485+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792663-ET4aefe9452a541b9c2ef2af08dfa07099',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:38.669+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792663-CLf462fe9933c945649cf0063fd4ce333d',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:38.673+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792663-AS98f6e9613cf69158b10b4c6505af52d9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:38.818+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792663-VC9e0a70fded37f13dce6dc795caf3c60f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:38.954+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20792663-MT7826de7b0ff93c01ee5e7c98d4122173',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:39.091+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20793112-ET8bfb1929fe521ad16110b03557b74cdf',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:39.289+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20793112-CL21fcb5db873cf33768126f3697179066',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:39.294+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20793112-MT7ed0f67010b4855c9f93a694f7d5fd46',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:39.431+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20793112-VCe2aea5a01e8fc21b02893f6aeca243e1',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:39.607+0000'}},
   {'@id': 'http://aarhustrafficdata182955:4000/20793112-AS353b63623875ad9dd105f90bf3f10f97',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:39.739+0000'}}]},
 'sld:lastUpdated': {'@type': 'xsd:dateTime',
  '@value': '2017-11-04T18:01:39.739+0000'},
 'sld:streamLocation': 'ws://aarhustrafficdata182955:4040/primus',
 'sld:tBoxLocation': 'https://rsplab.blob.core.windows.net/static/citybench.owl'}

In [34]:
stream1 = RSPSource("http://aarhustrafficdata158505", 4001);
stream1.sgraph()


Out[34]:
{'@context': {'generatedAt': {'@id': 'http://www.w3.org/ns/prov#generatedAtTime',
   '@type': 'http://www.w3.org/2001/XMLSchema#dateTime'},
  'sld': 'http://streamreasoning.org/ontologies/SLD4TripleWave#'},
 '@id': 'tr:sGraph',
 'sld:contains': {'@list': [{'@id': 'http://aarhustrafficdata158505:4001/20782963-ET1657bf8575dd719875339ea15a815e8d',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:41:56.431+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20782963-ASc286221da954320a2674dc5bcfd94a85',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:41:56.436+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20782963-VCb787fa20e0f9ca22a68169db58ff344b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:41:56.574+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20782963-CLa151656fac5864feb0060a9f5c64afe4',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:41:57.172+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20782963-MT1e488cf59eacd5daf34c09230a06b649',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:41:57.306+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783412-CLd91173da6435aec151612e63110daa26',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:57.890+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783412-MT135ce990824d0388cfe7d9a93d03aba9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:57.896+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783412-ET03856bb6a0efd589f43df4fe866a535c',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:58.028+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783412-VCc86dbd61f9a5f687854e56caca8f531b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:58.157+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783412-AS6cb799371193d8db0cdd638f7183b8a1',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:42:58.290+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783861-VC4c6ae56a13d3527ca2687c8be1711267',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:58.490+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783861-ETdc627dc1e84991494428f94eea930dec',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:58.494+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783861-CLd06db7595eb4d0cdf0b3abcb74362460',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:59.133+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783861-AS6ca7123a780eae27f4f0ee414625f850',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:59.303+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20783861-MTd5abb28f370584cebd981d48c9906f04',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:43:59.481+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784310-ET3ceadbcf4e95a88b1cf45dd58c9bffa7',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:44:59.678+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784310-AS0eaca2258f846c119351dc508aacaf0e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:44:59.685+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784310-CLd27d450159cd2e5d3f4197401f23cc22',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:45:00.407+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784310-VCd92bf9cb5d856e665af02f0bc6e2f817',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:45:00.596+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784310-MT3a914b6c8e60fbd7d3596df5b7f300e0',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:45:00.764+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784759-VC6dbe1454fc0f330b183a996cc7ec202f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:00.970+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784759-MTb7b309cbffcf395646ff56b35c67c034',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:00.978+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784759-ET02e6511ae90477b54cedd38995b076ac',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:01.101+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784759-CL6a2a2cdb0719b3ba196ff4a1f6eba685',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:01.734+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20784759-AS3eba216fc23b3374483cb74ee137cff4',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:46:02.086+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785208-CLba5ba253c0576ad6fa91963430ede166',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:02.822+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785208-ET09b410e2711daafdd3fa75dabc04fe22',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:02.833+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785208-VCaa4cd313e8cf3a252c597fc0e68b37fc',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:02.971+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785208-ASa6e651d68409605c433905c001931209',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:03.107+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785208-MT249cd8294f9675acc96abf111514b3a3',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:47:03.243+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785657-ET8c8d75ca7e89321f3bf57bd88fe5b41f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:03.439+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785657-AS197803542482ec79b1c9e9288050fdb5',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:03.452+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785657-VC2d5b8d701af6cb2533e7caf9df926ebf',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:03.611+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785657-CL256f839a52346fe7cede7bb76ca9a1eb',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:04.249+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20785657-MTdd8dd934844e7526ced1d185d84a0291',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:48:04.401+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786106-CLe675aaccc824490a1bb0d5f16ad84055',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:05.060+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786106-MT6aadf02e751c14c0c108de7e7b563dc0',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:05.064+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786106-ETde7eb0cbcdb888f2105cab3c2857a391',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:05.202+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786106-VC149e1d9c246cf7090ae4508a43f0b5a7',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:05.335+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786106-AS6701adfd3f498435249481c2ddc69ca6',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:49:05.461+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786555-VCcbc225a6cd4c6c60b3ff4a2f3c61ae33',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:05.661+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786555-ETc7d6d585968b2ce6664e0f4fb836aa51',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:05.667+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786555-CLc8335136c30cc7918a32c4b316390aa9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:06.243+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786555-ASe9bea202020d00f19caf60c23042d5dc',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:06.396+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20786555-MTf638b4d45ac1ca2ad19bcbba16cf54fe',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:50:06.536+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787004-ET10d97e959a880520a5a853bd39b56802',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:06.738+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787004-AS06d0878d0210e49899a325c22cabd854',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:06.741+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787004-CLbc306a626e56458b5a28c7da52717108',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:07.292+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787004-VCa40c8e43deaede9ff5bd2aec536ac618',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:07.436+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787004-MT045319a53cd0bb8719d9aec489dddfd6',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:51:07.585+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787453-VCd4ee60b35a1867534b36bdb5434d948a',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:07.772+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787453-MTd93f8d7b9fdcaa46a7b01c0c994d889e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:07.780+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787453-AS72eb3233174ad53ea57874a8c48e6095',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:07.914+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787453-CL196dda22115e3c55a6cac12eda310158',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:08.603+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787453-ET4aae399419e098a1445864b0a9b5fb2a',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:52:08.745+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787902-CL0006b838fbf5bbbf54b5491ebe413542',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:09.449+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787902-ETdba6c5b2bc8af71aaa75db6e1f665093',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:09.453+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787902-VC5f852b906958e1a8da85dc6d0f73e991',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:09.621+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787902-AS4208214468663769f69aacad72fe316c',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:09.762+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20787902-MT1febf20ad3a3117514e41e4b3363303f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:53:09.898+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788351-ET6308730d2c3e4ae5d8fb23be4fed48fd',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:10.089+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788351-ASf3f1c856b0352ef811d10629db97858b',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:10.097+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788351-VC7d15d0c3e4cda2e5f5f80ca514674ce5',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:10.231+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788351-CLc48cbce4ef995b0c87fc5a93cf99d2f9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:10.892+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788351-MTc39d373339eb7a2b87b2d73666f36ac8',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:54:11.048+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788800-CL1dbb912289bcc3db709172989ec05afd',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:11.709+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788800-MTc0306de2411b73d07f964999b21308c9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:11.723+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788800-ET5d9824aa5df5b674746eb33cd8cdbfb9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:11.865+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788800-VC0d8794d556fc93082ac16aa39c9d9b48',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:12.011+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20788800-ASb8ef854c2552536df5bf3a3e8add20a3',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:55:12.147+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789249-VCadcce8c50e6cbc645a63371206bf47a7',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:12.338+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789249-ETc801f17b33d322eb996aa8dd5967d726',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:12.344+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789249-CL1bd2cda45ae87a4bda8257e2b66c2d35',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:13.014+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789249-ASfd2f0565e2d0928ce74514acfd3f077c',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:13.173+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789249-MTa78a0362dd28287be4c05879a2abdfba',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:56:13.324+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789698-ETc39084c85e52c3955ae418ad9e7f87d7',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:13.490+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789698-ASb595f23c213493f34516aad4c68aab99',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:13.494+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789698-CL9d37bb739eb00a93fe30e9ac490c34d0',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:14.053+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789698-VCea9d815e4f500cde47a4b46bf22fe831',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:14.204+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20789698-MTd2f3d36df3f180294f143736098db26f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:57:14.343+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790147-VCba6bb6291af3581eafee7fadb58f8c11',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:14.549+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790147-MTb1649229c0c5daa01b3bb51ee6f31f50',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:14.557+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790147-ET263898de8af4d160c999bc7239f7277f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:14.703+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790147-CL2c87fefecd09af4a087ae9d1f14e41cb',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:15.459+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790147-AS180091f478eb95de4abe1a890963b7da',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:58:15.610+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790596-CL4612d5b976eafb5ddebaa5e6a4ab54e7',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:16.251+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790596-ETfaef485b31707cd541625a4854cd22ac',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:16.256+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790596-VC286ec865ae454dfd38dbfa7abc2da487',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:16.399+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790596-AS77fb1ed7fb5c05157e45ae354fb1bdf4',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:16.532+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20790596-MTc4b6cc7ac474bdfb7e55d3946ea0e32d',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T17:59:16.665+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791045-ET0e0e875583dc5c56d1dd8ae97fd3f1f3',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:16.850+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791045-AS1d3fa86675838f57fc568ba67130daa9',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:16.855+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791045-VCee2444f49a634c6232bb76e1f57b4076',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:16.999+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791045-CLb98edd274ac2c03d77bfe27811639897',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:17.616+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791045-MTe70911eb20f985aa18af1f765e62771a',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:00:17.793+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791494-CLcd5c58fe541ca2140ee5151b83948e8f',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:18.521+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791494-MT38f9929f8111a9ff42df0747cf33cdc2',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:18.529+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791494-ET9d4df09e598d7e2bfc6c7cb3395a5a8e',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:18.675+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791494-VCb091e5f70cae436e1e6c88d9c0a4b089',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:18.813+0000'}},
   {'@id': 'http://aarhustrafficdata158505:4001/20791494-ASb1fc2c14634f2b7ce90df14b64fb2441',
    'generatedAt': {'@type': 'xsd:dateTime',
     '@value': '2017-11-04T18:01:18.959+0000'}}]},
 'sld:lastUpdated': {'@type': 'xsd:dateTime',
  '@value': '2017-11-04T18:01:18.959+0000'},
 'sld:streamLocation': 'ws://aarhustrafficdata158505:4041/primus',
 'sld:tBoxLocation': 'https://rsplab.blob.core.windows.net/static/citybench.owl'}

In [5]:
stream0.start()


Out[5]:
{'msg': 'streamCreated'}

In [ ]:
stream1.start()

Now that we started our streams, we can consider them as wild RDF streams that we can consume and query using an RSP Engine.

RDFLib abstracts RDF Streams a RSPSource. Using this Facace is possible to access the stream description published using TripleWave: the sGragh

Are you curious to see what's is inside the RDF Streams?

You might have noticed that the sGraph has a sld:contains property that contains the uris of the stream items, called iGraphs.

However, in order to access the content of the iGraphs one has to de-reference their URIs.

Click on the following link and let's see how to consume the content in a push-based manner as RSP engine do.

RSP Engine: CSPARQL

Now that we have our RDF Stream running, we can start thinking about how to query them. To this extent, we are going to use the CSPARQL engine.

Did you started csparql in the consumer folder?

RSPLib offers a facade to communicate with RSP engine via the RSP Services (a RESTful interface for RSPs).


In [27]:
csparql = RSPEngine("http://csparql", 8182);
csparql.status()


{"name":"csparql","host":"csparql/","runUUID":"27457187-c185-11e7-9837-1a00a83a5601","port":8182,"empty_results":false,"inference":false,"timestam_function":false,"backloop":false,"num_streams":0,"num_datasets":0,"num_queries":0}
Out[27]:
{'backloop': False,
 'empty_results': False,
 'host': 'csparql/',
 'inference': False,
 'name': 'csparql',
 'num_datasets': 0,
 'num_queries': 0,
 'num_streams': 0,
 'port': 8182,
 'runUUID': '27457187-c185-11e7-9837-1a00a83a5601',
 'timestam_function': False}

Registering the Streams

A first important step to answer queries over streams is the registration. As we saw during the initial part of this tutorial, Streams are unbounded sequences of data. Therefore, in order to access them we need special systems such as RSP engines.

The RSP engines needs receive the data in a push-based manned. This process is initialized registering the streams to the engine.


In [28]:
csparql.register_stream("AarhusTrafficData182955", "http://aarhustrafficdata182955:4000/sgraph")


"Stream AarhusTrafficData182955 succesfully registered with IRI http://aarhustrafficdata182955:4000/sgraph"
Out[28]:
'Stream AarhusTrafficData182955 succesfully registered with IRI http://aarhustrafficdata182955:4000/sgraph'

Register A Second Stream


In [29]:
csparql.register_stream("AarhusTrafficData158505", "http://aarhustrafficdata158505:4001/sgraph")


"Stream AarhusTrafficData158505 succesfully registered with IRI http://aarhustrafficdata158505:4001/sgraph"
Out[29]:
'Stream AarhusTrafficData158505 succesfully registered with IRI http://aarhustrafficdata158505:4001/sgraph'

Available Streams


In [23]:
to access the stream andcsparql.streams()


[{"streamURL":"AarhusTrafficData158505","status":"RUNNING"},{"streamURL":"AarhusTrafficData182955","status":"RUNNING"}]
Out[23]:
[{'status': 'RUNNING', 'streamURL': 'AarhusTrafficData158505'},
 {'status': 'RUNNING', 'streamURL': 'AarhusTrafficData182955'}]

Register a Query

Now that our engine receives the data from the registered streams, we can issue a query to answer.

As we saw in the second part of this tutorial, queries over streams are different from queries over static data: they are continuous queries

Continuous query answering produces results over time, therefore a query is registered and evaluated again and again.

In the current example, we are using the CSPARQL engine to query our RDF Streams. This particular engine consumes queries written in a continuous extension of SPARQL called CSPARQL. An example of query looks like this:


In [30]:
with open('q1.csparql.txt', 'r') as csparq_query:
   body = csparq_query.read()
   print(body)


CONSTRUCT {?s ?p ?o }
FROM STREAM <AarhusTrafficData182955> [RANGE 3s STEP 1s] 
FROM STREAM <AarhusTrafficData158505> [RANGE 3s STEP 1s] 
WHERE 
    {
        ?s ?p ?o
        
}

In order to register our query, we have to give it a name, e.g. givemeall and decide its type. The query type can be either STREAM or QUERY. The former produces a stream as a result, i.e. each output is timestamped, the latter simple push out the results.

This simple difference is actually very important, since an output STREAM can be consumed by another RSP engine while a QUERY does not.


In [31]:
csparql.register_query("givemeall", "STREAM", body)


{'queryBody': 'REGISTER STREAM givemeall AS CONSTRUCT {?s ?p ?o }\nFROM STREAM <AarhusTrafficData182955> [RANGE 3s STEP 1s] \nFROM STREAM <AarhusTrafficData158505> [RANGE 3s STEP 1s] \nWHERE \n    {\n        ?s ?p ?o\n        \n}'}
"Query givemeall succesfully registered"
Out[31]:
'Query givemeall succesfully registered'

Register Observer

A final step to our query answering is observing the results. Since we registered our query as a type STREAM we require an observer that is expose the results as an RDF Stream:


In [32]:
csparql.register_observer("givemeall", "default", {"host":"csparql","type":"ws","port":8283,"name":"default"})


"http://csparql:8182/queries/givemeall/observers/default"
Out[32]:
'http://csparql:8182/queries/givemeall/observers/default'

Measuring the Performance

RSPLab offers assisted realt-time performance monitoring using cAdvisor and Grafana. In order to observe the current status of the engine you can visit

http://localhost:3000/dashboard/db/csparql?orgId=1

in case you didn't access yet, username:admin password:admin


In [6]:
Image(url= "https://raw.githubusercontent.com/streamreasoning/rsplab/tutorial/collector/lab/streamapp/images/jasper_grafana.png")


Out[6]:

Clean UP


In [35]:
csparql.unregister_observer("givemeall", "default")


"Observer default (ws://csparql:8283/givemeall) succesfully unregistered"
Out[35]:
'Observer default (ws://csparql:8283/givemeall) succesfully unregistered'

In [36]:
csparql.unregister_query("givemeall")


"Query givemeall and stream csparql/queries/givemeall succesfully unregistered"
Out[36]:
'Query givemeall and stream csparql/queries/givemeall succesfully unregistered'

In [37]:
csparql.unregister_stream("AarhusTrafficData158505")


"Stream AarhusTrafficData158505 succesfully unregistered"
Out[37]:
'Stream AarhusTrafficData158505 succesfully unregistered'

In [38]:
csparql.unregister_stream("AarhusTrafficData182955")


"Stream AarhusTrafficData182955 succesfully unregistered"
Out[38]:
'Stream AarhusTrafficData182955 succesfully unregistered'

In [40]:
csparql.status()


{"name":"csparql","host":"csparql/","runUUID":"27457187-c185-11e7-9837-1a00a83a5601","port":8182,"empty_results":false,"inference":false,"timestam_function":false,"backloop":false,"num_streams":0,"num_datasets":0,"num_queries":0}
Out[40]:
{'backloop': False,
 'empty_results': False,
 'host': 'csparql/',
 'inference': False,
 'name': 'csparql',
 'num_datasets': 0,
 'num_queries': 0,
 'num_streams': 0,
 'port': 8182,
 'runUUID': '27457187-c185-11e7-9837-1a00a83a5601',
 'timestam_function': False}

To turn off CSPARQL engine:

  • return to the folder rsplab/consumer
  • ./stop.sh

In [ ]: