[erlang-patches] [PATCH] - Add NIF function enif_phash2
Henrik Nord
henrik@REDACTED
Tue Nov 12 10:44:23 CET 2013
On 2013-02-14 15:25, Fredrik wrote:
> On 02/08/2013 09:19 PM, Paul Davis wrote:
>> Fredrik,
>>
>> Rebased against master:
>>
>> git fetch git://github.com/davisp/otp.git enif_phash2
>>
>> https://github.com/davisp/otp/compare/master...enif_phash2
>> https://github.com/davisp/otp/compare/master...enif_phash2.patch
>>
>> Sverker,
>>
>> I've updated the function ordering as per the comment in
>> erl_nif_api_funcs.h. For use case, I'm implementing a couple data
>> structures that use hash tables to speed up some hot loops. I can get
>> away for awhile using erlang:phash2/2 in Erlang and passing that value
>> into the NIF but this breaks down when I don't know a priori which
>> terms (or subterms) I may need to hash in the NIF.
>>
>> A similar example would be trying to reimplement ets without this.
>> Either I'd have to store enough information in the Erlang term
>> representing the table to be able to know which elements of the tuple
>> to hash or I'd have to ask the table what to hash before passing the
>> term off to the NIF. There are definitely work arounds to not having
>> access to phash2 but they aren't pretty.
>>
>> Thanks,
>> Paul Davis
>>
>> On Fri, Feb 8, 2013 at 7:39 AM, Sverker Eriksson
>> <sverker.eriksson@REDACTED> wrote:
>>> Fredrik wrote:
>>>> On 02/08/2013 12:58 AM, Paul Davis wrote:
>>>>> git fetch git://github.com/davisp/otp.git enif_phash2
>>>>>
>>>>> https://github.com/davisp/otp/compare/maint...enif_phash2
>>>>> https://github.com/davisp/otp/compare/maint...enif_phash2.patch
>>>>>
>>>>> This patch exposes the phash2 function to NIFs. It is exactly
>>>>> equivalent
>>>>> to:
>>>>>
>>>>> erlang:phash2(Term, 16#100000000)
>>>>>
>>>>> Thanks,
>>>>> Paul Davis
>>>>> _______________________________________________
>>>>> erlang-patches mailing list
>>>>> erlang-patches@REDACTED
>>>>> http://erlang.org/mailman/listinfo/erlang-patches
>>>> Please rebase this patch upon the current 'master' branch.
>>>> Thanks,
>>>>
>>> Also read the comments in erl_nif_api_funcs.h of how to add new
>>> functions.
>>> You do not have to increase ERL_NIF_MINOR_VERSION as I've already
>>> done that
>>> for R16B.
>>>
>>> I guess you have a real use case for enif_phash2 and why
>>> erlang:phash2 is
>>> not enough.
>>>
>>> /Sverker
> Hello could you rebase this upon the current 'master' branch on github
> Thanks,
Ping!
--
/Henrik Nord Erlang/OTP
More information about the erlang-patches
mailing list