====== [[wp>Sesame (framework)|Sesame Triple Store]] ====== [[http://www.openrdf.org/|Sesame]] is an open source framework for storage, inferencing and querying of RDF data * {{sesame-a_generic_architecture_for_storing_and_querying_rdf_and_rdf_schema.pdf|Sesame: A Generic Architecture for Storing and Querying RDF and RDF Schema}} by [[jeen.broekstra@aidministrator.nl|Jeen Broekstra]] ([[http://www.openrdf.org/doc/papers/Sesame-ISWC2002.pdf|online]]) * {{sesame_lucene_sail.pdf|Sesame Lucene Sail}} ([[http://www.dfki.uni-kl.de/~sauermann/papers/Minack+2008.pdf|online]]) * How to apply a custom rule reasoner((See also [[sourceforgemailmessage>816739.16756.qm%40web50511.mail.re2.yahoo.com|CustomRuleReasoner transitiveProperties]] conversation)):
* check out [[http://repo.aduna-software.org/svn/org.openrdf/sesame-ext/|this repository]] * ''cd customrulereasoner/trunk && mvn install'' * the it depends, how you're used to create your repositories \\ console: put the ''customrulereasoner.jar'' into the according lib folder and use the following template: # # Sesame configuration template for a native RDF repository with # RDF Schema and Custom inferencing # @prefix rdfs: . @prefix rep: . @prefix sr: . @prefix sail: . @prefix ns: . @prefix custom: . @prefix ms: . [] a rep:Repository ; rep:repositoryID "xpd-154-sesamenative" ; rdfs:label "CustomRuleReasoner-NATIVE" ; rep:repositoryImpl [ rep:repositoryType "openrdf:SailRepository" ; sr:sailImpl [ sail:sailType "openrdf:CustomRuleReasoner" ; sail:delegate [ sail:sailType "openrdf:NativeStore" ; ns:tripleIndexes "spoc" ] ] ]. * write some rules (see below for examples) into a file and import the file into the ruledef context, approximately like so: repcon.add(FileUtils.openInputStream(new File("/templates/rules-skos.ttl")), "", RDFFormat.TURTLE, new Resource[] { CustomRuleReasonerSchema.RULEDEF_CONTEXT } ); * now just use the repository, easiest: LocalRepositoryManger LRM = new LocalRepositoryManager(new File("path/to/sesameroot/")); LRM.initialize(); Repository rep = LRM.getRepository("mycustom"); ... * you may run into the following problems: - class not found: make sure the jar is in place - unsupported sail type: make sure the factories are loaded * if problem occures in console: edit ''Console.java'' source code and enter the following line somewhere in the constructor or like this: ''SailRegistry.getInstance().add(new CustomRuleReasonerFactory());'' * if problem occurs in webapp or so, best is to write this line into a webappcontextlistener * if problem occurs in sesame-workbench (write a webappcontextlistener) and add to sesame-workbench's web.xml Jakobitsch Juergen, tschyrgie@yahoo.com, www.turnguard.com
* API to access SPARQL endpoint is [[http://www.openrdf.org/doc/alibaba/2.0-alpha2/apidocs/org/openrdf/repository/sparql/package-summary.html|here]]. ==== Maillist ==== * [[sourceforgemailmessage>4B05594F.3060502%40mail.ru|Mulgara sail in Sesame]] * [[sourceforgemailthread>21830943.9263.1274784064958.JavaMail.root%40zcs&forum_name=sesame-general|Alternative storage backends for Sesame]] * [[sourceforgemailmessage>4B0BBF43.9060105%40aduna-software.com|Authentication and authorization in Sesame (FOAF+SSL, OpenSSO)]] ([[http://blogs.sun.com/bblfish/entry/more_on_authorization_in_foaf|foaf+ssl: creating a web of trust without key signing parties]], [[http://blogs.sun.com/bblfish/entry/foaf_ssl_creating_a_global|FOAF & SSL: creating a global decentralised authentication protocol]], [[http://blogs.sun.com/bblfish/entry/foaf_ssl_adding_security_to|foaf+ssl: adding security to open distributed social networks]]) * [[sourceforgemailthread>4B0552EA.6040803%40poczta.onet.pl&forum_name=sesame-general|SWRL in Sesame]] (references [[http://www.med.univ-rennes1.fr/~cgolb/Protege2005/ReasoningParadigmsforSWRL-enabled%20Ontologies.pdf|Reasoning Paradigms for SWRL-enabled Ontologies]]) * [[sourceforgemailmessage>f89422bd1002140808j5158fc0fi260a0b4f0a6f1b91%40mail.gmail.com|Сalculating semantic similarity between objects that are represented as arbitrary RDF graphs]] * [[sourceforgemailthread>4BE5A4C5.1050109%40mail.ru&forum_name=sesame-general|Decoupling of pepared query from RepositoryConnection]] * [[sourceforgemailmessage>4AEB6E72.5060306%40mail.ru|Persisting and loading collections]] * [[sourceforgemailmessage>39D4350F1D43438D86B3779631CE7150%40AdrianPC|Pellet reasoner with Sesame]] * [[sourceforgemailmessage>4AB08964.70105%40mail.ru|IN- queries are slow and no way to influence optimizer]] * [[sourceforgemailmessage>1255030141.754.35.camel%40localhost|Performance of RDBMS sail]] * [[sourceforgemailmessage>4AB94535.6080006%40mail.ru|RDFS reasoner over RDBMS store is not implemented yet]], [[sourceforgemailthread>51a901720910050510t40624a64m83124d53675ae8b7%40mail.gmail.com&forum_name=sesame-general|Inferencer + RDBMS integration problems]] * [[sourceforgemailthread>4AC3900C.7010907%40mail.ru&forum_name=sesame-general|RDBMS repository store memory leak in Batch class]] (reported as [[http://www.openrdf.org/issues/browse/SES-686|SES-686]]) * [[sourceforgemailmessage>4AD79C20.5040206%40mail.ru|Query escaping]] (reported as [[http://www.openrdf.org/issues/browse/SES-688|SES-688]]) * [[sourceforgemailthread>711A6E44E5028648A8D15B1DC32E58E0017C3172%40scomp0038.wurnet.nl&forum_name=sesame-general|Filtering out illegal XML characters (0x0B) before doing a commit]] * [[sourceforgemailmessage>1268655494.17615.1364871361%40webmail.messagingengine.com|Why using of repository-specific ''ValueFactory'' is better]] * [[sourceforgemailmessage>4AA7E225.6090702%40mail.ru|Runtime dependency on jcl104-over-slf4j]] (reported as [[http://www.openrdf.org/issues/browse/SES-682|SES-682]]) (also see [[http://www.openrdf.org/forum/mvnforum/viewthread?thread=2034|Sesame and logging ]], [[sourceforgemailthread>711A6E44E5028648A8D15B1DC32E58E001FC14AD%40scomp0038.wurnet.nl&forum_name=sesame-general|Sesame logging configuration]] for solution how to enable log4j logging) ==== RDMBS store ==== * As to [[http://www.openrdf.org/doc/sesame2/2.2/users/userguide.html#section-rdbms-store-config|RDBMS store configuration notice]], RDBMS store can be configured as monolithic and as vertical schema that stores statements in a per-predicate table. In last case the queries like ''SELECT A, B FROM {_:node14fopd6qfx2065} A {B}'' become very inefficient, because all tables should be joined to get the result. Setting ''maxTripleTables'' property will switch on monolithic schema, if you set it to 2, it will put the first predicate used into it own table and everything else into a shared table, 3 will cause the first two predicates to have their own table. Generally, you want either 1 or 0 (infinity). * "sequenced" property: when set to false the system will use 64bits for URI, BNode, and Literal internal IDs. This results in the statement table being twice as big and requires much more memory to work with. However, it reduces some of the intermediate operations. Best to leave this setting alone. * "indexed" property creates or drops additional indexes to balance between load <-> retrieval efficiency. * ''HashManager'' is used to generate 64-bit hashes out of literals. The hash value is converted into a 32bit sequential number to save space. To use the 64bit values directly set ''RdbmsStore#setSequenced(false)'' before initializing an empty database (no existing tables)((See the complete discussion [[sourceforgemailthread>1256055781.32151.22.camel%40localhost&forum_name=sesame-general|in maillist]])). * Writes to the different tables are executed in different threads. That is why is there a need to have a "flusher" thread for each manager. Separate threads prevent dead locks between separate transactions. Some operations are global (assigning a value to an ID for example). These should not be executed within an isolated transaction, but shared to prevent conflicts. * All the values (URI, Literal, BNodes) are stored in the database and shared for all connections. However, to prevent this table from growing out of control, it must be pruned (particularly when the RDF store is cleared). When these value tables are pruned their version is incremented to indicate that any in-memory values will need to be restored in the database if they were looked up using as earlier version of the table. The version number (''RdbmsValue'') does not need to be persisted as it is only used to keep the in-memory values in-sync with recent changes to the database. ==== The details about Native store == * Native store performance can be influenced by defining the sequence of indices to use (e.g. ''nativeStore.setTripleIndexes("spoc,posc")'') ==== The details about [[http://www.openrdf.org/doc/elmo/1.5/|Elmo]] engine == * Create a beans ''Author'' which has a collection of ''Publications'': import java.util.Collection; import org.mycompany.common.vocabulary.CWA; import org.openrdf.elmo.annotations.rdf; @rdf(CWA.NAMESPACE + "auth") public class Author { @rdf(CWA.NAMESPACE + "auth/id") private int id; @rdf(CWA.NAMESPACE + "auth/name") private String name; @rdf(CWA.NAMESPACE + "auth/publications") private Collection publications; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Collection getPublications() { return publications; } public void setPublications(Collection publications) { this.publications = publications; } } import org.mycompany.common.vocabulary.CWA; import org.openrdf.elmo.annotations.rdf; @rdf(CWA.NAMESPACE + "pub") public class Publication { private int id; private String title; @rdf(CWA.NAMESPACE + "pub/id") public int getId() { return id; } public void setId(int id) { this.id = id; } @rdf(CWA.NAMESPACE + "pub/title") public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } } * Now use the following code to persist instance of ''Author'' object: import java.io.FileOutputStream; import java.io.IOException; import java.util.Arrays; import java.util.Collection; import org.openrdf.elmo.ElmoModule; import org.openrdf.elmo.sesame.SesameManager; import org.openrdf.elmo.sesame.SesameManagerFactory; import org.openrdf.model.Resource; import org.openrdf.repository.Repository; import org.openrdf.repository.RepositoryConnection; import org.openrdf.repository.RepositoryException; import org.openrdf.rio.RDFHandlerException; import org.openrdf.rio.rdfxml.RDFXMLWriter; public class Tester { public void testElmo(Repository repository) throws RepositoryException, RDFHandlerException, IOException { ElmoModule module = new ElmoModule(); module.addConcept(Author.class); module.addConcept(Publication.class); SesameManagerFactory factory = new SesameManagerFactory(module, repository); SesameManager manager = factory.createElmoManager(); Publication publication1 = new Publication(); publication1.setId(1); publication1.setTitle("cool"); Publication publication2 = new Publication(); publication2.setId(2); publication2.setTitle("super"); Author author = new Author(); author.setId(5); author.setName("It's me!"); author.setPublications(Arrays.asList(publication1, publication2)); manager.persist(author); final FileOutputStream fos = new FileOutputStream("elmo.rdf"); final RDFXMLWriter rdfWriter = new RDFXMLWriter(fos); final RepositoryConnection connection = repository.getConnection(); try { connection.export(rdfWriter, new Resource[0]); } finally { connection.close(); } fos.close(); } * The output follows. Notice that Elmo instantiates the collection using [[http://www.w3.org/TR/rdf-schema/#ch_containervocab|RDF Container]]: 5 It's me! 1 cool 2 super