项目作者: ly0va

项目描述 :
Simple one-table remote database that can store robots
高级语言: C++
项目地址: git://github.com/ly0va/GL-robots-db.git
创建时间: 2020-04-19T00:02:38Z
项目社区:https://github.com/ly0va/GL-robots-db

开源协议:

下载


Simple Robots Database

Simple one-table remote database that can store robots. Made during GlobalLogic C++ practice.

Installation

Dependencies: libjsoncpp, libzmq

On Ubuntu:

  1. apt-get install libjsoncpp-dev libzmq3-dev

On Arch:

  1. pacman -S jsoncpp zeromq

After installing dependencies, run:

  1. git clone https://github.com/ly0va/GL-robots-db.git
  2. cd GL-robots-db
  3. mkdir build
  4. cd build
  5. cmake ..
  6. cmake --build .

Usage

Server

To start, run ./server [port]. Default port is 31111.

Client

To use, run ./client [host] [port]. Default host is localhost, default port is 31111.

Using client, you can add/remove/update/find robots in the database. Robot is defined as:

  1. struct Robot {
  2. int price;
  3. float weight;
  4. std::string name;
  5. };
  6. // Examples
  7. Robot bumblebee = {100500, 3.1415, "Bumblebee"};
  8. Robot bender = {18, 2.71828, "Bender"};

Efficiency

Let S be the size of the entry, and T be the total size of the database.
Then, time efficiency of the operations can be expressed as

Add Delete Update Find by id Find by field
O(S) O(1) O(S) O(S) O(T)

As per space, whole database is stored in 2 files (instead of 1 file per entry),
so there is practically no overhead due to file system block sizes.

Features

  • Basic database operations
  • Fully stored on the filesystem
  • Time and space efficient
  • LRU cache for faster retrieval
  • Server can handle multiple clients at the same time
  • Endianness-agnostic serialization
  • Crossplatform