Return-Path: X-Original-To: apmail-drill-dev-archive@www.apache.org Delivered-To: apmail-drill-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 032701932C for ; Mon, 21 Mar 2016 21:17:42 +0000 (UTC) Received: (qmail 87843 invoked by uid 500); 21 Mar 2016 21:17:41 -0000 Delivered-To: apmail-drill-dev-archive@drill.apache.org Received: (qmail 87783 invoked by uid 500); 21 Mar 2016 21:17:41 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 87763 invoked by uid 99); 21 Mar 2016 21:17:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Mar 2016 21:17:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EE857DFA6C; Mon, 21 Mar 2016 21:17:40 +0000 (UTC) From: amansinha100 To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request: DRILL-4237 DRILL-4478 fully implement hash to ... Content-Type: text/plain Message-Id: <20160321211740.EE857DFA6C@git1-us-west.apache.org> Date: Mon, 21 Mar 2016 21:17:40 +0000 (UTC) Github user amansinha100 commented on a diff in the pull request: https://github.com/apache/drill/pull/430#discussion_r56899122 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MurmurHash3.java --- @@ -0,0 +1,264 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +package org.apache.drill.exec.expr.fn.impl; + +import io.netty.buffer.DrillBuf; +import io.netty.util.internal.PlatformDependent; + + +/** + * + * MurmurHash3 was written by Austin Appleby, and is placed in the public + * domain. + * See http://smhasher.googlecode.com/svn/trunk/MurmurHash3.cpp + * MurmurHash3_x64_128 + * MurmurHash3_x86_32 + */ +public final class MurmurHash3 extends DrillHash{ + + public final class LongPair { + public long val1; + public long val2; + } + + public static final long fmix64(long k) { + k ^= k >>> 33; + k *= 0xff51afd7ed558ccdL; + k ^= k >>> 33; + k *= 0xc4ceb9fe1a85ec53L; + k ^= k >>> 33; + return k; + } + + + + /* + Take 64 bit of murmur3_128's output + */ + public static long murmur3_64(long bStart, long bEnd, DrillBuf buffer, int seed) { + + long h1 = seed & 0x00000000FFFFFFFFL; + long h2 = seed & 0x00000000FFFFFFFFL; + + final long c1 = 0x87c37b91114253d5L; + final long c2 = 0x4cf5ad432745937fL; + long start = buffer.memoryAddress() + bStart; + long end = buffer.memoryAddress() + bEnd; + long length = end - start; + long roundedEnd = start + ( length & 0xFFFFFFF0); // round down to 16 byte block + for (long i=start; i