# Path: quantbube/timeseries/storage/mongo_connection.py
# class MongoConnection(object):
#     """
#     """
#     config = settings.MONGO_ENGINE
#     dbs = {}  # mongo db
#     connections = {}  # mongo connection strings
# 
#     @classmethod
#     def get_client(cls, alias="default"):
#         """
#         :param alias:
#         :return:
#         """
#         if cls.connections.get(alias):
#             mongo_client = cls.connections[alias]
#         else:
#             mongo_config = cls.config.get(alias)
#             url = mongo_config.get("url")
#             options = mongo_config.get("options", {})
#             client = pymongo.MongoClient(url, **options)
# 
#             cls.connections[alias] = client
#             mongo_client = client
#         return mongo_client
# 
#     @classmethod
#     def disconnect(cls, alias="default"):
#         """
#         :return:
#         """
#         if alias in cls.connections:
#             cls.connections[alias].close()
#             cls.connections.pop(alias)
# 
# Path: quantbube/timeseries/backends/base.py
# class TimeSeriesBase(abc.ABC):
#     """
#     base connection class
#     """
#     default_serializer_class = DummySerializer
#     default_compressor_class = DummyCompressor
# 
#     def __init__(self, serializer_class=None, compressor_class=None):
#         """
#         :param serializer_class:
#         :param compressor_class:
#         """
#         serializer_class = serializer_class or self.default_serializer_class
#         self.serializer = serializer_class()
#         compressor_class = compressor_class or self.default_compressor_class
#         self.compressor = compressor_class()
# 
#     @abc.abstractmethod
#     def add(self, name, *args, **kwargs):
#         """
#         add item to storage
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def get(self, name, *args, **kwargs):
#         """
#         get one item from storage
#         :param name:
#         :param args:
#         :param kwargs:
#         :return:
#         """
#         raise NotImplementedError()
# 
#     def count(self, name):
#         """
#         get the count of the data
#         :return:
#         """
#         raise NotImplementedError()
# 
#     def delete(self, name, *args, **kwargs):
#         """
#         delete item from the data
#         :param name:
#         :param args:
#         :param kwargs:
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def trim(self, name, length):
#         """
#         trim the length of the data
#         :param name: the key location
#         :param length: the length want to trim
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def get_slice(self, name, start=None, end=None, asc=True):
#         """
#         return sorted set from args
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def add_many(self, name, data, *args, **kwargs):
#         """
#         add many data
#         :param name:
#         :param data:
#         :param args:
#         :param kwargs:
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def remove_many(self, *args, **kwargs):
#         """
#         remove many data
#         :param args:
#         :param kwargs:
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def exists(self, name, timestamp=None):
#         """
#         check data in database
#         :return: bool
#         """
#         raise NotImplementedError()


import functools
from quantbube.timeseries.storage import MongoConnection
from .base import TimeSeriesBase
# encoding:utf-8


"""
second resolution

schema
{ 
    name: "",
    data: {
    
    }
    timestamp: ""
}
"""


# Path: quantbube/timeseries/storage/mongo_connection.py
# class MongoConnection(object):
#     """
#     """
#     config = settings.MONGO_ENGINE
#     dbs = {}  # mongo db
#     connections = {}  # mongo connection strings
# 
#     @classmethod
#     def get_client(cls, alias="default"):
#         """
#         :param alias:
#         :return:
#         """
#         if cls.connections.get(alias):
#             mongo_client = cls.connections[alias]
#         else:
#             mongo_config = cls.config.get(alias)
#             url = mongo_config.get("url")
#             options = mongo_config.get("options", {})
#             client = pymongo.MongoClient(url, **options)
# 
#             cls.connections[alias] = client
#             mongo_client = client
#         return mongo_client
# 
#     @classmethod
#     def disconnect(cls, alias="default"):
#         """
#         :return:
#         """
#         if alias in cls.connections:
#             cls.connections[alias].close()
#             cls.connections.pop(alias)
# 
# Path: quantbube/timeseries/backends/base.py
# class TimeSeriesBase(abc.ABC):
#     """
#     base connection class
#     """
#     default_serializer_class = DummySerializer
#     default_compressor_class = DummyCompressor
# 
#     def __init__(self, serializer_class=None, compressor_class=None):
#         """
#         :param serializer_class:
#         :param compressor_class:
#         """
#         serializer_class = serializer_class or self.default_serializer_class
#         self.serializer = serializer_class()
#         compressor_class = compressor_class or self.default_compressor_class
#         self.compressor = compressor_class()
# 
#     @abc.abstractmethod
#     def add(self, name, *args, **kwargs):
#         """
#         add item to storage
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def get(self, name, *args, **kwargs):
#         """
#         get one item from storage
#         :param name:
#         :param args:
#         :param kwargs:
#         :return:
#         """
#         raise NotImplementedError()
# 
#     def count(self, name):
#         """
#         get the count of the data
#         :return:
#         """
#         raise NotImplementedError()
# 
#     def delete(self, name, *args, **kwargs):
#         """
#         delete item from the data
#         :param name:
#         :param args:
#         :param kwargs:
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def trim(self, name, length):
#         """
#         trim the length of the data
#         :param name: the key location
#         :param length: the length want to trim
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def get_slice(self, name, start=None, end=None, asc=True):
#         """
#         return sorted set from args
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def add_many(self, name, data, *args, **kwargs):
#         """
#         add many data
#         :param name:
#         :param data:
#         :param args:
#         :param kwargs:
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def remove_many(self, *args, **kwargs):
#         """
#         remove many data
#         :param args:
#         :param kwargs:
#         :return:
#         """
#         raise NotImplementedError()
# 
#     @abc.abstractmethod
#     def exists(self, name, timestamp=None):
#         """
#         check data in database
#         :return: bool
#         """
#         raise NotImplementedError()


# Path: quantbube/timeseries/backends/mongo.py
import functools
from quantbube.timeseries.storage import MongoConnection
from .base import TimeSeriesBase

# encoding:utf-8


"""
second resolution

schema
{ 
    name: "",
    data: {
    
    }
    timestamp: ""
}
"""


class MongoTimeSeries(TimeSeriesBase):