Simple one-table remote database that can store robots. Made during GlobalLogic C++ practice.
Dependencies: libjsoncpp
, libzmq
On Ubuntu:
apt-get install libjsoncpp-dev libzmq3-dev
On Arch:
pacman -S jsoncpp zeromq
After installing dependencies, run:
git clone https://github.com/ly0va/GL-robots-db.git
cd GL-robots-db
mkdir build
cd build
cmake ..
cmake --build .
To start, run ./server [port]
. Default port is 31111
.
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:
struct Robot {
int price;
float weight;
std::string name;
};
// Examples
Robot bumblebee = {100500, 3.1415, "Bumblebee"};
Robot bender = {18, 2.71828, "Bender"};
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.
- 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