Here's how to use tabulator to render a simple data table.
My test data might be a bit confusing since the terms overlap with tabulator terms. I'm trying to compare query runtimes of various queries on different databases. The result I'm trying to produce is a table showing how long each database took on each query.
Here's my mockup data in n3:
@prefix : <http://example.org/> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . :result rdfs:label "test result" . :db rdfs:label "database" . :time rdfs:label "elapsed time" . <> :result [a :Result; :query :q1; :db :rdflibBdb; :time ".5"], [a :Result; :query :q2; :db :rdflibBdb; :time ".6"], [a :Result; :query :q3; :db :rdflibBdb; :time ".7"], [a :Result; :query :q1; :db :db2; :time ".8"], [a :Result; :query :q2; :db :db2; :time ".9"], [a :Result; :query :q3; :db :db2; :time ".11"] .
Note the line which associates the 6 results with this document. Without that link, tabulator won't put the results in its outline.
I used cwm to create an XML version of that data, which you can view that data in tabulator with the following link. [Update: there was no need to convert; tabulator can read n3 thanks to a version of the cwm parser translated to js with pyjs!]
Tabulator has a query-building interface where you click on predicates and other nodes to constrain your result rows, but I couldn't figure out how to make the table I wanted. Instead, I used the SPARQL tab at the bottom and wrote my own query:
SELECT ?query ?bdb ?db2
WHERE
{
?v1 <http://example.org/db> <http://example.org/db2> .
?v0 <http://example.org/db> <http://example.org/rdflibBdb> .
<http://bigasterisk.com/post-rdf/timing-results6.rdf> <http://example.org/result> ?v0 .
?v1 <http://example.org/query> ?query .
?v0 <http://example.org/time> ?bdb .
?v0 <http://example.org/query> ?query .
?v1 <http://example.org/time> ?db2 .
}
In english, that says "find queries with results for the two databases, and report their times in columns named after the databases". You can load tabulator with my datafile and that query together:
tabulator with mockup data and query
You have to click the radiobutton next to 'Query' to see the results.
Now I'll actually write my database benchmark, and I'll have it output result sets for each db. I should be able to combine the result sets together and display them in a table with the method described above. The biggest issue with abusing tabulator in this way is that I have to grow my query for each new database I test. Also, that query won't display a row unless it has results from all databases. It would be nice to have all cells optional, so I can still see a row if it only has a result from one database.
![]() | Unless otherwise noted, all content licensed by Drew Perttula under a Creative Commons License. |