Code Monkey home page Code Monkey logo

cattledb-extensions's Introduction

cdb_ext

Build Status

Extensions and Common Helpers für CattleDB

The timeseries classes provide a ordered list of timestamps with a timestamp offset and a float value.

insert Insert is always sorted. O(1) for appending or prepending items. O(log n) for inserts.

access By index access is O(1). The more common access by timestamp is O(log n).

Usage

Initialize one of the main classes.

from cdb_ext import TSList, FastTSList, PyTSList

# use fast c++ version
ts = FastTSList("key", "metric")

# use python version
ts = PyTSList("key", "metric")

# use best available
ts = TSList("key", "metric")

Add items using Python syntax. Timezone offsets can be given as tuple or using pendulum datetimes.

import pendulum
import random
from cdb_ext import FastTSList

ts = FastTSList("my_device", "temperature")


start = pendulum.now("Europe/Vienna")
for i in range(24):
    ts[start.add(hours=i)] = random.random() * 30.0

# access by ts (other timezone)
print(ts[start])

# access by index
print(ts.at_index(2))

# trim to 3 items
ts.trim_index(2, 4)

# remove item
del ts[start.add(hours=3)]

# iterate raw
for t in ts:
    print(t)

# iterate iso datetime tuples
for t in ts.iter_iso():
    print(t)

# iterate pendulum datetime tuples
for t in ts.iter_datetime():
    print(t)

Building

To build the extension cmake is needed.

python setup.py develop
pytest tests

# creating windows distribution
python setup.py sdist bdist_wheel

cattledb-extensions's People

Contributors

wuttem 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.