def add_data(traffic_data): gpudb = GPUdb(encoding='BINARY',gpudb_ip='10.1.10.31',gpudb_port='9191') # Add more fileds as needed for the analysis type_definition = """{ "type":"record", "name":"gen_pt", "fields":[ {"name":"x","type":"double"}, {"name":"y","type":"double"}, {"name":"src","type":"string"}, {"name":"dst","type":"string"}, {"name":"payload","type":"string"} ] }""" retobj = gpudb.do_register_type(type_definition,"","point-type","POINT") type_id = retobj['type_id'] set_id = str(uuid.uuid1()) retobj = gpudb.do_new_set(type_id,set_id) x = 1;y = 1 encoded_datums = [] for e in traffic_data: datum = ordereddict.OrderedDict([('x',x), ('y',y), ('src',e[0]),('dst',e[1]),('payload',e[2])]) encoded_datum = gpudb.encode_datum(type_definition,datum) encoded_datums.append(encoded_datum) x+=1;y+=1 gpudb.do_bulk_add(set_id, encoded_datums) return set_id,gpudb
def add_data(traffic_data): gpudb = GPUdb(encoding='BINARY', gpudb_ip='10.1.10.31', gpudb_port='9191') # Add more fileds as needed for the analysis type_definition = """{ "type":"record", "name":"gen_pt", "fields":[ {"name":"x","type":"double"}, {"name":"y","type":"double"}, {"name":"src","type":"string"}, {"name":"dst","type":"string"}, {"name":"payload","type":"string"} ] }""" retobj = gpudb.do_register_type(type_definition, "", "point-type", "POINT") type_id = retobj['type_id'] set_id = str(uuid.uuid1()) retobj = gpudb.do_new_set(type_id, set_id) x = 1 y = 1 encoded_datums = [] for e in traffic_data: datum = ordereddict.OrderedDict([('x', x), ('y', y), ('src', e[0]), ('dst', e[1]), ('payload', e[2])]) encoded_datum = gpudb.encode_datum(type_definition, datum) encoded_datums.append(encoded_datum) x += 1 y += 1 gpudb.do_bulk_add(set_id, encoded_datums) return set_id, gpudb