delta_rs

Crates.iodelta_rs
lib.rsdelta_rs
version0.1.1
sourcesrc
created_at2023-10-27 09:17:56.534144
updated_at2023-10-27 09:47:32.683605
descriptionA version control and incremental data storage tool based on Rust,
homepagehttps://github.com/sonichen/delta_rs
repositoryhttps://github.com/sonichen/delta_rs
max_upload_size
id1015812
size13,373
(sonichen)

documentation

https://github.com/sonichen/delta_rs

README

delta_rs 0.1.0

delta_rs is a version control and incremental data storage tool based on Rust, allowing you to store only data blocks that have not been stored in previous versions, effectively managing and restoring different versions of data.

Design Overview

The design of delta_rs is centered around the following key principles:

  • Version Control: The project allows users to maintain and manage multiple versions of data. Each version is represented as a Delta.

  • Incremental Data Storage: To reduce storage space usage, delta_rs stores only the data blocks that have not been stored in previous versions. This is achieved through a block-based approach.

  • Block-Based Storage: Data is divided into blocks, and each block is associated with a unique identifier. When a new version is created, only the new and previously unsaved blocks are stored, along with the composition order. This design minimizes redundant data storage.

  • Quick Data Restoration: Users can efficiently restore data to a specific version by specifying the version number and data block index.

Example Use Cases

Delta_rs is designed to be useful in various scenarios, including:

  • Managing versioned documents or files efficiently.
  • Reducing storage space for data that evolves over time.
  • Quickly restoring data to specific versions for analysis or historical purposes.

Quick Start

Installation

Add delta_rs as a dependency in your Cargo.toml:

[dependencies]
delta_rs = "0.1.1"

Usage Example

use delta_rs::{ get_content, Deltas};

fn main() {
    // Write data
    let mut deltas=Deltas::create("Hello, I am a rust developer.");
    
    // First modify
    deltas.modify("Hello, I am a Java developer.");

    // Second modify
    deltas.modify("Hello, I am a Python developer.");

    // Third modify
    deltas.modify("Hello, I am a Go developer.");

    // print the data block and the content
    for item in &deltas.deltas {
        println!("{}", get_content(item.id, deltas.deltas.clone()));
        println!("{:?}\n", item);
    }
    
}

Output

Hello, I am a rust developer.
Delta { id: 0, index: [0, 1, 2], blocks: [DataBlock { block_number: 0, data: [72, 101, 108, 108, 111, 44, 32, 73, 32, 97] }, DataBlock { block_number: 1, data: [109, 32, 97, 32, 114, 117, 115, 116, 32, 100] }, DataBlock { block_number: 2, data: [101, 118, 101, 108, 111, 112, 101, 114, 46] }], snapshot: true }

Hello, I am a Java developer.
Delta { id: 1, index: [0, 3, 2], blocks: [DataBlock { block_number: 3, data: [109, 32, 97, 32, 74, 97, 118, 97, 32, 100] }], snapshot: true }

Hello, I am a Python developer.
Delta { id: 2, index: [0, 4, 5, 6], blocks: [DataBlock { block_number: 4, data: [109, 32, 97, 32, 80, 121, 116, 104, 111, 110] }, DataBlock { block_number: 5, data: [32, 100, 101, 118, 101, 108, 111, 112, 101, 114] }, DataBlock { block_number: 6, data: [46] }], snapshot: true }

Hello, I am a Go developer.
Delta { id: 3, index: [0, 7, 8], blocks: [DataBlock { block_number: 7, data: [109, 32, 97, 32, 71, 111, 32, 100, 101, 118] }, DataBlock { block_number: 8, data: [101, 108, 111, 112, 101, 114, 46] }], snapshot: true }

License

delta_rs is licensed under this licensed:

Commit count: 21

cargo fmt