GithubHelp home page GithubHelp logo

xdb's People

Contributors

rishavbhowmik avatar

Stargazers

 avatar

Watchers

 avatar

xdb's Issues

Fix index errors: not_found -> not_provided + improve error descriptions

Storage.read_block - option max_data_read_length

pub fn read_block(&mut self, block_index: BlockIndex) -> Result<(usize, Vec<u8>), Error> {

To Do:

read_block(
    &mut self,
    block_index: BlockIndex,
    data_start_index: Option<BlockLength>,
    data_end_index: Option<BlockLength>
) {
   // ...
}

Why needed?

Make log traversal more efficient. No need to read full segment payload while traversing.

New Error Framework

Errors in the code base are not standardised so far.

All Errors should be collected in a single file for each sub-package

Error {
  code: 500, // HTTP like error code
  message: format!(
    "{}/{} - {}",
    MODULE_NAME,
    "<error_brief>",
    "<error_description>"
  )
}

Improve project structure and naming

Current status (5c9792ae0edfe8233987fea622c94084747883e4):

Existing structure of project

We are using Cargo workspace to manage multiple packages(library or binary) in this repo.

[workspace]

members = [
    "util",       # Dir: /util, Description: Reusable functions and structs, such as custom error struct
    "storage",    # Dir: /storage, Description: Module to manage storage file with blocks of fixed size. ie, the primitive storage engine
    "logchain",   # Dir: /logchain, Description: Abstract function for Storage struct, to store data as a chain of blocks.
    "index",      # Dir: /index, Description: Inbuild HashMapIndex, BtreeIndex, etc... logic buit for logchain, along with kv store(Manage CRUD for keyvalue store).
]

Existing naming used

  • block: A segment of fixed size on storage file.

  • block_index: The serial index of a block on storage file.

  • block_data: The data of a block on storage file.

  • block_header: The header of a block on storage file.

  • block_len: The length of a block on storage file.

  • log / logchain: A chain of blocks. (This one makes me cry)

  • kv: module to manage Key-value store on block storage.

  • tupple: A tuple in Key-value store.

Issues

Issues with current naming

  1. block is a segment of fixed size on storage file (we have tell this docs). But a block can be any entity of any size.
  2. logchain This is a crazy meaningless name.

Issues with existing structure

  1. Now, we see that this project can be used to build multiple database binaries. Not just one graph DB as intended intially. So, it makes more sence to segregate storage engine libraries and buildable packages.
  2. In index module, we have kv module, which is a has primitive function to manage crud for KV store. So, kv module deserves to be a separate library, and should not be restructed to inbuilt index data structues present in index module.
  3. In Error framework, We have and error type Happens (which denotes to expected errors which can be part of the logic). This brings in requirement to perform error handling, which may not suit dependency injection as good practice. We have used this extensively in index module, so we must reconsider this.

Resolutions

New naming

  • page: A segment of fixed size on storage file. (Rename from block)

  • page_index: The serial index of a page on storage file.

  • page_payload: The data intended to be stored in a page.

  • page_header: Initial bytes of a page to store little-endian representation for size of page_payload in bytes.

  • page_padding: Unused space of a page.

  • page_body: All the bytes inside a page. page_header + page_payload + page_padding

  • pagestore: Module to manage storage file with pages of fixed size. ie, the primitive storage engine. (Rename from storage)

  • pagelist: A chain of pages. (Rename from logchain)

New structure

Follow convention

More about pages
About firebirdDB

[workspace]

members = [
    "util",                         # {Error, Logger, Cursor}
    "storage_engine/page_store",    # {PagePayload, PageStore, PageStoreHeader, PageIndex}
    "storage_engine/page_list",     # {create, append, delete}
    "storage_engine/kv_serializer", # {serialize_kv, deserialize_kv, serialize_kv_list, deserialize_kv_list}
    "storage_engine/index_traits",  # {IndexOpration, UnqiueIndexOpration, IndexSerializer, IndexClone}
    
    # More in future
    "kv_db_lite",
    "kv_db",
    "document_db_lite",
    "document_db",
    "graph_db",
]
  • Verify if Resolution works
  • Implement the changes

Need to close following issues before or along side

logchain.read_log

/// Returns data: Vec<u8>
pub fn read_log(
   storage: &mut Storage,
   start_segment_block_index: BlockIndex
) -> Result<Vec<u8>, Error> {
   // traverse log
   // return log data as Vec<u8>
}
  • define read_log
  • integration tests for read_log in logchain/tests/logchain_storage_flows.rs

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.