Giter Site home page Giter Site logo

Node ID return type int -> uint64 about graph HOT 5 CLOSED

baijum avatar baijum commented on August 15, 2024
Node ID return type int -> uint64

from graph.

Comments (5)

kortschak avatar kortschak commented on August 15, 2024

I would rather not. Negative node IDs can be useful (e.g. 2-SAT problem) and I'm not convinced by the portability claim - the source is portable and we don't currently have and binary graph representation.

Can you explain how you want to use SipHash and how that is relevant here?

from graph.

baijum avatar baijum commented on August 15, 2024

Well, I am very new to Graph. Now I am trying to solve a dependency analysis problem using DAG.

As per the spec the size of int is implementation specific. So, if the IDs are retrieved from a persistent store, there is a chance to get the constant NNN overflows int error.
https://golang.org/ref/spec#Numeric_types
If negative numbers are really required, why not use int32 or int64?
(BTW, int64 is supported on 32 bit platforms: https://groups.google.com/forum/#!topic/golang-nuts/mtnn-01Dh_I )

Regarding the SipHash, I was thinking I can create unique IDs for my nodes from certain string parameters using that hash. May be this design is not really required. I am in early stage of my development.

from graph.

kortschak avatar kortschak commented on August 15, 2024

If you are writing code that you expect to create persistent data and you intend to share that between 32- and 64- bit archs, then you need to ensure that you your node IDs fit within 32 bits. How you serialise the node data is up to you, but there are plenty of arch agnostic methods available if you follow the above restriction.

Why not the fixed size ints? Because int matches the size of data store available for the arch without doubling the size of the ID needed (for some graphs this may be a signficant burden).

Using a hash to generate ID seems foolhardy. How do you know that you will not get a hash collision? Sure, the probability if low, but why not just make pool of IDs that you can draw from and keep those as well as whatever data you are storing in the node? I'm also wondering why you want to use a cryptographic hash for this.

I really can't see a good justification for making this change.

from graph.

baijum avatar baijum commented on August 15, 2024

Thanks for the feedback, you can close this issue.

BTW, SipHash is not a cryptographic hash: https://131002.net/siphash/ (Users include Python, Ruby, JRuby, Rust, Redis etc.)

from graph.

kortschak avatar kortschak commented on August 15, 2024

It's a fast cryptographic hash. Yes, it's used as a hashing system for many languages' associative arrays, but this is principally because it prevents the kind of things a crypto hash prevents, just faster.

from graph.

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.