So, close is discouraged, and seems no more useful.
Then, is one of TDB.sync() useful to call, or is TDB imune to sudden power
off ?


2014-01-30 Andy Seaborne <[email protected]>

> Hi Jean-Marc,
>
> Thank you for the report - especially a link to the complete code as well
> as the in-email description and discussion.
>
> This is JENA-571, or rather it's reverse.  It looks like there is a bad
> side effect due to caching.  The closed graph is still in the DatasetGraph
> cache and also in the DatasetCache.
>
> I've reopened JENA-571.  I suspect that caching of graphs (and models
> higher up) is not nearly as import as it once was.
>
> Workaround is to not close models (or datasets).
>
> In TDB, the true state is on-disk and also in a single system wide object
> for the location.  This is shared, which is essential because it avoids a
> lot of disk I/O on opening.creating.  .close() isn't really doing anything
> much.
>
>         Andy
>
>
> On 29/01/14 12:30, Jean-Marc Vanel wrote:
>
>> 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

Reply via email to