0.0.12 • Published 2 years ago

@umlss/filesystem-timeseries-db v0.0.12

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

file-system-time-series-database

This module allows using a file system as a time series database. It is efficient for these queries:

  • Get a range of data for an identifier (such as a user id)
  • Get the most recent time for an identifer (such as a user id)
  • Get the earliest time for an identifer (such as a user id)

The number of files in a directory is attempting to be limited to 768, though this may be exceeded occasionally. NFS allows 65535.

File System Format

The data is laid out in the following format, which shards the data by month:

/year/group1/group2/8ofid/8ofid/8ofid/id/year-month-day.extension

For example, for user deadbeef with a JSON file, group1 garmin, group2 sleeps:

/2020/garmin/sleeps/de/ad/be/deadbeef/2020-08-09.json

this will support billions of users with ease, provided the user ID has sufficient randomness.

Performance

Performance Assumptions.

The file system is assumed to have about 10mS of latency or less.

Parallelism

Operations are meant to be parallized, so for example if you are looking for the latest data the year direcotry would be queried for existence in parallel from the start epoch (2020) to today's current date, using Promise.map() to parallalize.

Usage

This package was developed to work with AWS's EFS on Lambda, though the file system handle is passed into this library so it doesn't really care.

Module Usage

  1. Add Module:

    npm install --save filesystem-timeseries-db
  2. Require Statement:

    const FsTimeSeriesDB = require('filesystem-timeseries-db');
  3. General usage:

    const fileSystem = fileHandle;
    const dbInstance = Object.create(FsTimeSeriesDB).setOptions({rootPath: rootPath});

Testing

Interactive Testing

  1. Run Docker Compose:

    docker-compose run app  /bin/bash
  2. Navigate to the directory where the source code is located:

    cd /home/code       
  3. Run NPM install

    npm install
  4. Run the unit tests

    npm test test/*.js
0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago