Clojure

Allow external collections to use standard collection hashing

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: Release 1.6
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hash mixing behavior as core collections.

Patch: clj-1336-4.patch
Depends on: CLJ-1338, CLJ-1339, CLJ-1335, CLJ-1331

  1. clj-1336-1.patch
    03/Feb/14 8:43 AM
    2 kB
    Alex Miller
  2. clj-1336-2.patch
    04/Feb/14 10:42 AM
    2 kB
    Alex Miller
  3. clj-1336-3.patch
    04/Feb/14 2:45 PM
    4 kB
    Alex Miller
  4. clj-1336-4.patch
    04/Feb/14 8:19 PM
    4 kB
    Alex Miller

Activity

Alex Miller made changes -
Field Original Value New Value
Assignee Alex Miller [ alexmiller ]
Alex Miller made changes -
Fix Version/s Release 1.6 [ 10157 ]
Approval Vetted [ 10003 ]
Alex Miller made changes -
Attachment clj-1336-1.patch [ 12746 ]
Description With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hashing behavior as core collections. With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hash mixing behavior as core collections.
Patch Code [ 10001 ]
Hide
Alex Miller added a comment -

Updated patch for a couple issues. However, in testing the use of this I discovered that the hash-basis must be an int and the basis accumulation must be based on int-accumulation with int-overflow, so it is not possible to do this in pure Clojure so this function is not currently useful.

I think the best solution would be to provide functions that encapsulate the ordered and unordered algorithms (Murmur3/hashOrdered and Murmur3/hashUnordered basically) such that external collections can implement hasheq correctly and with good performance.

Show
Alex Miller added a comment - Updated patch for a couple issues. However, in testing the use of this I discovered that the hash-basis must be an int and the basis accumulation must be based on int-accumulation with int-overflow, so it is not possible to do this in pure Clojure so this function is not currently useful. I think the best solution would be to provide functions that encapsulate the ordered and unordered algorithms (Murmur3/hashOrdered and Murmur3/hashUnordered basically) such that external collections can implement hasheq correctly and with good performance.
Alex Miller made changes -
Attachment clj-1336-2.patch [ 12750 ]
Description With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hash mixing behavior as core collections. With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hash mixing behavior as core collections.

*Patch:* clj-1336-2.patch
Hide
Alex Miller added a comment -

Add new patch that makes Murmur3 class public so it will work for users of mix-collection-hash. Also adds generative tests for comparing the external collection hashing algorithm with hashes produced by internal ordered and unordered collections. These tests currently fail due to CLJ-1335 (empty list and empty lazy seq return wrong hash code).

Show
Alex Miller added a comment - Add new patch that makes Murmur3 class public so it will work for users of mix-collection-hash. Also adds generative tests for comparing the external collection hashing algorithm with hashes produced by internal ordered and unordered collections. These tests currently fail due to CLJ-1335 (empty list and empty lazy seq return wrong hash code).
Alex Miller made changes -
Attachment clj-1336-3.patch [ 12751 ]
Description With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hash mixing behavior as core collections.

*Patch:* clj-1336-2.patch
With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hash mixing behavior as core collections.

*Patch:* clj-1336-3.patch
Patch Code [ 10001 ] Code and Test [ 10002 ]
Alex Miller made changes -
Attachment clj-1336-4.patch [ 12757 ]
Description With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hash mixing behavior as core collections.

*Patch:* clj-1336-3.patch
With the change in new hashing algorithms in 1.6, we need to provide a public hook for collections implemented outside of core to participate in the same hash mixing behavior as core collections.

*Patch:* clj-1336-4.patch
*Depends on:* CLJ-1338, CLJ-1339, CLJ-1335, CLJ-1331
Stuart Halloway made changes -
Approval Vetted [ 10003 ] Screened [ 10004 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Status Open [ 1 ] Closed [ 6 ]
Resolution Completed [ 1 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: