GithubHelp home page GithubHelp logo

jdrew1303 / hmsearch-node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from commonsmachinery/hmsearch-node

0.0 1.0 0.0 184 KB

Node API to hmsearch library

License: MIT License

JavaScript 53.59% Makefile 1.70% Python 1.48% C++ 43.23%

hmsearch-node's Introduction

hmsearch-node

Node API to HmSearch library. For more information on the library, see https://github.com/commonsmachinery/hmsearch

Installing

Currently the build only supports Linux. Pull requests for Mac and Windows are welcome!

Ensure that Kyoto Cabinet is installed. On Ubuntu:

apt-get install libkyotocabinet-dev kyotocabinet-util

When building from the git repository the hmsearch submodule must be initialised on first checkout:

git submodule init
git submodule update

API

For details on these methods, see the documentation for the C++ library: https://github.com/commonsmachinery/hmsearch/blob/master/hmsearch.h

The synchronous methods all throw an Error if the operation fails, with the message providing further details. The asynchronous methods instead invoke the callback with the first argument set to an Error instance.

Initialise a database

hmsearch.initdb(path, hash_bits, max_error, num_hashes, function(err) {...})

hmsearch.initdbSync(path, hash_bits, max_error, num_hashes)

Open a database

hmsearch.open(path, mode, function(err, db) {...})

db = hmsearch.openSync(path, mode)

Mode is either hmsearch.READONLY or hmsearch.READWRITE.

db is a newly opened database object.

Close a database

db.close(function(err) {...})

db.closeSync()

Sync any changes to the database and close it. This must be done to release any locks on the database so other processes can access it.

It is safe to close the database multiple times.

The database is also closed when the database object is garbage collected.

Insert a hash

db.insert(hash, function(err) {...})

db.insertSync(hash)

hash must be a hexadecimal string of the correct length.

Lookup a hash

db.lookupSync(query, [max_error], function(err, matches) {...})

matches = db.lookupSync(query, [max_error])

query must be a hexadecimal string of the correct length. If max_error is provided and non-negative, it can further restrict the accepted hamming distance than the database default.

matches lists each matching hash as a hexadecimal string and the hamming distance to the query hash:

[ { hash: '0123456789abcdef', distance: 3 }, ... ]

matches is an empty list if no hashes are found.

License

Copyright 2014 Commons Machinery http://commonsmachinery.se/

Distributed under an MIT license, please see LICENSE in the top dir.

Contact: [email protected]

hmsearch-node's People

Contributors

petli avatar

Watchers

James Drew 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.