Giter Site home page Giter Site logo

xe1gyq / rollingdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openalpr/rollingdb

0.0 1.0 0.0 104 KB

RollingDB Storage Library

License: GNU Lesser General Public License v3.0

CMake 1.91% Makefile 0.64% Shell 0.31% C++ 96.80% Python 0.33%

rollingdb's Introduction

rollingdb

Overview

This is a time-based rolling object database. The purpose of the database is to store binary objects over time and automatically delete the oldest records when the maximum file size is reached.

This library is used in the OpenALPR software to store image files, and remove the oldest files once a maximum disk quota is achieved.

Using an LMDB database is more efficient for this purpose especially for a large number of files.
When the database reaches 100k+ files, many file systems tend to become very slow when listing and deleting those files. LMDB, by comparison, stores files quickly regardless of the database size. The files are chunked into relatively large file sizes (e.g., 1GB), so a large number of files can be deleted virtually instantaneously.

Each file is indexed by a UUID that contains an epoch time (in milliseconds).

This is a rolling buffer of lmdb databases that contain the images. The archive is given a maximum size, and a location to store the images. It writes database files and cuts them off at one gigabyte. As time progresses and the max size is exceeded, the oldest database files are deleted.

LMDB is the database engine. Files are named: [epoch_start].mdb

key = uuid for image

epoch start is the time for the very first image in the archive

Once a database file reaches 1GB, it is no longer written to, and we start a new one.

On reads: Request for image site-id-epoch_time.jpg

  • Parse the epoch time
  • Look for the last database that has an epoch time before the image. open it and read the image.

Compile Instructions (Linux):

  • sudo apt-get update && sudo apt-get install libre2-dev libtclap-dev liblmdb-dev
  • mkdir build
  • cmake ..
  • make

Test program (rdb_write, rdb_read):

The test programs demonstrate the use of the library. You can add or retrieve binary data by key.

The format for the keys are: [arbitrary name]-[epoch_time_ms]

Once you add more data than the current database file can hold, it will create a new database file. Once the maximum total file size has been achieved, the database will delete the oldest files (by epoch time).

For example, to write and read a file:

./rdb_write ./librollingdb.so.2
./rdb_read -o /tmp/testout ./librollingdb.so.2-1503072730590

License:

RollingDB is licensed under the terms of the GNU Lesser GPL (LGPL)

rollingdb's People

Contributors

matthill avatar

Watchers

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