Giter VIP home page Giter VIP logo

xorf's Introduction

xorf

Xorf docs Crates.io Build Status

This repository hosts a Rust library implementing xor filters -- data structures for fast approximation of set membership using little memory. Probabilistic filters like xor filters are useful when it's okay to have false positives sometimes, but it's important to be space and time efficient. In other words, they trade off accuracy for efficiency as compared to general-purpose hashsets. Filters like xor filter are often used in conjunction with larger hash-based data structures, with the filter doing a "first pass" of the work to avoid using a more expensive resource unnecessarily. For example, filters like xor filters can be used to reduce disk writes in a cache or identify malicious URLs in a browser.

Xor filters are faster and smaller than Bloom and Cuckoo filters. Xor filters incur a relative time penalty in construction, but are very fast in lookups; the expectation is that construction of a filter is amortized after many queries. Daniel Lemire's go implementation provides a useful summary of xor filters' benefits and listing of other xor filter libraries.

This library is no_std and needs_allocator. Currently, the following xor filters are provided:

xorf also provides a HashProxy for using Xor filters with arbitrary key types.

Installation

Add a dependency to xorf in Cargo.toml:

[dependencies]
xorf = "M.m.p" # use a desired version

Available versions are listed on crates and the in repository's releases.

Usage

Please see the library documentation for usage information.

Features

Custom allocator

To use a custom global allocator, you must be using a nightly release of rustc and have enabled the nightly feature for xorf.

[dependencies]
xorf = { version = "M.m.p", features = ["nightly"] }

This will tag the crate as needs_allocator, which you will then have to provide. At this time, a custom allocator is used globally.

Serialization/Deserialization

Serialization and deserialization with serde cab be enabled with the serde feature.

[dependencies]
xorf = { version = "M.m.p", features = ["serde"] }

Default features

By default, xorf uses the uniform-random feature, which uses random values for unused fingerprint entries rather than setting them to zero. This provides a slightly lower false-positive rate, but incurs a higher initialization cost. The cost of lookups is not affected.

To disable the uniform-random feature, specify that default features should be disabled:

[dependencies]
xorf = { version = "M.m.p", default-features = false }

Development

Development of xorf targets the master branch of this repository.

Changes can be tested by running the check script:

scripts/check lf     # validates lint and format
scripts/check test   # tests source code

Contribution

Contributions are warmly welcomed. No contribution is too small, and all are appreciated.

License

MIT

xorf's People

Contributors

ayazhafiz avatar madninja avatar stiiifff 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.