Example #1
0
def decode(n, proto_factory=TBinaryProtocolFactory()):
    ab = addressbook.AddressBook()
    start = time.time()
    for i in range(n):
        deserialize(ab, ab_encoded, proto_factory)
    end = time.time()
    print("decode\t-> {}".format(end - start))
Example #2
0
def decode(n, proto_factory=TBinaryProtocolFactory()):
    ab = addressbook.AddressBook()
    start = time.time()
    for i in range(n):
        deserialize(ab, ab_encoded, proto_factory)
    end = time.time()
    print("decode\t-> {}".format(end - start))
Example #3
0
def test_mix_item():
    x_item = container.MixItem()
    x_item.list_map = [{'foo': 'bar'}]
    x_item.map_list = {'foo': ['hello', 'world']}

    x_item2 = deserialize(container.MixItem(), serialize(x_item))
    assert x_item == x_item2
Example #4
0
def test_map_item():
    m_item = container.MapItem()
    m_item.map_string = {'foo': 'bar'}
    m_item.map_map_string = {'foo': {'hello': 'world'}}

    m_item2 = deserialize(container.MapItem(), serialize(m_item))
    assert m_item == m_item2
Example #5
0
def decode_msg(kafka_msg):
    raw_payload = deserialize(STRUCTS.CollectorPayload(), kafka_msg,
                              TCyBinaryProtocolFactory())
    querystring = raw_payload.querystring
    obj = raw_payload.__dict__
    obj['querystring_parsed'] = parse.parse_qs(raw_payload.querystring)
    return obj
Example #6
0
def print_thrift(timestamp, data):
    json_payload = json.loads(data.decode('utf-8'))
    decoded_thrift_payload = base64.b64decode(json_payload['line'])
    thrift_payload = deserialize(collector_payload, decoded_thrift_payload,
                                 TCyBinaryProtocolFactory())
    print('{}: {}, {}'.format(timestamp, thrift_payload,
                              json_payload['errors']))
Example #7
0
def test_list_item():
    l_item = container.ListItem()
    l_item.list_string = ['foo', 'bar']
    l_item.list_list_string = [['foo', 'bar']]

    b = serialize(l_item)
    l_item2 = deserialize(container.ListItem(), b)
    assert l_item == l_item2
Example #8
0
def test_mix_item():
    x_item = container.MixItem()
    x_item.list_map = [{"foo": "bar"}]
    x_item.map_list = {"foo": ["hello", "world"]}

    b = serialize(x_item)
    x_item2 = deserialize(container.MixItem(), b)
    assert x_item == x_item2
Example #9
0
def test_map_item():
    m_item = container.MapItem()
    m_item.map_string = {"foo": "bar"}
    m_item.map_map_string = {"foo": {"hello": "world"}}

    b = serialize(m_item)
    m_item2 = deserialize(container.MapItem(), b)
    assert m_item == m_item2
Example #10
0
def test_list_item():
    l_item = container.ListItem()
    l_item.list_string = ["foo", "bar"]
    l_item.list_list_string = [["foo", "bar"]]

    b = serialize(l_item)
    l_item2 = deserialize(container.ListItem(), b)
    assert l_item == l_item2
Example #11
0
def decode_event(data, collector_payload):
    json_payload = json.loads(data.decode('utf-8'))
    decoded_thrift_payload = base64.b64decode(json_payload['line'])
    thrift_payload = deserialize(collector_payload, decoded_thrift_payload,
                                 TCyBinaryProtocolFactory())

    qs = thrift_payload.querystring
    event = {'qs': parse.parse_qs(qs), 'errors': json_payload['errors']}
    return event
Example #12
0
def test_list_struct():
    l_item = container.ListItem()
    l_item.list_string = ['foo', 'bar'] * 100
    l_item.list_list_string = [['foo', 'bar']] * 100

    l_struct = container.ListStruct()
    l_struct.list_items = [l_item] * 100

    b = serialize(l_struct)
    l_struct2 = deserialize(container.ListStruct(), b)
    assert l_struct == l_struct2
Example #13
0
def decode(n, proto_factory=TBinaryProtocolFactory()):
    ab = make_addressbook()
    encoded = serialize(ab)
    for i in range(n):
        deserialize(ab, encoded, proto_factory)
Example #14
0
def decode(n, proto_factory=TBinaryProtocolFactory()):
    ab = make_addressbook()
    encoded = serialize(ab)
    for i in range(n):
        deserialize(ab, encoded, proto_factory)