Hi there,

What does PropertiesManager do? That seems critical here.

You should be using dataset transactions, ReadWrite.WRITE for an update.

Which version of jena is this?

> Inconsistency:
> base.allocOffset() = 1982292 : allocOffset = 0

That usually means that at some point in the past, either a non-transactional update creash, or the app didn't sync the database before exiting. Another possible cause is two JVMs accress the same database at the same time.

        Andy

On 27/06/14 12:22, Alessandro Suglia wrote:
Good morning to all, I'm having some trouble using apache Jena TDB API,
in particular when I have to add a lot of statement to my model.
I need to save the result which I get from the dbpedia endpoint for
about two thousand entities. For each entity I get about ten properties
that I need for my task. So, when I execute the query, I loop through
all the result set and do multiple add operations for each statement in
the result set.

This is the code that I use in order to save the properties for a single
subject:

|public void saveResourceProperties(String resourceURI,
Collection<String> specificProp, PropertiesManager propManager) throws
Exception {

     String proprVariable = "?prop",
             valueVariable = "?value",
             fixedURI = "<" + resourceURI + ">",
             queryProp = "select " + proprVariable + " " + valueVariable
+ " where {\n" +
                     fixedURI + " " + proprVariable + " " + valueVariable +
                     " values " + proprVariable + "{" +
formatPropertiesList(specificProp) + "} \n" +
                     "}";

     Query query = QueryFactory.create(queryProp);

     QueryExecution qexec = null;
     try {
         qexec = QueryExecutionFactory.sparqlService(endpoint, query);

         ResultSet resultSet = qexec.execSelect();


         QuerySolution currSolution;

         // invokes dataset.begin(ReadWrite.Write);
         propManager.start(true);

         while (resultSet.hasNext()) {
             currSolution = resultSet.nextSolution();
             writer.write(resourceURI + "\t" +
currSolution.getResource(proprVariable).toString() +
                     "\t" + currSolution.get(valueVariable).toString() +
"\n");

            // prepare the statement using the resource URI and the
current solution
            // and adds it using add() method
            propManager.addSolution(currSolution, resourceURI);


         }
         // I commit the results calling dataset.commit()
         propManager.commitChanges();


     }
     finally {

         if (qexec != null)
             qexec.close();
         // calls dataset.end() in order to end the current transaction
         propManager.closeManager();
     }


}
|

Everything goes ok, but at the end of the process I receive this
exception (it happens each time that I call this method): Inconsistency:
base.allocOffset() = 1982292 : allocOffset = 0 After that, no file are
stored and for this reason I'm not able to read nothing.

I've tried to execute all the commit in a single, huge transaction, but
I receive the same error and the program is not able to store TDB index
files.

How can I manage this kind of situation? Can you suggest to me an
efficient way to do that? I'm getting mad...

Thank you in advance.

Alessandro Suglia


Reply via email to