Giter Site home page Giter Site logo

smalldb's Introduction

SmallDB

A very simple database made with pure C++

Types

  • Double
  • Long
  • String (with max string length)
  • Datetime (no timezone)

Operations

  • insertRow()
  • find()
  • readDouble(), writeDouble()
  • readLong(), writeLong()
  • readString(), writeString()
  • readDatetime(), writeDatetime()
  • delete()

Architecture

The general arch is expressed in architecture.txt.

File layout

    |----------------|--------|-------|-------|-------|-------|-------|-   -|
    | number of rows | header | row 0 | row 1 | row 2 | row 3 | row 4 | ... |
    |----------------|--------|-------|-------|-------|-------|-------|-   -|

  Header:
    |---------------|------|-------------|------|-------------|-   -|------------|
    | header length | name | type letter | name | type letter | ... | row length |
    |---------------|------|-------------|------|-------------|-   -|------------|

    * name is std::string_view::c_str() with unicode support

    type letter:
      |-----|-----------------|     |-----|     |-----|     |-----|
      | 'S' | max size column | or  | 'D' | or  | 'L' | or  | 'T' |
      |-----|-----------------|     |-----|     |-----|     |-----|

      * type letter is the id letter for Datatype
      * max size column is the max size of the column in bytes, it is only used for String

  Row:
    |----------|----------|----------|-   -|
    | column 0 | column 1 | column 2 | ... |
    |----------|----------|----------|-   -|

    * row has predefined length according to each type for Double, Long and Datetime
    * if there is a string_view in the row, there will be length information in header

  Serialization for Datetime:
    |------|-------|-----|------|--------|--------|
    | year | month | day | hour | minute | second |
    |------|-------|-----|------|--------|--------|
 
    year, month, day, hour, minute, second are saved as uint32_t

  Serialization for string:
    |-          -|-       -|
    | characters | padding |
    |-          -|-       -|

    * pad with 0 until assigned string size is filled (for row skipping conveniences)
 
  * All lengths are uint32_t

Become a patreon

smalldb's People

Contributors

emmanuelmess avatar

Watchers

James Cloos avatar  avatar  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.