Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1207

Adding Decimal Typed Literal Results in TDBException on Dataset Commit

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Workaround
    • Jena 3.1.0
    • None
    • TDB
    • None
    • Mac OSX

    Description

      When adding a statement of the form

      http://www.myhost.com/mysubject, http://www.myhost.com/mypredicate, "2.2"^^http://www.w3.org/2001/XMLSchema#decimal

      using the following snippet

      import java.util.ArrayList;
      import java.util.List;
      
      import org.apache.jena.datatypes.RDFDatatype;
      import org.apache.jena.datatypes.xsd.XSDDatatype;
      import org.apache.jena.query.Dataset;
      import org.apache.jena.query.ReadWrite;
      import org.apache.jena.rdf.model.Model;
      import org.apache.jena.rdf.model.Property;
      import org.apache.jena.rdf.model.RDFNode;
      import org.apache.jena.rdf.model.Resource;
      import org.apache.jena.rdf.model.ResourceFactory;
      import org.apache.jena.rdf.model.Statement;
      import org.apache.jena.tdb.TDBFactory;
      
      public class DecimalExample {
      	
      	public static void main(String[] args) {
      		String tdbPath = "absolute/path/here";
      		Dataset dataset = TDBFactory.createDataset( tdbPath );
      		
      		Resource subject = ResourceFactory.createResource("http://www.myhost.com/mysubject");
      		Property predicate = ResourceFactory.createProperty("http://www.myhost.com/mypredicate");
      		RDFDatatype datatype = new XSDDatatype("decimal");
      		RDFNode object = ResourceFactory.createTypedLiteral("2.2", datatype);
      		
      		List<Statement> statements = new ArrayList<Statement>();
      		statements.add( ResourceFactory.createStatement(subject, predicate, object) );
      		
      		dataset.begin(ReadWrite.WRITE);
      		try {
      			
      			Model model = dataset.getDefaultModel();
      			
      			model.add(statements);
      			dataset.commit();
      			
      		} catch (Exception e) {
      			
      			e.printStackTrace();
      			dataset.abort();
      			
      		} finally {
      
      			dataset.end();
      
      		}
      		
      	}
      }
      
      

      A TDBException is thrown. The stack trace shows the following:

      SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
      SLF4J: Defaulting to no-operation (NOP) logger implementation
      SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
      
      
      Different ids for "2.2"^^http://www.w3.org/2001/XMLSchema#decimal: allocated: expected [0000000000000000], got [0201000000000016]
      >>>>>>>>>>
      label = nodes
      txn = Transaction: 1 : Mode=WRITE : State=PREPARING : /Users/kaihe/Documents/experimental/tdb/
      offset = 0
      journalStartOffset = 0
      journal = nodes
      
      org.apache.jena.tdb.transaction.TDBTransactionException: Abort during prepare - transaction did not commit
      	at org.apache.jena.tdb.transaction.Transaction.commit(Transaction.java:123)
      	at org.apache.jena.tdb.transaction.DatasetGraphTxn.commit(DatasetGraphTxn.java:54)
      	at org.apache.jena.tdb.transaction.DatasetGraphTransaction._commit(DatasetGraphTransaction.java:146)
      	at org.apache.jena.sparql.core.DatasetGraphTrackActive.commit(DatasetGraphTrackActive.java:46)
      	at org.apache.jena.sparql.core.DatasetImpl.commit(DatasetImpl.java:123)
      	at DecimalExample.main(DecimalExample.java:37)
      Caused by: org.apache.jena.tdb.TDBException: Different ids for "2.2"^^http://www.w3.org/2001/XMLSchema#decimal: allocated: expected [0000000000000000], got [0201000000000016]
      	at org.apache.jena.tdb.transaction.NodeTableTrans.inconsistent(NodeTableTrans.java:232)
      	at org.apache.jena.tdb.transaction.NodeTableTrans.append(NodeTableTrans.java:220)
      	at org.apache.jena.tdb.transaction.NodeTableTrans.writeNodeJournal(NodeTableTrans.java:317)
      	at org.apache.jena.tdb.transaction.NodeTableTrans.commitPrepare(NodeTableTrans.java:289)
      	at org.apache.jena.tdb.transaction.Transaction.prepare(Transaction.java:172)
      	at org.apache.jena.tdb.transaction.Transaction.commit(Transaction.java:108)
      	... 5 more
      

      The problem goes away when adding statements with integer values like

      http://www.myhost.com/mysubject, http://www.myhost.com/mypredicate, "2"^^http://www.w3.org/2001/XMLSchema#integer

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            kaithinkiq Kai He
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment