GithubHelp home page GithubHelp logo

kvrs's Introduction

About

Console binary key-value storage with output highlighting, searchability with regular expressions and aliasing of bash commands.

Usage

Basic operations

Set a key-value pair:

kvrs set "key" "value" --file="storage.kv"

Get the value by key

kvrs get "key" --file="storage.kv"

Update the value by key

kvrs update "key" "new value" --file="storage.kv"

Delete a key-value pair

kvrs remove "key" --file="storage.kv"

Find a key-value pair by regexp

kvrs find "regexp" --file="storage.kv"

This command tries to treat the keys as text and match them to the sample, returning all matches.

Sort

kvrs sort --file="storage.kv"

Returns a list of keys in lexicographic order.

Run the value as a bash command

kvrs set "list" "ls -la"
kvrs cmd "list" --file="storage.kv"

Common parameters

  • --file - the database file that the command will work with. By default, this parameter will be equal to the path to the file "storage.kv" in the home directory.

Roadmap

  • get, set, update, remove
  • cmd
  • sort
  • find

kvrs's People

Contributors

starovoid avatar

Stargazers

 avatar Alexander Ruliov avatar

Watchers

 avatar

Forkers

blacksoulhub

kvrs's Issues

Creating new data file

When should we create a new data file?
Now I suggest doing this only with a specific "new" command:

kvrs new "path"

Development of the data file format

Previously, it will look like this.

But there are still a few things to solve:

  1. What is the best way to represent the Index in the program: IndexMap<String, u64> or IndexMap<Vec<u8>, u64>. IndexMap is represented by the crate indexmap and allows to track the order in which keys are added.
  2. In what format should the Index be serialized? Now we are focusing on postcard.

UPDATED:
Now we are leaning towards using IndexMap<Vec<u8>, u64> in the prototype and potentially replacing Vec<u8> with SmallVec<u8> by the first stable release.

Data format

The data file contains binary values and by default has the .kv extension.

Section Type Size (in bytes)
identifier u64 8
version u8 1
index position u64 8
vacant blocks list position u64 8
record 1 [u8] arbitary
... ... ...
record n [u8] arbitary
vacant blocks list [u8] arbitary

  • Identifier

    The identifier is a "magic" number so that using it the program can make sure that it is actually dealing with a file of the correct format.

  • Version

    Just the file format version.

  • Index position

    The byte number from which begins record containing the index.

  • Vacant blocks list position

    The byte number from which the list of vacant blocks begins.

Record format

Section Type Size (in bytes)
data len (size) u64 8
data [u8] size

Vacant blocks list format

Sorted Vec<VacantBlock> serialized in postcard format.

struct VacantBlock {
    pos: u64,   // It's position in data file
    size: u64,  // Size in bytes
}

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.