libby.miller@bristol.ac.uk 2002-07-26 Inkling - a query engine in Java for RDF, with in-memory and SQL backends. http://swordfish.rdfweb.org/rdfquery/ This code has a GPL license - see the license.txt or http://www.gnu.org/copyleft/ If this doesn't suit you, get in touch. The tests are separately available under a W3C-like license: http://swordfish.rdfweb.org/rdfquery/tests/ do this: sh build.sh (which builds and runs two small tests) sh test.sh runs lots of tests and takes a while. Some of (the better parts of) this code were written by Leigh Dodds and Dan Brickley - thanks to them :) The SQL query rewriter started as a transliteration of Matt Biddulph's PHP version. This product includes software developed by the Apache Software Foundation (http://www.apache.org/). Dependencies ARP 1.0.5 which depends on Xerces 1_2_3 ant_1_2.jar for building pgjdbc2.jar, a Postgres driver (which you may have already) jpeg.jar, the W3C's jpeg embedded text library junit.jar for unit testing aging-stanford-api.jar, a now superceeded simple API for RDF all these jars and licenses are in lib/ directory. Packages and APIs org.desire.rudolf.app Scutter is the main class here: If harvests RDF files, starting with either an RDF file containing nothing but rdfs:seealso relations, e.g. http://swordfish.rdfweb.org/discovery/2001/08/codepict/scutterplan.rdf or a scutterplan - a list of files, one per line with the prefix ./scutter on each line, e.g. http://swordfish.rdfweb.org/discovery/2001/04/rdfig/scutterplan.rdfig run it like this: java -classpath $CP org.desire.rudolf.app.Scutter [-d database url] [-f scutterfilename] [-r] -r tells it to use a text file rather than an rdf file. The defaults are to use rdf:jdbc:postgresql://localhost:5432/test?auth=password&user=postgres&password=notneeded for the database file and rdf/scutterplan.rdf for scutterplan file src.org.desire.rudolf.rdf The classes here use a now defunct simple stanford RDF API. Essentially it uses Resource, Property, Literal, and RDFConsumer for interacting with the RDF parser. It's better to interact with the query language rather than at this low level, as some of these classes may change. ARPWrapper - required to use ARP with this API RDFModelCoreStatementHandler - required to use ARP with this API RDFModelCore is a simple RDF API RDFGraph is a simple implementation of RDFGraph Triple represents a triple and associated meta information TripleSearcher is the main triple matching search method org.desire.rudolf.rdf.mime several classes for getting RDF data from various formats, including JPegs for harvesting RDFPic-generated files. org.desire.rudolf.query Inkling uses the JDBC API for querying both SQL-backed and in-memory implementations. See http://swordfish.rdfweb.org/rdfquery/howto.html for more details. Statement, ResultSet, ResultSetMetaData, Connection are all partial implementations of various java.util.SQL interfaces. QE.java is the in-memory Query implementation Squish2SQL converts Squish query strings to SQL query strings using the inklingsqlschema.psql (use sqlstring=Squish2SQL.convertString(String squish_query)) DownloadUrls uses the RDF parser to download lists or single urls and return RDFModelCore objects. QueryDirect is the interface you need to use so that Squish2SQL kicks in. SQLHandlerInterface is misnamed - it is the simplest interface that QE.java can talk to to query an RDF database and get results back. Query architecture: optional JDBC -> QE (SquishQL querystring) -> QE if QueryDirect -> SQL query of an SQL database returning JDBC resultset->QE QE if SQLHandlerInterface -> a triple-matching type query of any RDF database returning a Vector-> QE QE returns a java.sql.Resultset, either passing the SQL one straight back, or building one itself from the results of the triple-matching type query. org.desire.rudolf.query.squishparser Squish.jj is the javacc parser file. The other files are all generated from this using javacc http://www.webgain.com/products/java_cc/. JavaCC can't be redistributed but it is free to download. For minor things you could edit the SquishParser.java file directly. You can build a query directly by talking to SquishParser - see test.desire.rudolf.query.ParserAPITest for details. org.desire.rudolf.query.modelcore Drivers and implementations for using SquishQL with the RDFModelCore API in org.desire.rudolf.rdf.* SQLModelCore is an implementation of RDFModelCore that talks to an SQL backend. It also implements QueryDirect and somewhat redundantly SQLHandlerInterface. MemModelCore is a wrapper for RDFGraph The *Drivers are for talking to the JDBC mechanism. Smoosh is for merging two graphs according to some principle. See http://rdfweb.org/2001/01/design/smush for details (I spelt it wrong ;) org/desire/rudolf/util This contains the Logger, which you need to edit to get more information (set the level) SearchReplace is a nasty text searcher and replacer which I use a lot. DateUtil is unfinshed, but was going to be used for Date datatyping and rewriting. TESTS test.desire.rudolf.app BasicScutterTest loads in a file then counts the number of triples in the database TwoFileScutterTest does the same with two files test.desire.rudolf.query AskTheWebTest runs one sql and one inmemory query as a simple test. InMemoryQueryTest runs lots of inmemory tests from the rdf manifest file: rdf/query-results-manifest.rdf SQLQueryTest does the same but for SQL, using the same manifest file. ParserAPITest shows you how to do tests by accessing the API directly. It also illustrates how you can make queries without using JDBC API. test.desire.rudolf.query.modelcore LiteralsTest isn't being used at the moment - it tries to find out the types of things it gets back - literals or resources. At present you can't get this information back, because ResultSetMetaData does typing by column, which isn't the case in the SQL database. SmooshTest tests a number of files and a number of predicates for smooshing. test.desire.rudolf.rdf RDFGraphTest simple RDF API test using TestConstants and TestGraph TripleSearcherTest does some triple matching tests