You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "sdhalex (Jira)" <ji...@apache.org> on 2019/12/24 23:55:00 UTC
[jira] [Commented] (JENA-1207) Adding Decimal Typed Literal Results
in TDBException on Dataset Commit
[ https://issues.apache.org/jira/browse/JENA-1207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17003016#comment-17003016 ]
sdhalex commented on JENA-1207:
-------------------------------
why was it seen as a workaround? Is there any long term fix?
> Adding Decimal Typed Literal Results in TDBException on Dataset Commit
> ----------------------------------------------------------------------
>
> Key: JENA-1207
> URL: https://issues.apache.org/jira/browse/JENA-1207
> Project: Apache Jena
> Issue Type: Bug
> Components: TDB
> Affects Versions: Jena 3.1.0
> Environment: Mac OSX
> Reporter: Kai He
> Priority: Major
> Attachments: add-decimal-literals.zip
>
>
> 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
> {code:java}
> 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();
> }
>
> }
> }
> {code}
> A TDBException is thrown. The stack trace shows the following:
> {code:java}
> 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
> {code}
> 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]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)