All Projects → lithammer → Go Jump Consistent Hash

lithammer / Go Jump Consistent Hash

Licence: mit
⚡️ Fast, minimal memory, consistent hash algorithm

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Go Jump Consistent Hash

Ebooks
A repository for ebooks, including C, C plus plus, Linux Kernel, Compiler, OS, Algorithm, Security, Database, Network, ML and DL
Stars: ✭ 151 (-7.36%)
Mutual labels:  algorithm
Pythonrobotics
Python sample codes for robotics algorithms.
Stars: ✭ 13,934 (+8448.47%)
Mutual labels:  algorithm
Funnyalgorithms
A repository with a bunch of funny algorithms, beginners friendly
Stars: ✭ 161 (-1.23%)
Mutual labels:  algorithm
D.s.a Leet
References and summary for leetcode high-frequency algorithm problems
Stars: ✭ 155 (-4.91%)
Mutual labels:  algorithm
Gasyori100knock
image processing codes to understand algorithm
Stars: ✭ 1,988 (+1119.63%)
Mutual labels:  algorithm
Algorithmictrading
This repository contains three ways to obtain arbitrage which are Dual Listing, Options and Statistical Arbitrage. These are projects in collaboration with Optiver and have been peer-reviewed by staff members of Optiver.
Stars: ✭ 157 (-3.68%)
Mutual labels:  algorithm
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (-6.75%)
Mutual labels:  algorithm
Internet Recruiting Algorithm Problems
《程序员代码面试指南》、公司招聘笔试题、《剑指Offer》、算法、数据结构
Stars: ✭ 163 (+0%)
Mutual labels:  algorithm
C Plus Plus
Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
Stars: ✭ 17,151 (+10422.09%)
Mutual labels:  algorithm
Jstarcraft Ai
目标是提供一个完整的Java机器学习(Machine Learning/ML)框架,作为人工智能在学术界与工业界的桥梁. 让相关领域的研发人员能够在各种软硬件环境/数据结构/算法/模型之间无缝切换. 涵盖了从数据处理到模型的训练与评估各个环节,支持硬件加速和并行计算,是最快最全的Java机器学习库.
Stars: ✭ 160 (-1.84%)
Mutual labels:  algorithm
Algorithms Js
Consumable Data Structures and Algorithms library in JavaScript
Stars: ✭ 155 (-4.91%)
Mutual labels:  algorithm
Data Structures Algorithms
Your personal library of every algorithm and data structure code that you will ever encounter
Stars: ✭ 157 (-3.68%)
Mutual labels:  algorithm
Openalgo
💹 openAlgo is a public repository for various work product relavant to algorithms and the high frequency low latency electronic trading space with a bias toward market microstructure as well as exchange traded futures and options.
Stars: ✭ 158 (-3.07%)
Mutual labels:  algorithm
Algorithms
The codes and my solutions to exercises from the book "Algorithms" (4th edition) by Robert Sedgewick and Kevin Wayne.
Stars: ✭ 2,001 (+1127.61%)
Mutual labels:  algorithm
Python data structures and algorithms
Python 中文数据结构和算法教程
Stars: ✭ 2,194 (+1246.01%)
Mutual labels:  algorithm
Graphview
Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
Stars: ✭ 152 (-6.75%)
Mutual labels:  algorithm
Rolling
Computationally efficient rolling window iterators for Python (including sum, min/max, median and more...)
Stars: ✭ 158 (-3.07%)
Mutual labels:  algorithm
Algorithm
The repository algorithms implemented on the Go
Stars: ✭ 163 (+0%)
Mutual labels:  algorithm
Paper checking system
基于C#和C++开发的文本查重/论文查重系统,一亿字次级论文库秒级查重。关联:查重算法、数据去重、文档查重、文本去重、标书查重、辅助防串标
Stars: ✭ 160 (-1.84%)
Mutual labels:  algorithm
Java Notes
☕️ Java 基础 👫 面向对象思想✏️ 算法 📝 操作系统 ☁️ 网络 💾 数据库 🙊 Spring 💡 系统架构🐘大数据
Stars: ✭ 160 (-1.84%)
Mutual labels:  algorithm

Jump Consistent Hash

Build Status Godoc

Go implementation of the jump consistent hash algorithm[1] by John Lamping and Eric Veach.

[1] http://arxiv.org/pdf/1406.2294v1.pdf

Usage

import jump "github.com/lithammer/go-jump-consistent-hash"

func main() {
    h := jump.Hash(256, 1024)  // h = 520
}

Includes a helper function for using a string as key instead of an uint64. This requires a hasher that computes the string into a format accepted by Hash(). Such a hasher that uses CRC-64 (ECMA) is also included for convenience.

h := jump.HashString("127.0.0.1", 8, jump.NewCRC64())  // h = 7

In reality though you probably want to use a Hasher so you won't have to repeat the bucket size and which key hasher used. It also uses more convenient types, like int instead of int32.

hasher := jump.New(8, jump.NewCRC64())
h := hasher.Hash("127.0.0.1")  // h = 7

If you want to use your own algorithm, you must implement the KeyHasher interface, which is a subset of the hash.Hash64 interface available in the standard library.

Here's an example of a custom KeyHasher that uses Google's FarmHash algorithm (the successor of CityHash) to compute the final key.

type FarmHash struct {
    buf bytes.Buffer
}

func (f *FarmHash) Write(p []byte) (n int, err error) {
    return f.buf.Write(p)
}

func (f *FarmHash) Reset() {
    f.buf.Reset()
}

func (f *FarmHash) Sum64() uint64 {
    // https://github.com/dgryski/go-farm
    return farm.Hash64(f.buf.Bytes())
}

hasher := jump.New(8, &FarmHash{})
h := hasher.Hash("127.0.0.1")  // h = 5

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].