Issue 5858 in pharo: DateAndTime >>#hash

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 5858 in pharo: DateAndTime >>#hash

pharo
Status: New
Owner: ----
Labels: Milestone-1.4 Type-Feature

New issue 5858 by [hidden email]: DateAndTime >>#hash
http://code.google.com/p/pharo/issues/detail?id=5858

The attached DateAndTime hash is ~130x times faster (~14,400,000/sec vs  
~110,000/sec on my machine) than the current version and has a low  
collision rate (0.04% or 4 per 10,000)

DateAndTime>>#hash
        ^ (jdn hashMultiply bitXor: seconds + offset asSeconds) bitXor: nanos

Attachments:
        DateAndTime-hash.st  242 bytes


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5858 in pharo: DateAndTime >>#hash

pharo
Updates:
        Status: FixReviewNeeded
        Labels: Milestone-2.0

Comment #1 on issue 5858 by [hidden email]: DateAndTime >>#hash
http://code.google.com/p/pharo/issues/detail?id=5858

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5858 in pharo: DateAndTime >>#hash

pharo
Updates:
        Status: FixToInclude

Comment #2 on issue 5858 by [hidden email]: DateAndTime >>#hash
http://code.google.com/p/pharo/issues/detail?id=5858

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5858 in pharo: DateAndTime >>#hash

pharo

Comment #3 on issue 5858 by [hidden email]: DateAndTime >>#hash
http://code.google.com/p/pharo/issues/detail?id=5858

Nicholas Ceiler pointed out that my hash would fail this test on Squeak:

| date1 date2 |
date1 := DateAndTime new ticks: (DateAndTime unixEpoch + 1 hours)
ticks offset: 0 hours.
date2 := DateAndTime new ticks: (DateAndTime unixEpoch - 2 hours)
ticks offset: -3 hours.
self assert: (date1 = date2) ==> [date1 hash = date2 hash]

which it does fail on Squeak but it passes on Pharo.

He proposes using this instead:
DateAndTime>>#hash
        | totalSeconds |
        totalSeconds := seconds - offset asSeconds.
        ^ ((totalSeconds // 86400 + jdn) hashMultiply bitXor: totalSeconds \\
86400) bitXor: nanos


Which works better than what I proposed from a collision point of view  
(0.01% or 1 per 10,000) and is a bit slower than my proposal.  Its still  
100x faster than the original I proposed to replace.  So 11,000,000/sec  
rather than 110,000/sec.

Attachments:
        DateAndTime-hash-2.st  326 bytes


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5858 in pharo: DateAndTime >>#hash

pharo
Updates:
        Labels: -Milestone-2.0

Comment #4 on issue 5858 by [hidden email]: DateAndTime >>#hash
http://code.google.com/p/pharo/issues/detail?id=5858

in 2.0 066

TODO: 1.4


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5858 in pharo: DateAndTime >>#hash

pharo

Comment #5 on issue 5858 by [hidden email]: DateAndTime >>#hash
http://code.google.com/p/pharo/issues/detail?id=5858

just in case, execute:

HashedCollection allSubclassesDo: #rehashAll.

after include (it wont hurt in any case)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5858 in pharo: DateAndTime >>#hash

pharo
Updates:
        Status: Integrated

Comment #6 on issue 5858 by [hidden email]: DateAndTime >>#hash
http://code.google.com/p/pharo/issues/detail?id=5858

in 14442


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker