Code Monkey home page Code Monkey logo

hammer's Introduction

Hammer

Build Status

Hamming distance search index

Use

All requests to the API should be POST's. Three endpoints are exposed; /add, /query and /delete, which do what they say. Databases are identified by the size of the values they index, their tolerance (the maximum hamming distance of returned values from a query) and an arbitrary namespace value. Supported value sizes:

  • b/64/:tolerance/:namespace: Substitution-variant DB indexing 64-bit binary values
  • b/128/:tolerance/:namespace: Substitution-variant DB indexing 128-bit binary values
  • b/256/:tolerance/:namespace: Substitution-variant DB indexing 256-bit binary values
  • bN/:bits/:tolerance/:namespace: Substitution-variant DB indexing binary values of length :bits (multiples of 8)
  • v/64/:length/:tolerance/:namespace: Deletion-variant DB indexing vectors of 64-bit values of length :length
  • v/128/:length/:tolerance/:namespace: Deletion-variant DB indexing vectors of 128-bit values of length :length
  • v/256/:length/:tolerance/:namespace: Deletion-variant DB indexing vectors of 256-bit values of length :length

End points accept arrays of additions, queries and deletions and return results arrays - each element in the result array relates to the corresponding element in the request array.

# Start an HTTP server on port 3000
cargo build && target/build/hammer --bind localhost:3000

# Add some keys
curl -X POST -d '["AAAAAAAAAAA=","AAAAAAAAAAA=","AAAAAAAA","AADZvdpG3MA="]' localhost:3000/add/b/64/8/foo
# ["ok",exists","err: unable to decode 'AAAAAAAA': (...)","ok"]
curl -X POST -d '[["AAAAAAAAAAA=","AAAAAAAAAAE="],["AAAAAAAAAAI=","AADZvdpG3MA="]]' localhost:3000/add/v/64/2/8/foo
# ["ok","ok"]

# Query for some keys
curl -X POST -d '["AAAAAAAAAAA=","AADZvdpG3MA="]' localhost:3000/query/b/64/8/foo
# [["AAAAAAAAAAI=","AAAAAAAAAAE=","AAAAAAAAAAA="],["AADZvdpG3MA="]]

# Delete keys
curl -X POST -d '["AAAAAAAAAAA="]' localhost:3000/delete/b/64/8/foo
# ["ok"]

Architecture

Keys are partitioned into a set of indices. Indices consist of a mapping from a key partition to the key value, as well as mappings from each key's 1-permutation to the key value.

Keys are added by splitting into partitions, each partition is merged into its associated index.

Keys are retrieved by splitting the query key into partitions and querying for the partition in each index. Results are filtered by the target hamming distance and returned as a set.

This is mostly an implementation of HmSearch

hammer's People

Contributors

kerinin avatar

Watchers

 avatar James Cloos avatar Andrew Harrison avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.