You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Jean-Marc Vanel <je...@gmail.com> on 2016/06/18 14:08:23 UTC

Fwd: Are numbers stored as binary ?

Hi all

I could not find the answer in the FAQ, nor by googling.
https://jena.apache.org/documentation/tdb/faqs.html

The advantages of numbers stored as binary versus strings are:

- less storage
- less CPU in conversion of string => number when using API
- more efficient SPARQL queries involving numbers computations

--
Jean-Marc Vanel
Déductions SARL - Consulting, services, training,
Rule-based programming, Semantic Web
+33 (0)6 89 16 29 52
Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui

Re: Are numbers stored as binary ?

Posted by Andy Seaborne <an...@apache.org>.
On 19/06/16 10:57, james anderson wrote:
> good morning;
>
>> On 2016-06-18, at 22:25, Andy Seaborne <an...@apache.org> wrote:
>>
>> On 18/06/16 15:08, Jean-Marc Vanel wrote:
>>> [\u2026]
>>
>>>
>>> The advantages of numbers stored as binary versus strings are:
>>>
>>> - less storage - less CPU in conversion of string => number when
>>> using API - more efficient SPARQL queries involving numbers
>>> computations
>>
>> A negative is that exact representation is lost
>>
>> "+1" and "1" and "0001"
>>
>> "1"^^xsd:integer and "1"^^xsd:int
>
> have there been applications where this mattered, where it was
> eventually decided that it was necessary to entrain some distinction
> in the encoding and not better to account for the respective
> semantics explicitly in the model?

Some. Questions comes up on users@ every so often - not frequently.

A user expectation is that read-write of a model does not change the 
model but here it does in the detail.  So detailed data checking or 
ETL-ish apps can be sensitive to this.

And you can see it in SPARQL with sameTerm.

For TDB2, I am thinking of extending it to xsd:doubles (64 bits needed) 
which would also extend the range of handled decimals.

	Andy

>
> best regards, from berlin, --- james anderson | james@dydra.com |
> http://dydra.com
>
>
>
>
>
>


Re: Are numbers stored as binary ?

Posted by james anderson <ja...@dydra.com>.
good morning;

> On 2016-06-18, at 22:25, Andy Seaborne <an...@apache.org> wrote:
> 
> On 18/06/16 15:08, Jean-Marc Vanel wrote:
>> […]
> 
>> 
>> The advantages of numbers stored as binary versus strings are:
>> 
>> - less storage
>> - less CPU in conversion of string => number when using API
>> - more efficient SPARQL queries involving numbers computations
> 
> A negative is that exact representation is lost
> 
> "+1" and "1" and "0001"
> 
> "1"^^xsd:integer and "1"^^xsd:int

have there been applications where this mattered, where it was eventually decided that it was necessary to entrain some distinction in the encoding and not better to account for the respective semantics explicitly in the model?

best regards, from berlin,
---
james anderson | james@dydra.com | http://dydra.com






Re: Fwd: Are numbers stored as binary ?

Posted by Andy Seaborne <an...@apache.org>.
On 18/06/16 15:08, Jean-Marc Vanel wrote:
> Hi all
>
> I could not find the answer in the FAQ, nor by googling.
> https://jena.apache.org/documentation/tdb/faqs.html

yes and no.

They are stored in the NodeId if possible.

See class NodeId.

In TDB as released there are 56 bits of space for holding: decimals, 
integers and derived types, dateTime, dates, boolean).

If the number does not fit, it is stored long form.

>
> The advantages of numbers stored as binary versus strings are:
>
> - less storage
> - less CPU in conversion of string => number when using API
> - more efficient SPARQL queries involving numbers computations

A negative is that exact representation is lost

"+1" and "1" and "0001"

"1"^^xsd:integer and "1"^^xsd:int

     Andy


>
> --
> Jean-Marc Vanel
> D�ductions SARL - Consulting, services, training,
> Rule-based programming, Semantic Web
> +33 (0)6 89 16 29 52
> Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
>