Skip to content

Commit

Permalink
Clean-up hash functions and introduce MurmurHash3 (twitter#145)
Browse files Browse the repository at this point in the history
* remove (mostly duplicate) cc_lookup3.[ch]

* rename hash() and cc_hash.[ch] to indicate *lookup3

* bump version, introduce murmur3
  • Loading branch information
thinkingfish authored Mar 27, 2017
1 parent b1babb2 commit b164fcf
Show file tree
Hide file tree
Showing 8 changed files with 582 additions and 547 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ endif()

# version info
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 2)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}
Expand Down
38 changes: 0 additions & 38 deletions include/cc_lookup3.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/cc_hash.h → include/hash/cc_lookup3.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {
#include <stdint.h>
#include <stdlib.h>

uint32_t hash(const void *key, size_t length, const uint32_t initval);
uint32_t hash_lookup3(const void *key, size_t length, const uint32_t initval);

#ifdef __cplusplus
}
Expand Down
39 changes: 39 additions & 0 deletions include/hash/cc_murmur3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* ccommon - a cache common library.
* Copyright (C) 2013 Twitter, Inc.
*
* Licensed 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.
*/

/**
* The cc_murmur3.[ch] are adapated from the canonical implementation of
* MurmurHash3 by Austin Appleby, released as part of SMHasher:
* https://github.com/aappleby/smhasher
*
* Changes include renaming fuctions, removing MSVC-related code, adding "static"
* keyword to local-scope functions according to C language spec (original code is
* in C++), to better fit them into the scope and style of ccommon
*
* The actual implementation is untouched.
*/

#pragma once

#include <stdint.h>


void hash_murmur3_32 ( const void * key, int len, uint32_t seed, void * out );

void hash_murmur3_128_x86 ( const void * key, int len, uint32_t seed, void * out );

void hash_murmur3_128_x64 ( const void * key, int len, uint32_t seed, void * out );
2 changes: 1 addition & 1 deletion src/hash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(SOURCE
${SOURCE}
hash/cc_hash.c
hash/cc_lookup3.c
hash/cc_murmur3.c
PARENT_SCOPE)
Loading

0 comments on commit b164fcf

Please sign in to comment.