コード例 #1
0
def main():
    # we augment the schema by adding columns for 5 vantage points
    for i in range(NUMVPS):
        schema["d_vp-{}".format(i)] = {'type': "float", 'index': 1}
    db = DocDB('pk', schema=schema)
    server = TSDBServer(db)
    server.run()
コード例 #2
0
def main():
    # we augment the schema by adding columns for 5 vantage points
    for i in range(NUMVPS):
        schema["d_vp-{}".format(i)] = {'convert': float, 'index': 1}
    db = DictDB(schema, 'pk')
    server = TSDBServer(db)
    server.run()
コード例 #3
0
def main(load=False, dbname="db", overwrite=False, threshold = 10, wordlength = 16, tslen = 256, cardinality = 64):
    # we augment the schema by adding columns for 5 vantage points
    #for i in range(NUMVPS):
    #    schema["d_vp-{}".format(i)] = {'convert': float, 'index': 1}
    db = PersistentDB(schema, 'pk',load=load, dbname=dbname, overwrite=overwrite, threshold = threshold, wordlength = wordlength, tslen = tslen, cardinality = cardinality)
    server = TSDBServer(db)
    server.run()
コード例 #4
0
def main():
    # we augment the schema by adding columns for 5 vantage points
    for i in range(NUMVPS):
        schema["d_vp-{}".format(i)] = {'type': "float", 'index': 1}
    db = DocDB('pk', schema=schema)
    server = TSDBServer(db)
    server.run()
コード例 #5
0
def main():
    # we augment the schema by adding columns for 5 vantage points
    for i in range(NUMVPS):
        schema["d_vp-{}".format(i)] = {'convert': float, 'index': 1}
    db = DictDB(schema, 'pk')
    server = TSDBServer(db)
    server.rest_run()
コード例 #6
0
def main():
    for i in range(NUMVPS):
        schema["d_vp-{}".format(i)] = {'type': 'float',  'index': 1}

    db = PersistentDB(schema, pk_field='pk', db_name='testing', ts_length=TS_LENGTH, testing=True)
    server = TSDBServer(db)
    server.run()
    db.delete_database()
コード例 #7
0
def main():
    # we augment the schema by adding columns for 5 vantage points
    for i in range(NUMVPS):
        schema["d_vp-{}".format(i)] = {'convert': float, 'index': 1}
    # db = DictDB(schema, 'pk')
    db = connect("/tmp/four_continents.dbdb", "/tmp/four_continents_idx.dbdb", schema)
    server = TSDBServer(db, 30000)
    server.run()
コード例 #8
0
ファイル: go_server.py プロジェクト: Mynti207/cs207project
def main():

    # initialize the database
    db = DictDB(schema, 'pk')

    # initialize & run the server
    server = TSDBServer(db)
    server.run()
コード例 #9
0
def main():
    # we augment the schema by adding columns for 5 vantage points
    for i in range(NUMVPS):
        schema["d_vp-{}".format(i)] = {'convert': float, 'index': 1}
    # db = DictDB(schema, 'pk')
    db = connect("/tmp/four_continents.dbdb", "/tmp/four_continents_idx.dbdb",
                 schema)
    server = TSDBServer(db, 30000)
    server.run()
コード例 #10
0
def main():
    for i in range(NUMVPS):
        schema["d_vp-{}".format(i)] = {'type': 'float', 'index': 1}

    db = PersistentDB(schema,
                      pk_field='pk',
                      db_name='testing',
                      ts_length=TS_LENGTH,
                      testing=True)
    server = TSDBServer(db)
    server.run()
    db.delete_database()
コード例 #11
0
def main(ts_length, db_name, data_dir):
    '''
    Runs the persistent database server.

    Parameters
    ----------
    ts_length : int
        Length of time series stored in the database
    db_name : str
        Name of the database
    data_dir : str
        Folder location of the database

    Returns
    -------
    Nothing, modifies in-place.
    '''

    # set up directory for db data
    if not os.path.exists(data_dir):
        os.makedirs(data_dir)

    # initialize the database
    db = PersistentDB(schema=schema, pkfield='pk', ts_length=ts_length,
                      db_name=db_name, data_dir=data_dir)

    # initialize & run the server
    server = TSDBServer(db)

    # initialize ayncio event loop
    loop = asyncio.get_event_loop()

    # run database server
    try:
        loop.run_until_complete(server.run())

    # this script is generally called as a sub-process
    # make sure that the database is closed and all data committed
    # if the sub-process is interrupted
    except RuntimeError:
        loop.close()
        db.close()
    except Exception:
        loop.close()
        db.close()
    except KeyboardInterrupt:
        loop.close()
        db.close()
コード例 #12
0
    def test_protocol_delete(self):
        db = DictDB(schema, 'pk')
        server = TSDBServer(db)
        prot = TSDBProtocol(server)
    
        t1 = [0,1,2,3,4]
        v1 = [1.0,2.0,3.0,2.0,1.0]
        ats1 = ts.TimeSeries(t1, v1)
    
        t2 = [10,11,12,13,14]
        v2 = [-1.0,-2.0,-3.0,-2.0,-1.0]
        ats2 = ts.TimeSeries(t2, v2)

        insert_op = {}
        insert_op['pk'] = 1
        insert_op['ts'] = ats1
        insert_op['op'] = 'insert_ts'
    
        # Test Protocol Insert
        insert_return = prot._insert_ts(insert_op)
        assert(insert_return['op'] == 'insert_ts')
        assert(insert_return['status'] == TSDBStatus.OK)
        assert(insert_return['payload'] == None)
        inserted_row = server.db.rows[1]
        assert(inserted_row['pk'] == 1)
        assert(inserted_row['ts'] == ats1)

        insert_return2 = prot._insert_ts(insert_op)
        assert(insert_return2['op'] == 'insert_ts')
        assert(insert_return2['status'] == TSDBStatus.INVALID_KEY)

        delete_op = {}
        delete_op['pk'] = 1
        delete_op['op'] = 'delete_ts'

        delete_return = prot._delete_ts(delete_op)
        assert(delete_return['op'] == 'delete_ts')
        assert(delete_return['status'] == TSDBStatus.OK)
        assert(delete_return['payload'] == None)
        assert (len(server.db.rows) == 0)

        delete_return2 = prot._delete_ts(delete_op)
        assert(delete_return2['op'] == 'delete_ts')
        assert(delete_return2['status'] == TSDBStatus.INVALID_KEY)
コード例 #13
0
    def test_augmented_select(self):
        db = DictDB(schema, 'pk')
        server = TSDBServer(db)
        prot = TSDBProtocol(server)

        t1 = [0,1,2,3,4]
        v1 = [1.0,2.0,3.0,2.0,1.0]
        ats1 = ts.TimeSeries(t1, v1)

        t2 = [10,11,12,13,14]
        v2 = [-1.0,-2.0,-3.0,-2.0,-1.0]
        ats2 = ts.TimeSeries(t2, v2)

        insert_op = {}
        insert_op['pk'] = 1
        insert_op['ts'] = ats1
        insert_op['op'] = 'insert_ts'

        # Test Protocol Insert
        insert_return = prot._insert_ts(insert_op)
        assert(insert_return['op'] == 'insert_ts')
        assert(insert_return['status'] == TSDBStatus.OK)
        assert(insert_return['payload'] == None)
        inserted_row = server.db.rows[1]
        assert(inserted_row['pk'] == 1)
        assert(inserted_row['ts'] == ats1)

        # Test Protocol Select (None fields)
        metadata_dict = {'pk': {'>': 0}}
        fields = None
        additional = None
        aug_select_op = TSDBOp_AugmentedSelect('corr', ['mean', 'std'], [t2,v2], metadata_dict, additional )
        aug_select_return = prot._augmented_select(aug_select_op)

        assert(aug_select_return['op'] == 'augmented_select')
        assert(aug_select_return['status'] == TSDBStatus.OK)
        assert(aug_select_return['payload'] == {1: {'mean': 1.4142135623730403}})

        
コード例 #14
0
    def test_protocol_triggers(self):

        db = DictDB(schema, 'pk')
        server = TSDBServer(db)
        prot = TSDBProtocol(server)

        # Test Add Trigger
        add_trigger_op = TSDBOp_AddTrigger('stats', 'insert_ts', ['mean', 'std'], None)
        prot._add_trigger(add_trigger_op)

        mod = import_module('procs.stats')
        storedproc = getattr(mod,'main')

        assert(server.triggers['insert_ts'] ==  [('stats', storedproc, None, ['mean', 'std'])])


        # Test delete Trigger
        delete_trigger_op = TSDBOp_RemoveTrigger('stats', 'insert_ts')
        prot._remove_trigger(delete_trigger_op)

        mod = import_module('procs.stats')
        storedproc = getattr(mod,'main')

        assert(server.triggers['insert_ts'] ==  [])
コード例 #15
0
def main():
    db = PersistentDB(schema, 'pk', load=False, overwrite=True)
    server = TSDBServer(db)
    server.run()
コード例 #16
0
ファイル: go_server.py プロジェクト: Planet-Nine/cs207project
def main():
    db = PersistentDB(schema, 'pk', load=False, overwrite=True)
    server = TSDBServer(db)
    server.run()
コード例 #17
0
 def test_protocol(self):
     db = DictDB(schema, 'pk')
     server = TSDBServer(db)
     prot = TSDBProtocol(server)
 
     # Dumb server tests
     assert(server.db == db)
     assert(server.port == 9999)
 
     t1 = [0,1,2,3,4]
     v1 = [1.0,2.0,3.0,2.0,1.0]
     ats1 = ts.TimeSeries(t1, v1)
 
     t2 = [10,11,12,13,14]
     v2 = [-1.0,-2.0,-3.0,-2.0,-1.0]
     ats2 = ts.TimeSeries(t2, v2)
 
     # Test TSDBOp_InsertTS
     insert_op = {}
     insert_op['pk'] = 1
     insert_op['ts'] = ats1
     insert_op['op'] = 'insert_ts'
     InsertedTS = TSDBOp_InsertTS(1, ats1)
     assert(insert_op == InsertedTS)
 
     # Test Protocol Insert
     insert_return = prot._insert_ts(insert_op)
     assert(insert_return['op'] == 'insert_ts')
     assert(insert_return['status'] == TSDBStatus.OK)
     assert(insert_return['payload'] == None)
     inserted_row = server.db.rows[1]
     assert(inserted_row['pk'] == 1)
     assert(inserted_row['ts'] == ats1)
     
     # Add some more data
     prot._insert_ts(TSDBOp_InsertTS(2, ats1))
     inserted_row = server.db.rows[2]
     assert(inserted_row['ts'] == ats1)
     
     # Test Protocol Upsert
     upserted_meta = TSDBOp_UpsertMeta(2, {'ts': ats2, 'order': 1})
     upsert_return = prot._upsert_meta(upserted_meta)
     assert(upsert_return['op'] == 'upsert_meta')
     assert(upsert_return['status'] == TSDBStatus.OK)
     assert(upsert_return['payload'] == None)
 
     # Test Protocol Select (None fields)
     metadata_dict = {'pk': {'>': 0}}
     fields = None
     additional = None
     select_op = TSDBOp_Select(metadata_dict, fields, additional)
     select_return = prot._select(select_op)
     print("Here", select_return)
     assert(select_return['op'] == 'select')
     assert(select_return['status'] == TSDBStatus.OK)
     assert(select_return['payload'][1] == {})
     assert(select_return['payload'][2] == {})
     
     # Test Protocol Select
     metadata_dict = {'pk': {'>': 0}}
     fields = ['ts']
     additional = None
     select_op = TSDBOp_Select(metadata_dict, fields, additional)
     select_return = prot._select(select_op)
     assert(select_return['op'] == 'select')
     assert(select_return['status'] == TSDBStatus.OK)
     assert(select_return['payload'][1]['ts'] == ats1)
     assert(select_return['payload'][2]['ts'] == ats2)
     
     # Test Add Trigger
     add_trigger_op = TSDBOp_AddTrigger('stats', 'insert_ts', ['mean', 'std'], None)
     prot._add_trigger(add_trigger_op)
     
     mod = import_module('procs.stats')
     storedproc = getattr(mod,'main')
     
     assert(server.triggers['insert_ts'] ==  [('stats', storedproc, None, ['mean', 'std'])])
コード例 #18
0
ファイル: go_server.py プロジェクト: amlsf/tsdb-skeleton
def main():
    db = DictDB(schema)
    server = TSDBServer(db)
    server.run()