Skip to content

destrex271/LokiKV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LokiKV : ⚠️ WIP

Rust Build Test
DeepSource DeepSource DeepSource

LokiKV is intended to be a simple to use in memory Key-Value Store that can also persist data on disk. This project is specifically for learning purposes only.

To try out loki-kv you can follow these steps:

Create a control file(toml):

host = "localhost"
port = 8765
last_wal_timeline = 0
last_checkpoint_id = 0
checkpoint_directory_path = "/home/akshat/lokikv/checkpoints_follower"
wal_directory_path = "/home/akshat/lokikv/wal_follower"
current_leader_value = 12 # optional
self_identifier = 13 # optional
send_addr = "0.0.0.0:8070"
consume_addr = "0.0.0.0:8071"
checkpoint_timer_interval = 1
paxos_timer_interval = 2
gossip_timeout = 300
git clone https://github.com/destrex271/LokiKV

# path to control file 
export CONTROL_FILE_PATH="/home/akshat/control_follow.toml"

cargo run --bin server-db # in a separate terminal
# runs on localhost:8765 by default

# in a separate terminal to start CLI
cargo run  --bin client -- localhost 8765

Current Features

Data Types

  • Blob: <BLOB_BEGINS>data of blob<BLOB_ENDS>
  • Integer
  • Boolean
  • Float
  • String
  • HyperLogLog: To estimate cardinality

Operations

  • Set key values
  • Get value for key
  • Print all values in collection as a string
  • Create multiple types of collections (\c_bcol, \c_hcol, \c_bcust)
  • Select Collections
  • List all available collections

Architecture

  • Overall Process image

  • LokiKV structure image

  • LokiQL Executor image

Supported Operations

LokiQL is a custom query language for interacting with the LokiKV database. This document describes the supported commands and their syntax.

Collections

  • Create multiple Collections(similar to tables)
  • Collections are of the following types:
    • Hashmap
    • BTreeMap
    • Custom BTree
  • List collections
  • Select one collection at a time

Literals

Whitespace

  • Spaces, newlines, carriage returns, and tabs are ignored where applicable.

Data Types

  • Integer (INT): Signed or unsigned integer numbers.
  • Float (FLOAT): Signed or unsigned floating point numbers.
  • Boolean (BOOL): true or false.
  • String (STRING): Enclosed in single quotes ('example').
  • Blob (BLOB): Enclosed in <BLOB_BEGINS> and <BLOB_ENDS>.
  • HyperLogLog(HLL): Init by ADDHLL command

Identifiers

  • ID: Any string without whitespace.

Command Syntax

LokiQL supports three types of commands:

Duo Commands (Require a Key and a Value)

Command Syntax
SET SET ID (STRING / INT / BOOL / FLOAT / BLOB)
ADDHLL(adds value to a HLL data type) ADHLL ID (STRING / INT / BOOL / FLOAT / BLOB)

Examples:

SET mykey 'hello'
SET count 42
SET enabled true
SET temperature 98.6
SET file <BLOB_BEGINS>aGVsbG8=<BLOB_ENDS>

Uni Commands (Require a Key Only)

Command Syntax
GET GET <ID>
HLLCOUNT(estimated cardinality) HLLCOUNT <ID>
INCR INCR <ID>
DECR DECR <ID>
PERSIST PERSIST <collection_name>
LOAD_BCUST LOAD_BCUST <collection_name>
LOAD_BDEF LOAD_BDEF <collection_name>
LOAD_HMAP LOAD_HMAP <collection_name>
/c_hcol /c_hcol <ID>
/c_bcol /c_bcol <ID>
/c_bcust /c_bcust <ID>
/selectcol /selectcol <ID>

Examples:

GET mykey
INCR count
DECR count
/selectcol users

Solo Commands (Do Not Require Arguments)

Command Syntax
DISPLAY DISPLAY
/getcur_colname /getcur_colname
/listcolnames /listcolnames

Examples:

DISPLAY
/getcur_colname
/listcolnames

Command File Structure

A LokiQL command file follows this structure:

COMMAND
COMMAND
COMMAND
COMMAND; COMMAND; COMMAND;

Example

SET mykey 'hello'
GET mykey
DISPLAY

Multiple command in a single line must be separated by ;. Single commands don't need to follow a ;



Node Discovery

LokiKV currently uses a very adhoc version of the gossip protocol where we broadcast all the information across the network. All the nodes have varying values for paxos timer i.e. service discovery timer to facilitate for a smoother discovery flow and avoiding deadlocks(i.e. all the nodes begin consumption and broadcast at the same time).

TODO

  • Add support for distributed setup via Paxos Algorithm

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages