Hello all,

We recently noticed in a TDB2 dataset that negative float values (including
"negative zero") are corrupted.  The batch loader shows a WARN message --
see below.  The following simple steps reproduce the problem.  This is with
Jena 3.10, though the issue seems to exist prior to that.

$ echo "<s> <p> \"-1.0\"^^<http://www.w3.org/2001/XMLSchema#float> ." >
test.nt

$ tdb2.tdbloader --loc test_tdb2 test.nt
11:07:36 WARN  NodeId               :: Type set in long: type=Float
value=FFFFFFFFBF800000

$ tdb2.tdbquery --loc test_tdb2 "select ?o (datatype(?o) as ?dt) where { ?s
?p ?o }"
----------------------------------------------------------------------
| o                      | dt                                        |
======================================================================
| 3.1861834394748298E-58 | <http://www.w3.org/2001/XMLSchema#double> |
----------------------------------------------------------------------


TDB1 is OK:

$ tdbloader --loc test test.nt
11:09:12 INFO  loader               :: -- Start triples data phase
11:09:12 INFO  loader               :: ** Load empty triples table
11:09:12 INFO  loader               :: -- Start quads data phase
11:09:12 INFO  loader               :: ** Load empty quads table
11:09:13 INFO  loader               :: Load: test.nt -- 2019/02/19 11:09:13
PST
11:09:13 INFO  loader               :: -- Finish triples data phase
11:09:13 INFO  loader               :: ** Data: 1 triples loaded in 0.11
seconds [Rate: 9.09 per second]
11:09:13 INFO  loader               :: -- Finish quads data phase
11:09:13 INFO  loader               :: -- Start triples index phase
11:09:13 INFO  loader               :: ** Index SPO->POS: 1 slots indexed
11:09:13 INFO  loader               :: ** Index SPO->OSP: 1 slots indexed
11:09:13 INFO  loader               :: -- Finish triples index phase
11:09:13 INFO  loader               :: ** 1 triples indexed in 0.01 seconds
[Rate: 166.67 per second]
11:09:13 INFO  loader               :: -- Finish triples load
11:09:13 INFO  loader               :: ** Completed: 1 triples loaded in
0.12 seconds [Rate: 8.26 per second]
11:09:13 INFO  loader               :: -- Finish quads load

$ tdbquery --loc test "select ?o (datatype(?o) as ?dt) where { ?s ?p ?o }"
-----------------------------------------------------------------------------------------------
| o                                                | dt
                   |
===============================================================================================
| "-1.0"^^<http://www.w3.org/2001/XMLSchema#float> | <
http://www.w3.org/2001/XMLSchema#float> |
-----------------------------------------------------------------------------------------------

Creating the dataset via fuseki shows a similar pattern: "in-memory" and
"persistent" correctly retrieve the float value, but "persistent (tdb2)"
returns a corrupt value interpreted as a double.

Is this a known issue / limitation of TDB2?  If so, are there any suggested
workarounds other than always using doubles, at least for negatives?

Thanks,
- Mike

For completeness, this is the result of storing -1.0, -0.0, 0.0, and 1.0 as
both float and double (8 values total).  The combination of float +
negative results in the 2 near-zero "double" values.

-----------------------------------------------------------------------------------------------
| o                                               | dt
                  |
===============================================================================================
| "0.0"^^<http://www.w3.org/2001/XMLSchema#float> | <
http://www.w3.org/2001/XMLSchema#float>  |
| "1.0"^^<http://www.w3.org/2001/XMLSchema#float> | <
http://www.w3.org/2001/XMLSchema#float>  |
| 0.0e0                                           | <
http://www.w3.org/2001/XMLSchema#double> |
| 3.186183062619485E-58                           | <
http://www.w3.org/2001/XMLSchema#double> |
| 3.1861834394748298E-58                          | <
http://www.w3.org/2001/XMLSchema#double> |
| 1.0e0                                           | <
http://www.w3.org/2001/XMLSchema#double> |
| -0.0e0                                          | <
http://www.w3.org/2001/XMLSchema#double> |
| -1.0e0                                          | <
http://www.w3.org/2001/XMLSchema#double> |
-----------------------------------------------------------------------------------------------

Reply via email to