Giter Club home page Giter Club logo

Comments (3)

bitwalker avatar bitwalker commented on June 1, 2024

I'm fine with doing a pre-process step via :erlang.term_to_binary/1 if that actually solves the problem, otherwise I suppose we will need a new hash function

from libring.

jlerche avatar jlerche commented on June 1, 2024

That should be ok as :erlang.term_to_binary is pretty fast right? Here's some testing I did

iex(1)> :erlang.phash2(:foo)
27999
iex(2)> :erlang.phash2(:erlang.term_to_binary(:foo))
86811783
iex(3)> :erlang.phash2(:erlang.term_to_binary(:fooaaaa))
43291300
iex(4)> :erlang.phash2(:erlang.term_to_binary(:ffgfgff))
30215940
iex(5)> :erlang.phash2(:erlang.term_to_binary(:a))      
64216263
iex(6)> :erlang.phash2(:erlang.term_to_binary(:aaaaaa))
86861957
iex(7)> :erlang.phash2(:erlang.term_to_binary(:b))     
14428281
iex(8)> :erlang.phash2(:erlang.term_to_binary(:b), trunc(:math.pow(2,32)-1))
3235653753
iex(9)> :erlang.phash2(:foo, trunc(:math.pow(2,32)-1))                      
27999
iex(10)> :erlang.phash2(:erlang.term_to_binary(:foo), trunc(:math.pow(2,32)-1))
355247239

which is a lot closer to expected behavior.

from libring.

jordanhubbard avatar jordanhubbard commented on June 1, 2024

Is this why elixir HEAD is currently generating one test failure?

  1. test ensure function clauses are ordered (ModuleTest)
    test/elixir/module_test.exs:289
    Assertion with == failed
    code: assert :erlang.phash2(atoms) == 61635213
    left: 60755908
    right: 61635213
    stacktrace:
    test/elixir/module_test.exs:297: (test)

from libring.

Related Issues (14)

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.