GG-11764 - refreshPage() assertion fix
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9776f3f4 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9776f3f4 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9776f3f4 Branch: refs/heads/ignite-3477 Commit: 9776f3f4925f27d6639a7381c5151ebe8e58b683 Parents: 5c106da Author: Alexey Goncharuk <[email protected]> Authored: Thu Dec 29 12:25:09 2016 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Thu Dec 29 12:25:09 2016 +0300 ---------------------------------------------------------------------- .../ignite/internal/pagemem/FullPageId.java | 29 ++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/9776f3f4/modules/core/src/main/java/org/apache/ignite/internal/pagemem/FullPageId.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/FullPageId.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/FullPageId.java index 31028cd..20677ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/FullPageId.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/FullPageId.java @@ -77,16 +77,35 @@ public class FullPageId { * @return Hash code. */ private static int hashCode0(int cacheId, long effectivePageId) { - int pageIdx = (int)PageIdUtils.pageId(effectivePageId); - int partId = PageIdUtils.partId(effectivePageId); + return (int)(mix64(effectivePageId) ^ mix32(cacheId)); + } - // Take a prime number larger than total number of partitions. - int res = 65537 * partId + cacheId; + /** + * MH3's plain finalization step. + */ + private static int mix32(int k) { + k = (k ^ (k >>> 16)) * 0x85ebca6b; + k = (k ^ (k >>> 13)) * 0xc2b2ae35; - return res * 31 + pageIdx; + return k ^ (k >>> 16); } /** + * Computes David Stafford variant 9 of 64bit mix function (MH3 finalization step, + * with different shifts and constants). + * + * Variant 9 is picked because it contains two 32-bit shifts which could be possibly + * optimized into better machine code. + * + * @see "http://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html" + */ + private static long mix64(long z) { + z = (z ^ (z >>> 32)) * 0x4cd6944c5cc20b6dL; + z = (z ^ (z >>> 29)) * 0xfc12c5b19d3259e9L; + + return z ^ (z >>> 32); + } + /** * @param pageId Page ID. * @param cacheId Cache ID. */
