Exemplo n.º 1
0
def update_jubatus(id_, datum_):
    nn = client.nearest_neighbor("127.0.0.1", 9199)
    retry_max = 1
    retry_interval = 1
    try:
        retry_count = retry_max
        while True:
            try:
                nn.set_row(NAME, str(id_), datum_)
                break
            except (msgpackrpc.error.TransportError,
                    msgpackrpc.error.TimeoutError) as e:
                retry_count -= 1
                if retry_count <= 0:
                    raise

                nn.get_client().close()
                nn = client.nearest_neighbor("127.0.0.1", 9199)

                time.sleep(retry_interval)
                continue

    except msgpackrpc.error.RPCError as e:
        raise

    finally:
        nn.get_client().close()
def update_jubatus(id_, datum_):
    nn = client.nearest_neighbor("127.0.0.1", 9199)
    retry_max = 1
    retry_interval = 1
    try:
        retry_count = retry_max
        while True:
            try:
                nn.set_row(NAME, str(id_) , datum_)
                break
            except (msgpackrpc.error.TransportError, msgpackrpc.error.TimeoutError) as e:
                retry_count -= 1
                if retry_count <= 0:
                    raise

                nn.get_client().close()
                nn = client.nearest_neighbor("127.0.0.1", 9199)

                time.sleep(retry_interval)
                continue

    except msgpackrpc.error.RPCError as e:
        raise

    finally:
        nn.get_client().close()
Exemplo n.º 3
0
#!/usr/bin/env python

import sys
from nearest_neighbor import client
from nearest_neighbor import types

NAME = "sensor_nn"
nn = client.nearest_neighbor("127.0.0.1", 9199)
id_ = sys.argv[1]

print nn.similar_row_from_id(NAME, str(id_), 5)
#!/usr/bin/env python

import sys
from nearest_neighbor import client
from nearest_neighbor import types

NAME = "sensor_nn"
nn = client.nearest_neighbor("127.0.0.1", 9199)
id_ = sys.argv[1]

print nn.similar_row_from_id(NAME, str(id_) , 5)