Git Product home page Git Product logo

Comments (3)

marook avatar marook commented on June 16, 2024

I'm not 100% sure anymore why I thought using Strings for IDs would be the best choice. I remember dark that I had some problems with huge IDs but I'm not sure whether it was in JavaScript, Java or Python.

I think that problems could arise from the way JavaScript handles big integer values. See http://stackoverflow.com/a/9643650/404522

From an API point of view I used strings because they can handle 64 bit integers without a problem. The problem of handling 64 bit integers only arises on the osm-read implementation side. I thought that using strings in the interface leaves me the design choice to switch to some different way of parsing 64 bit IDs if I detect that the precision of the JavaScript integers is not good enough.

I think I'm going to add a test with a 0xffffffffffffffff ID and see what happens. If such high values can be represented in JavaScript we can change the datatype of ID, UIDs, etc. to integer in order to save some memory.
If the values can not be represented as JavaScript integers with enough precision I'm not yet sure what to do... Strings are "native" JavaScript datatypes. This makes comparing them and using them as keys in objects easy. Thats why I'm currently not very convinced of something like { lower32bits: 123, higher32bits: 456 } as representation for 64 bit integers.

What do you think?

from osm-read.

tyrasd avatar tyrasd commented on June 16, 2024

I think I'm going to add a test with a 0xffffffffffffffff ID and see what happens. If such high values can be represented in JavaScript we can change the datatype of ID, UIDs, etc. to integer in order to save some memory.

Actually, in JavaScript every "number" is stored as a double precision float which can hold Integers up to about 2^52 without rounding errors. 2^64 wouldn't work, though.

from osm-read.

nrenner avatar nrenner commented on June 16, 2024

Thanks for your responses, I feared there would be an issue with the number type. So I guess we just leave it as is.

An idea might be to have it configurable, so the user can decide to take the risk of not supporting 64-bit ids properly. But not sure what the actual benefit would be and not the highest priority right now, so closing.

from osm-read.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.