Git Product home page Git Product logo

node-fastcdc's Introduction

fastcdc

fastcdc: NodeJS bindings for @nlfielder's fastcdc-rs package.

This module implements the fast content defined chunking algorithm (FastCDC) described in the following paper:

W. Xia et al. "FastCDC: a Fast and Efficient Content-Defined Chunking Approach for Data Deduplication" Usenix 2016

Content defined chunking takes a blob of bytes (like a file for example) and cuts it into more or less uniform sized chunks along content boundaries. Because these chunk boundaries are determined by the contents of a file, not regular intervals they are robust to local modifications like insertions and deletions. This makes content defined chunking useful when deduplicating date, comparing files and synchronizing files over remote network storage.

Example

const fastCDC = require('./index.js')

const buffer = new Uint8Array(10 * 1024)
for (let i = 0; i < buffer.length; ++i) {
    buffer[i] = Math.random() * 256
}

console.log(fastCDC(buffer, {
    min: 1024,
    avg: 4096,
    max: 65536
}))

Output

[ 0, 2594, 6454, 8106, 9244, 10240 ]

Install

If your system has an up-to-date build of nodejs and rust you should be able to install this package using

npm install fastcdc

API

require('fastcdc')(bytes:ArrayBuffer|Uint8Array, opts?)

Computes a list of content defined chunk boundaries using fastcdc-rs.

Arguments

  • bytes is either an ArrayBuffer or a Uint8Array containing the bytes to be hashed
  • opts is a set of optional arguments to the chunker. If it is a number, then it assumed to be the average chunk size in bytes (default is 1024). Otherwise, if an object is passed then it is assumed to be a configuration with the following properties:
    • min the minimum chunk size
    • avg the average chunk size
    • max the maximum chunk size

Returns An array of chunk boundaries (0 and bytes.length inclusive) representing the chunks of the file

License

(c) 2021 Mikola Lysenko. ISC License

node-fastcdc's People

Contributors

mikolalysenko avatar h3r3zy avatar

Stargazers

Guillaume Arthaud 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.