RE: Import ontology information and imports ontology information
Thanks for your answer. I think that my problem is in the process of importing ontologies using OntDocumentManager. ¿Someone use something like this for importing ontologies that are imported in a root ontology?, I need to get all the information from all ontologies and using Model.read I only have information related root ontology. Thanks in advance. Urtza Iturraspe -Mensaje original- De: Joshua TAYLOR [mailto:joshuaaa...@gmail.com] Enviado el: martes, 28 de enero de 2014 17:02 Para: users@jena.apache.org Asunto: Re: Import ontology information and imports ontology information On Tue, Jan 28, 2014 at 10:00 AM, Iturraspe Barturen, Urtza urtza.iturra...@tecnalia.com wrote: This is my code. I get it, I obtain all the classes, properties, individuals from all ontologies but when I translate the model to an owl file I can’t open this with an ontology editor (Neon…) Someone has any idea? You didn't how the OWL ontology that you're generating, so it's not really clear whether it an OWL ontology editor _should_ be able to open it or not. Can you show that? If it's a legal OWL document, or if you can open it in other editors (e.g,. Protégé), then this sounds more like a question for the Neon mailing list than the Jena mailing list. Have you tried running the document through an OWL validator? -- Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
Re: Fuseki + tdb + reasoner config
Sorry, I missed this while travelling and just realized it hasn't been answered. There is no named graph support in the reasoners nor is there reasoner/tdb integration so that I'm afraid that what you want is not possible out of the box. Dave On 24/01/14 16:26, Rohana Rajapakse wrote: Hi, Can someone pass me a jena tdb config with a reasoner (say rdfs reasoner) that applies to all named-graphs. My application requirements are such that i need to insert/delete data into existing named-graphs as well as add new datasets into new named graphs on the fly. I will be making sparql queries against a given named-graph and/or the union graph. In both cases, I would like to find infered-triples. If the above is not possible, is it possible to configure Fuseki tdb to have inferred-triples in the union (default) graph. I am thinking of adding data into named graphs and querying them on the union graph. In this case, when data is inserted into named graphs, the inference engine should kick-in and add inferred triples into either into the corresponding named graph or if possible into the default union graph. Hope I explained my requirement clearly. Rohana
Re: Default graph issue (tdb-backed Fuseki)
On 24/01/14 09:52, Rohana Rajapakse wrote: Thanks Andy. I am now trying to use GenericRuleReasoner. The tdb config is given below. It works fine with data added to the default graph. The query you sent me does not show any triples when I insert data into a graph. I am not sure if the way I configure the inference engine is correct. Can you please see what is wrong. The defaultUnionGraph is a feature of SPARQL query processing - it's a read-only view of the data. It does not apply to the API (because updates have to go to the real default graph) which is what the inference engine is using. You might try using a named graph instead of ja:defaultGraph with a name of union: urn:x-arq:UnionGraph That gets you a read-only view similar to SPARQL (TDB actually does it differently for efficiency). Inference uses memory so there may be scale issues here. The other approach is to apply your rules while loading the data, expanding the triples once at load time - then at runtime, you are running with a non-inference dataset (which is faster). Andy Data Insert Query: == PREFIX owl: http://www.w3.org/2002/07/owl# INSERT DATA { GRAPH http://test { http://localhost:3030/resource/Kevin foaf:lastName Fernando . http://localhost:3030/resource/Peter foaf:lastName Fernando . http://localhost:3030/resource/Kevin2 foaf:lastName Fernando . http://localhost:3030/resource/Kevin owl:sameAs http://localhost:3030/resource/Peter . http://localhost:3030/resource/Peter owl:sameAs http://localhost:3030/resource/Kevin2 . } } Select Query: == PREFIX owl: http://www.w3.org/2002/07/owl# SELECT ?s ?s1 ?s2 { { ?s owl:sameAs ?o } UNION { GRAPH urn:x-arq:DefaultGraph { ?s1 owl:sameAs ?o1 } } UNION { GRAPH ?g2 { ?s2 owl:sameAs ?o2 } } } TDB Config file: @prefix :# . @prefix fuseki: http://jena.apache.org/fuseki# . @prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# . @prefix rdfs:http://www.w3.org/2000/01/rdf-schema# . @prefix tdb: http://jena.hpl.hp.com/2008/tdb# . @prefix ja: http://jena.hpl.hp.com/2005/11/Assembler# . [] rdf:type fuseki:Server ; # Timeout - server-wide default: milliseconds. # Format 1: 1000 -- 1 second timeout # Format 2: 1,6 -- 10s timeout to first result, then 60s timeout to for rest of query. # See java doc for ARQ.queryTimeout # ja:context [ ja:cxtName arq:queryTimeout ; ja:cxtValue 1 ] ; # ja:loadClass your.code.Class ; fuseki:services ( #service_rulesinf ) . # TDB [] ja:loadClass com.hp.hpl.jena.tdb.TDB . tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset . tdb:GraphTDBrdfs:subClassOf ja:Model . #service_rulesinf rdf:type fuseki:Service ; rdfs:label TDB Service with Generic Rule Reasoner ; fuseki:namedata ; # http://host/data fuseki:serviceQuerysparql ; # SPARQL query service fuseki:serviceQueryquery ; fuseki:serviceUpdate update ; fuseki:serviceUpload upload ; fuseki:serviceReadWriteGraphStore data ; fuseki:dataset#dataset ; . #dataset a ja:RDFDataset; ja:defaultGraph [ a ja:InfModel; ja:reasoner [ ja:reasonerURL http://jena.hpl.hp.com/2003/GenericRuleReasoner ; ja:rulesFrom file:inference_rules.rules ; ]; ja:baseModel #data_and_ontology_graph ]; . #data_and_ontology_graph a tdb:GraphTDB ; tdb:location MYTDB ; # tdb:unionDefaultGraph true ; . Rules File: @prefix owl: http://www.w3.org/2002/07/owl# . @include OWLMini. [rule1: (?S1 owl:sameAs ?S2),(?S2 owl:sameAs ?S3) -(?S1 owl:sameAs ?S3) ] On 23 January 2014 16:11, Andy Seaborne a...@apache.org wrote: Hi Rohana, #tdb_dataset_read rdf:type tdb:DatasetTDB ; tdb:location MYTDB ; tdb:unionDefaultGraph true ; #tdb_dataset_readwrite rdf:type tdb:DatasetTDB ; tdb:location MYTDB ; . The two descriptions of the datasets point to the same set of files so, internally, there is one TDB dataset engine, which has to manage all accesses. tdb:unionDefaultGraph true is going to set a property of the engine, and not be sensitive to the route used to name it, so it sets it on the shared engine. It will apply to both services. Sorry that wasn't documented anywhere. Andy On 23/01/14 15:06, Rohana Rajapakse wrote: Hi Andy, I have tested inserting and querying data using with two tdb configs. Having
API : detecting isInTransaction and closed Dataset ?
Hi I have an API that wraps Jena's, and I want to detect isInTransaction in all cases. Apparently this implies to detect whether a Dataset is closed. Currently I'm obliged (not sure !) to do : public boolean isInTransaction() { try { return dataset.isInTransaction(); } catch ( JenaTransactionException e){ if (e.getMessage().contains( Already closed)) return false; else throw e; } } Is there a better way ? -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Re: BlockException: No such block
Andy, Adding the code as mentioned in your earlier post I get the following: RecordRangeIterator.iterator -- No such block (pageId=117440534, fromRec=, toRec=0001) Thanks Steve Groeger From: Andy Seaborne a...@apache.org To: users@jena.apache.org, Date: 26/01/2014 19:57 Subject:Re: BlockException: No such block Steve, I'm not getting systematic failures, even after running multiple times for well over 4 hours. I saw one failure but had several runs with no failure at all. Looks like my setup does not have the right timing. I've changed the internal exception point to print (stderr) some details and exit the VM: if ( ! pageMgr.valid(pageId) ) { String msg = RecordRangeIterator.iterator -- No such block (pageId=+ pageId+ , fromRec=+fromRec+, toRec=+toRec+ ) ; System.err.println(msg) ; System.exit(0) ; throw new BlockException(msg) ; } Do you have some test servers you could run your test code with the development Jena? Ideally, running multiple tests so we build up a number of outcomes to see if there is a pattern. https://repository.apache.org/content/repositories/snapshots/org/apache/jena/ apache-jena/2.11.2-SNAPSHOT for a binary build or use maven directly on apache-jena-libs. The other thing that may well be needed is a more sensitive test case. Running in the debugger is too slow to be practical. What other patterns of transactions have you tried? Andy On 24/01/14 16:00, Steve Groeger wrote: Andy, I am currently running with the TDB being written to my harddrive (of my Linux RHEL 64bit machine). This failure can sometimes take up to 3-4 hours before it fails. I have tried using a RAM disk but it fills up before the failure occurs as I can only give it 10Gb of space and due the test the TDB does get very large due to all the creates deletes. I am running on RHEL 6.4 with the following JVM: java version 1.6.0 Java(TM) SE Runtime Environment (build pxa6460sr15-20131017_01(SR15)) IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux amd64-64 jvmxa6460sr15-20131016_170922 (JIT enabled, AOT enabled) J9VM - 20131016_170922 JIT - r9_20130920_46510ifx2 GC - GA24_Java6_SR15_20131016_1337_B170922) JCL - 20131015_01 Thanks Steve Groeger IBM WebSphere Service Registry Development MP 211, Hursley Tel: (44) 1962 816911 Mobex: 279990 Mobile: 07718 517 129 Fax (44) 1962 816800 Lotus Notes: Steve Groeger/UK/IBM Internet: groe...@uk.ibm.com From: Andy Seaborne a...@apache.org To: users@jena.apache.org, Date: 24/01/2014 13:57 Subject:Re: BlockException: No such block On 24/01/14 07:18, Steve Groeger wrote: It took 16690 iterations of the writer thread to obtain this error but as you can see the reader thread gets the exception when trying to execute this line: How long in time did that take? As it may be a timing issue, do you have an SSD? Running java version 1.7.0_51 OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.13.10.1) OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode) Andy Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
2.11.1 TBD throws ClosedException: already closed
Hi Jena 2.11.1 TBD throws ClosedException: already closed, when 2.11.0 did not. The test below involves adding a triple in a named model, closing the model, re-opening the dataset and the same model. Note that closing the whole dataset instead of the model works fine. Here is the test (sorry , it's in Scala): @Test def storeTripleinNamedDatasetandRetrieve() { val directory = new File(bbtest); directory.mkdirs(); val dataset = TDBFactory.createDataset(directory.getAbsolutePath()); val modelName = test // test val model = dataset.getNamedModel(modelName); val obj = a val subject = c val predicate = model.createProperty(p); val subjectResource = model.createResource(subject); val objectResource = model.createResource(obj); model.add(model.createStatement(subjectResource, predicate, objectResource)) if (!model.isClosed()) { model.close(); // com.hp.hpl.jena.shared.ClosedException: already closed //dataset.close(); // OK! System.out.println(Test TDB: model closed:\t + dataset) } { val dataset = TDBFactory.createDataset(directory.getAbsolutePath()); val model = dataset.getNamedModel(modelName); System.out.println(Test TDB: model reopened:\t + dataset) println( model.size() + model.size()) val sIter = model.listStatements() for (st - sIter) { println(st) } assertTrue(model.size == 1, model.size == 1); } Complete code: http://svn.code.sf.net/p/eulergui/code/trunk/eulergui/src/test/scala/eulergui/jena/JenaTDBTest.scala -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Re: Fuseki + tdb + reasoner config
Thanks Dave. regards Rohana On 29 January 2014 08:58, Dave Reynolds dave.e.reyno...@gmail.com wrote: Sorry, I missed this while travelling and just realized it hasn't been answered. There is no named graph support in the reasoners nor is there reasoner/tdb integration so that I'm afraid that what you want is not possible out of the box. Dave On 24/01/14 16:26, Rohana Rajapakse wrote: Hi, Can someone pass me a jena tdb config with a reasoner (say rdfs reasoner) that applies to all named-graphs. My application requirements are such that i need to insert/delete data into existing named-graphs as well as add new datasets into new named graphs on the fly. I will be making sparql queries against a given named-graph and/or the union graph. In both cases, I would like to find infered-triples. If the above is not possible, is it possible to configure Fuseki tdb to have inferred-triples in the union (default) graph. I am thinking of adding data into named graphs and querying them on the union graph. In this case, when data is inserted into named graphs, the inference engine should kick-in and add inferred triples into either into the corresponding named graph or if possible into the default union graph. Hope I explained my requirement clearly. Rohana
Update an existing TDB with a RDF file
Hello there, Here is my question. I have an existing TDB containing triples. I have a RDF file and i want to update the existing TDB with the data contained in the RDF file. If nodes already exist they should be updated and new data added. Is it possible to do it with the Jena API ?
Re: Update an existing TDB with a RDF file
Cher Frédéric, You just have to use the basic RDF API : http://jena.apache.org/tutorials/rdf_api.html with the TDB API : http://jena.apache.org/documentation/tdb/java_api.html Note that update nodes is not the right wording for what happens. An RDF model is bascally a collection of triples. So adding a p o2 . to a model that contains already: a p o1 . will not update a ; there is just one more triples having a as subject. 2014-01-29 Frederic Toublanc frederic.toubl...@telemis.com Hello there, Here is my question. I have an existing TDB containing triples. I have a RDF file and i want to update the existing TDB with the data contained in the RDF file. If nodes already exist they should be updated and new data added. Is it possible to do it with the Jena API ? -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Re: Update an existing TDB with a RDF file
For your convenience, I pasted together the first lines of both API mentioned: // Make a TDB-backed dataset String directory = MyDatabases/Dataset1 ; Dataset dataset = TDBFactory.createDataset(directory) ; dataset.begin(ReadWrite.READ) ; // Get model inside the transaction Model model = dataset.getDefaultModel(); paste from basic RDF API Model model2 = ModelFactory.createDefaultModel(); String inputFileName = f; // use the FileManager to find the input file InputStream in = FileManager.get().open( inputFileName ); if (in == null) { throw new IllegalArgumentException( File: + inputFileName + not found); } // read the RDF/XML file model2.read(in, null); * model.add(model2);* dataset.end(); 2014-01-29 Jean-Marc Vanel jeanmarc.va...@gmail.com Cher Frédéric, You just have to use the basic RDF API : http://jena.apache.org/tutorials/rdf_api.html with the TDB API : http://jena.apache.org/documentation/tdb/java_api.html Note that update nodes is not the right wording for what happens. An RDF model is bascally a collection of triples. So adding a p o2 . to a model that contains already: a p o1 . will not update a ; there is just one more triples having a as subject. 2014-01-29 Frederic Toublanc frederic.toubl...@telemis.com Hello there, Here is my question. I have an existing TDB containing triples. I have a RDF file and i want to update the existing TDB with the data contained in the RDF file. If nodes already exist they should be updated and new data added. Is it possible to do it with the Jena API ? -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Re: Update an existing TDB with a RDF file
Frederic, are you sure this hasn't been done before? I've used JenaBean [1], but I know there are at least several other similar projects. Martynas [1] https://code.google.com/p/jenabean/ On Wed, Jan 29, 2014 at 2:58 PM, Frederic Toublanc frederic.toubl...@telemis.com wrote: Ok thx a lot :) I will implement a way to map a java object model to tripples :) 2014/1/29 Jean-Marc Vanel jeanmarc.va...@gmail.com For your convenience, I pasted together the first lines of both API mentioned: // Make a TDB-backed dataset String directory = MyDatabases/Dataset1 ; Dataset dataset = TDBFactory.createDataset(directory) ; dataset.begin(ReadWrite.READ) ; // Get model inside the transaction Model model = dataset.getDefaultModel(); paste from basic RDF API Model model2 = ModelFactory.createDefaultModel(); String inputFileName = f; // use the FileManager to find the input file InputStream in = FileManager.get().open( inputFileName ); if (in == null) { throw new IllegalArgumentException( File: + inputFileName + not found); } // read the RDF/XML file model2.read(in, null); * model.add(model2);* dataset.end(); 2014-01-29 Jean-Marc Vanel jeanmarc.va...@gmail.com Cher Frédéric, You just have to use the basic RDF API : http://jena.apache.org/tutorials/rdf_api.html with the TDB API : http://jena.apache.org/documentation/tdb/java_api.html Note that update nodes is not the right wording for what happens. An RDF model is bascally a collection of triples. So adding a p o2 . to a model that contains already: a p o1 . will not update a ; there is just one more triples having a as subject. 2014-01-29 Frederic Toublanc frederic.toubl...@telemis.com Hello there, Here is my question. I have an existing TDB containing triples. I have a RDF file and i want to update the existing TDB with the data contained in the RDF file. If nodes already exist they should be updated and new data added. Is it possible to do it with the Jena API ? -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Re: Update an existing TDB with a RDF file
Ok thx a lot :) You just have saved me a lot of time lol 2014/1/29 Martynas Jusevičius marty...@graphity.org Frederic, are you sure this hasn't been done before? I've used JenaBean [1], but I know there are at least several other similar projects. Martynas [1] https://code.google.com/p/jenabean/ On Wed, Jan 29, 2014 at 2:58 PM, Frederic Toublanc frederic.toubl...@telemis.com wrote: Ok thx a lot :) I will implement a way to map a java object model to tripples :) 2014/1/29 Jean-Marc Vanel jeanmarc.va...@gmail.com For your convenience, I pasted together the first lines of both API mentioned: // Make a TDB-backed dataset String directory = MyDatabases/Dataset1 ; Dataset dataset = TDBFactory.createDataset(directory) ; dataset.begin(ReadWrite.READ) ; // Get model inside the transaction Model model = dataset.getDefaultModel(); paste from basic RDF API Model model2 = ModelFactory.createDefaultModel(); String inputFileName = f; // use the FileManager to find the input file InputStream in = FileManager.get().open( inputFileName ); if (in == null) { throw new IllegalArgumentException( File: + inputFileName + not found); } // read the RDF/XML file model2.read(in, null); * model.add(model2);* dataset.end(); 2014-01-29 Jean-Marc Vanel jeanmarc.va...@gmail.com Cher Frédéric, You just have to use the basic RDF API : http://jena.apache.org/tutorials/rdf_api.html with the TDB API : http://jena.apache.org/documentation/tdb/java_api.html Note that update nodes is not the right wording for what happens. An RDF model is bascally a collection of triples. So adding a p o2 . to a model that contains already: a p o1 . will not update a ; there is just one more triples having a as subject. 2014-01-29 Frederic Toublanc frederic.toubl...@telemis.com Hello there, Here is my question. I have an existing TDB containing triples. I have a RDF file and i want to update the existing TDB with the data contained in the RDF file. If nodes already exist they should be updated and new data added. Is it possible to do it with the Jena API ? -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc:// irc.freenode.net#eulergui -- Jean-Marc Vanel Déductions SARL - Consulting, services, training, Rule-based programming, Semantic Web http://deductions-software.com/ +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
Re: [ANN] Jena 2.11.1
Comments inline: On 28/01/2014 22:36, Michael Brunnbauer bru...@netestate.de wrote: Hello Rob, On Tue, Jan 28, 2014 at 02:20:22PM -0800, Rob Vesse wrote: The 2.11.0 release was only last week so do not expect another official release for a while. OK The somewhat toy query in your bug seems to imply that you have some set of SPARQL smoke tests or similar that you use. It's a complete minimal example. I have an application that broke due to this one when I upgraded to 1.0.1. Really, that is actually a real application query. That seems like an odd query to use in the real world although I guess the intention is that it guarantees you one possibly empty row? Note that we publicise on the developer list (d...@jena.apache.org) when we are about to do a release and specifically request users beyond just the committers test the release candidates before we go ahead and make the release - http://mail-archives.apache.org/mod_mbox/jena-dev/201401.mbox/%3c52DAF10E.7 050...@apache.org%3e If developers who rely heavily on Jena are not subscribed to that list and do not take the time to test release candidates in advance and tell us if they break things for them we don't find out about these things until after the release is done. As I said in a previous email while we try to provide as many tests as we can think of (Jena as a whole has ~31K at the moment) once the code is out in the wild users do things with it that we don't expect or have queries/data that exposes corner cases we haven't covered. If you have a set of mission critical queries then contributing those as test cases would be most appreciated and reduces the risks that we unintentionally introduce regressions in the future. BTW: We are not able to implement a feature for the same application because of https://issues.apache.org/jira/browse/JENA-494 Contributions are always welcome, you are free to go look at the code and provide a fix yourselves. Everyone is volunteers here and a side effect of that is that people tend to focus their energy on things that matter to them. Rob Regards, Michael Brunnbauer -- ++ Michael Brunnbauer ++ netEstate GmbH ++ Geisenhausener Straße 11a ++ 81379 München ++ Tel +49 89 32 19 77 80 ++ Fax +49 89 32 19 77 89 ++ E-Mail bru...@netestate.de ++ http://www.netestate.de/ ++ ++ Sitz: München, HRB Nr.142452 (Handelsregister B München) ++ USt-IdNr. DE221033342 ++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer ++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel
Re: FUSEKI Concurrent runs issues
We don't give any specific guarantees about concurrent query performance because it depends on various factors. At the TDB layer you have the issue of caches, depending on the query load you may have different queries modifying the caches which can result in data one query uses dropping out of the cache forcing it to go to the memory mapped data structures for the lookups. Potentially you could get in a race conditions where the queries keep forcing each other to get cache misses. At the ARQ layer the evaluation of the query produces some load on the JVM (both in terms of heap memory usage and CPU usage) and depending on the query there may be more CPU/memory usage (or both) needed resulting in slowdowns for all queries. On the other hand for simple queries this load may be light and the queries don't compete for resources too much so the benefits of concurrent evaluation shows through. At the Fuseki layer you may also have outbound bandwidth constraints, generally Fuseki writes results for most formats to the client as soon as it has them available so if you have poor outbound bandwidth there may be a bottleneck here. Also if you chose a format that cannot be stream written (e.g. Text) then all the results get cached into memory before being written out which can result in high heap memory usage and you possibly start to hit swap and GC issues. In terms of your specific queries your first query makes heavy use of STR() which as Andy pointed out previously requires looking at the actual string value of the term which means a round trip to the node table to lookup this value. AFAIK there is a cache on top of this so you can get into the frequent cache miss behaviour I talked about. In your second query the functions are predominantly on dates which are inlined in TDB meaning the value can be read directly from the internal node ID without a trip to the node table which will be much faster since there is no cache contention involved. Rob On 29/01/2014 05:11, Ewa Szwed ewaszy...@gmail.com wrote: Hi, Since this group is so responsive I would like to sick advise in another field: Area: concurrent calls to Fuseki: I am performing concurrent SPARQL queries against freebase data using Fuseki and have noticed that for some queries running them in parallel versus in series results in a big difference in running time, whereas for others the difference in time is minimal or non-existent. For example my first query (notice new FILTER placement that improves performance a lot for me!): prefix fb: http://rdf.freebase.com/ns/ http://rdf.freebase.com/ns/ prefix fn: http://www.w3.org/2005/xpath-functions# http://www.w3.org/2005/xpath-functions prefix xsd: http://www.w3.org/2001/XMLSchema# http://www.w3.org/2001/XMLSchema select ?entity ?mID ?height ?wikipedia_url where { { ?mID_raw fb:type.object.type fb:people.person . ?mID_raw fb:type.object.name ?entity . ?mID_raw fb:people.person.height_meters ?height_in_meters . ?mID_raw fb:common.topic.topic_equivalent_webpage ?wikipedia_url . FILTER (lang(?entity) = en regex (str(?wikipedia_url), en.wikipedia, i) !regex (str(?wikipedia_url), curid=, i)) . } BIND(REPLACE(str(?mID_raw), http://rdf.freebase.com/ns/; http://rdf.freebase.com/ns/, ) as ?mID) BIND(round(xsd:float(?height_in_meters)* xsd:float(100))/ xsd:float(100) as ?height_rounded) BIND(xsd:float(?height_in_meters)* xsd:float(3.2808) AS ?height_in_feet) BIND(str(?height_in_feet) AS ?feet_str_value) BIND(str(floor(xsd:decimal(?feet_str_value))) AS ?feet_final) BIND(round(xsd:float(?height_in_feet - floor(xsd:decimal(?feet_str_value))) * 12) AS ?inches) BIND(str(floor(xsd:decimal(str(?inches as ?inches_final) BIND(fn:concat(?feet_final, ' ,?inches_final,\ (,?height_rounded, m) ) AS ?height) } Has the following runtime for a single query: 2 mins, 44 seconds and for 5 concurrent queries: 24 mins, 27 seconds Whereas for our second query: prefix fb: http://rdf.freebase.com/ns/ http://rdf.freebase.com/ns/ prefix fn: http://www.w3.org/2005/xpath-functions# http://www.w3.org/2005/xpath-functions select ?entity ?mID ?age_at_death ?wikipedia_url where { { ?mID_raw fb:type.object.type fb:people.person . ?mID_raw fb:type.object.type fb:people.deceased_person . ?mID_raw fb:type.object.name ?entity . ?mID_raw fb:people.deceased_person.date_of_death ?date_of_death . ?mID_raw fb:people.person.date_of_birth ?date_of_birth . ?mID_raw fb:common.topic.topic_equivalent_webpage ?wikipedia_url . FILTER (lang(?entity) = en regex (str(?wikipedia_url), en.wikipedia, i) !regex (str(?wikipedia_url), curid=, i)). } BIND(REPLACE(str(?mID_raw), http://rdf.freebase.com/ns/; http://rdf.freebase.com/ns/, ) as ?mID) BIND(fn:year-from-dateTime(?date_of_birth) AS ?year_of_birth) BIND(fn:year-from-dateTime(?date_of_death) AS
Re: [ANN] Jena 2.11.1
Hello Rob, On Wed, Jan 29, 2014 at 09:12:04AM -0800, Rob Vesse wrote: It's a complete minimal example. I have an application that broke due to this one when I upgraded to 1.0.1. Really, that is actually a real application query. No - a complete minimal example. This is one of the real queries: PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema# PREFIX dcterms: http://purl.org/dc/terms/ PREFIX lio: http://purl.org/net/lio# select ?img (SAMPLE(?x) as ?xs) ?p (SAMPLE(?xtype) as ?xtypes) where { { graph ?s { { ?x ?p http://dbpedia.org/resource/Graph_(mathematics).?img a lio:Image. } UNION { ?x1 a http://dbpedia.org/resource/Graph_(mathematics). ?x ?p ?x1.?img a lio:Image. } OPTIONAL { ?x a ?xtype }}} UNION { ?d1 http://dbpedia.org/ontology/isPartOf http://dbpedia.org/resource/Graph_(mathematics) FILTER isIRI(?d1) FILTER regex(str(?d1),http://dbpedia.org/resource/;) graph ?s { { ?x ?p ?d1 } UNION { ?x1 a ?d1. ?x ?p ?x1 } } graph ?s { ?img a lio:Image. } OPTIONAL { graph ?s { ?x a ?xtype } } } UNION { SERVICE http://127.0.0.1:3030/datasets/query { ?d1 rdfs:subClassOf+ http://dbpedia.org/resource/Graph_(mathematics). } graph ?s { { ?x ?p ?d1 } UNION { ?x1 a ?d1. ?x ?p ?x1 } } graph ?s { ?img a lio:Image. } OPTIONAL { graph ?s { ?x a ?xtype } } } FILTER(?p != http://www.w3.org/1999/02/22-rdf-syntax-ns#type) FILTER(?p != http://www.w3.org/2002/07/owl#sameAs) FILTER(?p != lio:hasVisualPart ) } group by ?img ?p if(strstarts(str(?x),http://www.imagesnippets.com/imgtag/images/;) contains(str(?x),#Region),region,?x) The first and the second or third outer UNION - together with the FILTERs at the bottom seem to cause the error. Can I skip the time consuming step of producing a minimal example next time? It took me maybe an hour. If developers who rely heavily on Jena are not subscribed to that list and do not take the time to test release candidates in advance and tell us if they break things for them we don't find out about these things until after the release is done. That's OK for me. As I said in a previous email while we try to provide as many tests as we can think of (Jena as a whole has ~31K at the moment) How about this one ? http://www.brunni.de/pdp1/ queries/data that exposes corner cases we haven't covered. If you have a set of mission critical queries then contributing those as test cases would be most appreciated and reduces the risks that we unintentionally introduce regressions in the future. Why not use the minimal example as new test case ? BTW: We are not able to implement a feature for the same application because of https://issues.apache.org/jira/browse/JENA-494 Contributions are always welcome, you are free to go look at the code and provide a fix yourselves. Yes. I am free to learn SPARQL Algebra, the inner workings and optimizations of it in Jena, to get more familiar with Java and Java IDEs and then to fix the things you guys overlooked. I'd prefer not to and to stay in Jena quality management. However, I could 1) pay my employee more familiar with Java to look into this and submit a fix 2) do a donation 3) put a bounty on it What would you prefer ? Regards, Michael Brunnbauer -- ++ Michael Brunnbauer ++ netEstate GmbH ++ Geisenhausener Straße 11a ++ 81379 München ++ Tel +49 89 32 19 77 80 ++ Fax +49 89 32 19 77 89 ++ E-Mail bru...@netestate.de ++ http://www.netestate.de/ ++ ++ Sitz: München, HRB Nr.142452 (Handelsregister B München) ++ USt-IdNr. DE221033342 ++ Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer ++ Prokurist: Dipl. Kfm. (Univ.) Markus Hendel pgpgaeKCfFmjE.pgp Description: PGP signature
Re: Can I pass a model in a parameter list?
Hi again My project is basically: 1) to come in with an abstract/ scientific article, 2) call an existing Annotator from Parser.java, 3) get good labels, and 4) return model with all the new labels to Parser.java. I have created my jena model in Parser.java, and wish to call TextAnnotation.java to load the preferred labels into my model, via the property AnnotationLabel in TextAnnotation.java. The labels are loaded in the printAnnotations method of class TextAnnotation. (I need to return model back to Parser.java.) I wish to use only one model. I am running into compile time errors. THANKS in ADVANCE for your help. Mona import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Property; public class Parser { public static Model model = ModelFactory.createDefaultModel(); /* create the Resource, using the product URI */ Resource softwareproduct = model.createResource(urlAddress); //create the properties Property extracteddata = model.createProperty( http://www.mydirectory.com/softwareproduct#extracteddata;); Property annotationLabel = model.createProperty( http://www.mydirectory.com/softwareproduct#softwareannotation;); ... SAXparsingExtractedText saxparser = new SAXparsingExtractedText(); abstractinfo = saxparser.parseDocument(urlAddress); softwareproduct.addProperty(extracteddata, abstractinfo); //--- I call the TEXT ANNOTATOR with abstractinfo and model (??) and url address TextAnnotation annotateText = new TextAnnotation(); annotateText.stringToAnnotate(abstractinfo, model, urlAddress); } import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; public class TextAnnotation { static final String REST_URL = http://data.bioontology.org;; static final ObjectMapper mapper = new ObjectMapper(); public void stringToAnnotate(String abstractInfo, Model model2, String URLaddress) throws UnsupportedEncodingException { String textToAnnotate = URLEncoder.encode(abstractInfo, UTF-8); Resource SoftwareProduct = model2.createResource(URLaddress); Property AnnotationLabel = model2.createProperty( http://www.mydirectory.com/softwareproduct#softwareannotation;); // Get just annotations JsonNode annotations = jsonToNode(get(REST_URL + /annotator?ontologies=NCITtext= + textToAnnotate)); printAnnotations(annotations); } private model2 printAnnotations(JsonNode annotations) { for (JsonNode annotation : annotations) { // Get the details for the class that was found in the annotation and print JsonNode classDetails = jsonToNode(get(annotation.get(annotatedClass).get(links).get(self).asText())); //Don't print preferred Labels, load prefLabels into the model // System.out.println(\tprefLabel: + classDetails.get(prefLabel).asText()); SoftwareProduct.addProperty(AnnotationLabel, classDetails.get(prefLabel).asText()); } } } } private static JsonNode jsonToNode(String json) { JsonNode root = null; try { root = mapper.readTree(json); } catch (JsonProcessingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return root; } private static String get(String urlToGet) { URL url; HttpURLConnection conn; BufferedReader rd; String line; String result = ; try { url = new URL(urlToGet); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(GET); conn.setRequestProperty(Authorization, apikey token= + API_KEY); conn.setRequestProperty(Accept, application/json); rd = new BufferedReader( new InputStreamReader(conn.getInputStream())); while ((line = rd.readLine()) != null) { result += line; } rd.close(); } catch (Exception e) { e.printStackTrace(); } return result; } } Compilation errors: Exception in thread main java.lang.Error: Unresolved compilation problems: SoftwareProduct cannot be resolved AnnotationLabel cannot be resolved to a variable at TextAnnotation.printAnnotations(TextAnnotation.java:47) at TextAnnotation.stringToAnnotate(TextAnnotation.java:32) at Parser.getTitle(Parser.java:291) at Parser.getAllUrlNames(Parser.java:118) at Parser.main(Parser.java:723) On Mon,
Re: Can I pass a model in a parameter list?
On Wed, Jan 29, 2014 at 4:03 PM, Mona Salem monasalem...@gmail.com wrote: Compilation errors: Exception in thread main java.lang.Error: Unresolved compilation problems: SoftwareProduct cannot be resolved AnnotationLabel cannot be resolved to a variable at TextAnnotation.printAnnotations(TextAnnotation.java:47) at TextAnnotation.stringToAnnotate(TextAnnotation.java:32) at Parser.getTitle(Parser.java:291) at Parser.getAllUrlNames(Parser.java:118) at Parser.main(Parser.java:723) The fact that there's a stack trace of this code running makes it seem like this isn't purely a compilation error. Did you compile part of the project separately from others, or something like that? In any case, this doesn't sound like a Jena issue. E.g., AnnotationLabel cannot be resolved to a variable The code you've provided doesn't look right, in the first place. E.g., public class TextAnnotation { static final String REST_URL = http://data.bioontology.org;; static final ObjectMapper mapper = new ObjectMapper(); // ... private model2 printAnnotations(JsonNode annotations) { for (JsonNode annotation : annotations) { // Get the details for the class that was found in the annotation and print JsonNode classDetails = jsonToNode(get(annotation.get(annotatedClass).get(links).get(self).asText())); //Don't print preferred Labels, load prefLabels into the model // System.out.println(\tprefLabel: + classDetails.get(prefLabel).asText()); SoftwareProduct.addProperty(AnnotationLabel, classDetails.get(prefLabel).asText()); } } } } ends with too many closing braces. This isn't compilable code. Even if the braces were right, the line SoftwareProduct.addProperty(AnnotationLabel, classDetails.get(prefLabel).asText()); references a variable AnnotationLabel, but it's nowhere to be found. That's why you'd get that particular error message. This isn't particular to Jena at all. If you're not, I'd suggest that you use a Java aware IDE such as Eclipse or NetBeans that can help with these sorts of Java issues. For non-Jena related questions, you should probably try a non-Jena specific mailing list or QA site (e.g., StackOverflow). //JT -- Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
Re: Can I pass a model in a parameter list?
I am using Eclipse actually. I am working with a jena model and can print out my triples. The problem that I am running into is adding a property to my model in a second class; most properties are added in the Parser class, except for the annotation labels. I am calling a third party api(?TextAnnotations.java) and wish to load the labels into my model there. This is a jena question. I do not know how to pass the model in a parameter list, and have the object returned to Parser.java. Sorry to be persistent, but this is how I perceive the problem. Mona On Wed, Jan 29, 2014 at 1:51 PM, Rob Vesse rve...@dotnetrdf.org wrote: Your code is not complete and you haven't shown how you run your code (i.e. command line invocation) so we can only guess at the cause of the problem However your error is a standard Java compiler error completely unrelated to Jena and indicates one of two things: 1 - You do not have the appropriate import statements at the start of your Java file 2 - You're trying to run a single Java file and don't have your compiled code for those classes available on the class path Rob On 29/01/2014 13:03, Mona Salem monasalem...@gmail.com wrote: Hi again My project is basically: 1) to come in with an abstract/ scientific article, 2) call an existing Annotator from Parser.java, 3) get good labels, and 4) return model with all the new labels to Parser.java. I have created my jena model in Parser.java, and wish to call TextAnnotation.java to load the preferred labels into my model, via the property AnnotationLabel in TextAnnotation.java. The labels are loaded in the printAnnotations method of class TextAnnotation. (I need to return model back to Parser.java.) I wish to use only one model. I am running into compile time errors. THANKS in ADVANCE for your help. Mona import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Property; public class Parser { public static Model model = ModelFactory.createDefaultModel(); /* create the Resource, using the product URI */ Resource softwareproduct = model.createResource(urlAddress); //create the properties Property extracteddata = model.createProperty( http://www.mydirectory.com/softwareproduct#extracteddata;); Property annotationLabel = model.createProperty( http://www.mydirectory.com/softwareproduct#softwareannotation;); ... SAXparsingExtractedText saxparser = new SAXparsingExtractedText(); abstractinfo = saxparser.parseDocument(urlAddress); softwareproduct.addProperty(extracteddata, abstractinfo); //--- I call the TEXT ANNOTATOR with abstractinfo and model (??) and url address TextAnnotation annotateText = new TextAnnotation(); annotateText.stringToAnnotate(abstractinfo, model, urlAddress); } import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; public class TextAnnotation { static final String REST_URL = http://data.bioontology.org;; static final ObjectMapper mapper = new ObjectMapper(); public void stringToAnnotate(String abstractInfo, Model model2, String URLaddress) throws UnsupportedEncodingException { String textToAnnotate = URLEncoder.encode(abstractInfo, UTF-8); Resource SoftwareProduct = model2.createResource(URLaddress); Property AnnotationLabel = model2.createProperty( http://www.mydirectory.com/softwareproduct#softwareannotation;); // Get just annotations JsonNode annotations = jsonToNode(get(REST_URL + /annotator?ontologies=NCITtext= + textToAnnotate)); printAnnotations(annotations); } private model2 printAnnotations(JsonNode annotations) { for (JsonNode annotation : annotations) { // Get the details for the class that was found in the annotation and print JsonNode classDetails = jsonToNode(get(annotation.get(annotatedClass).get(links).get(self).a sText())); //Don't print preferred Labels, load prefLabels into the model // System.out.println(\tprefLabel: + classDetails.get(prefLabel).asText()); SoftwareProduct.addProperty(AnnotationLabel, classDetails.get(prefLabel).asText()); } } } } private static JsonNode jsonToNode(String json) { JsonNode root = null; try { root = mapper.readTree(json); } catch (JsonProcessingException e) { e.printStackTrace(); } catch
Re: Can I pass a model in a parameter list?
On Wed, Jan 29, 2014 at 4:45 PM, Mona Salem monasalem...@gmail.com wrote: AnnotationLabel is a property of model2. It's not though. In your main method you have a local variable called AnnotationLabel: Property AnnotationLabel = model2.createProperty(http://www.mydirectory.com/softwareproduct#softwareannotation;); but that's a local variable. It doesn't have scope in the printAnnotations method: private model2 printAnnotations(JsonNode annotations) { ... SoftwareProduct.addProperty(AnnotationLabel, classDetails.get(prefLabel).asText()); ... And actually, now that I see that method declaration again, I'm confused. private model2 printAnnotations(JsonNode annotations) { says that printAnnotations is a private method that returns something that has type model2. Is model2 even the name of a class in your code? (I know it's the name of a variable, but that's completely unrelated.) It certainly doesn't follow standard Java naming conventions. The problems you're running into here are Java problems, and aren't particular to Jena at all. //JT -- Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
Re: Can I pass a model in a parameter list?
On Wed, Jan 29, 2014 at 5:01 PM, Mona Salem monasalem...@gmail.com wrote: I am using Eclipse actually. I am working with a jena model and can print out my triples. The problem that I am running into is adding a property to my model in a second class; most properties are added in the Parser class, except for the annotation labels. I am calling a third party api(?TextAnnotations.java) and wish to load the labels into my model there. This is a jena question. I do not know how to pass the model in a parameter list, and have the object returned to Parser.java. I think you may have a misconception about how properties are represented in Jena. Code like //create the properties Property extracteddata = model.createProperty(http://www.mydirectory.com/softwareproduct#extracteddata;); Property annotationLabel = model.createProperty(http://www.mydirectory.com/softwareproduct#softwareannotation;); doesn't actually do anything to the Model. (In the case of an OntModel, where it takes some triples to declare a property, there might be some data added to a model.) All this is doing is using a model to return a Property that you could use later on when you're trying to add property values to things. Here's some example code that shows that you can pass Models as parameters, and illustrates that creating Properties doesn't change the model. Adding triples to a model changes the model. import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; public class CreatePropertyExample { private final static String NS = http://example.org/;; public static void main(String[] args) { // Create a model and show it. final Model model = ModelFactory.createDefaultModel(); System.out.println( === ); model.write( System.out ); // Create a property from the model, and // show the property and the model again (nothing's changed). final Property p = model.createProperty( NS+p ); System.out.println( === ); System.out.println( p ); model.write( System.out ); // Pass the model as a parameter to a method that // will modify the model. This time there's some // new stuff in the model. addTripleToModel( model ); System.out.println( === ); model.write( System.out ); } private static void addTripleToModel( final Model m ) { // Create some resources and properties. Resource x = m.createResource( NS+x ); Resource y = m.createResource( NS+y ); Resource z = m.createResource( NS+z ); Property p = m.createProperty( NS+p ); Property q = m.createProperty( NS+q ); // Add a triple to the model by adding a property to x. x.addProperty( q, y ); // Add a triple to the model by adding it directly. m.add( y, p, z ); } } The output is === rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; /rdf:RDF === http://example.org/p rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; /rdf:RDF === rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; xmlns:j.0=http://example.org/; rdf:Description rdf:about=http://example.org/x; j.0:q rdf:resource=http://example.org/y/ /rdf:Description rdf:Description rdf:about=http://example.org/y; j.0:p rdf:resource=http://example.org/z/ /rdf:Description /rdf:RDF === rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; /rdf:RDF === http://example.org/p rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; /rdf:RDF === rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; xmlns:j.0=http://example.org/; rdf:Description rdf:about=http://example.org/x; j.0:q rdf:resource=http://example.org/y/ /rdf:Description rdf:Description rdf:about=http://example.org/y; j.0:p rdf:resource=http://example.org/z/ /rdf:Description /rdf:RDF -- Joshua Taylor, http://www.cs.rpi.edu/~tayloj/