コード例 #1
0
#!/usr/bin/env python

import sys
import time
from hypertable.thrift_client.thriftclient import ThriftClient
from hypertable.thrift_client.hyperthrift.gen.ttypes import *

if len(sys.argv) < 2:
    print (sys.argv[0], "<hql>")
    sys.exit(1)

try:
    client = ThriftClient("localhost", 15867)

    namespace = client.open_namespace("/")

    res = client.hql_query(namespace, sys.argv[1])

    print ([res.results, res.cells, res.scanner, res.mutator])

    client.close_namespace(namespace)

except ClientException, e:
    print ('%s' % e.message)
コード例 #2
0
#!/usr/bin/env python

import sys
import time
from hypertable.thrift_client.thriftclient import ThriftClient
from hypertable.thrift_client.hyperthrift.gen.ttypes import *

if len(sys.argv) < 4:
    print (sys.argv[0], "<table> <row-key> <column>")
    sys.exit(1)

try:
    client = ThriftClient("localhost", 15867)

    namespace = client.namespace_open("/")

    mutator = client.mutator_open(namespace, sys.argv[1], 0, 0)

    client.mutator_set_cell(mutator, Cell(Key(sys.argv[2], sys.argv[3], None), "thrift_insert.py"))
    client.mutator_flush(mutator)

    client.close_namespace(namespace)

except ClientException, e:
    print ('%s' % e.message)
コード例 #3
0
ファイル: client_test.py プロジェクト: thither/hypertable
import sys
import time
from hypertable.thrift_client.thriftclient import ThriftClient
from hypertable.thrift_client.hyperthrift.gen.ttypes import *

try:
    client = ThriftClient('localhost', 15867)
    print ('HQL examples')

    try:
        namespace = client.namespace_open('bad')
    except:
        print ('Caught exception when trying to open "bad" namespace')

    try:
        client.create_namespace('test')
    except:
        pass
    namespace = client.namespace_open('test')
    client.hql_query(namespace, 'drop table if exists thrift_test')
    client.hql_query(namespace, 'create table thrift_test (col)')

    res = client.hql_query(namespace, 'show tables')
    print (res)
    res = client.hql_query(namespace, 'select * from thrift_test')
    print (res)

    print ('mutator examples')
    mutator = client.mutator_open(namespace, str('thrift_test'), 0, 0)
    print ('mutator examples mutator_set_cell')
    client.mutator_set_cell(mutator, Cell(Key('py-k1', 'col', None), b'py-v1'))
コード例 #4
0
import random
import sys
import time
from hypertable.thrift_client.thriftclient import ThriftClient
from hypertable.thrift_client.hyperthrift.gen.ttypes import *

if (len(sys.argv) < 3):
    print sys.argv[0], "<max-keys>", "<limit>"
    sys.exit(1)

max_keys = int(sys.argv[1])
limit = int(sys.argv[2])

try:
    client = ThriftClient("localhost", 15867)

    ns = client.open_namespace("/")

    end_row = "%05d~" % (max_keys)

    for n in range(1, max_keys):

        start_row = "%05d" % (n)
        row_intervals = [RowInterval(start_row, True, end_row, True)]
        ss = ScanSpec(row_intervals=row_intervals, row_limit=limit)

        cells = client.get_cells(ns, "LoadTest", ss)

        if len(cells) != limit:
            print "Limit query starting at '%s' returned %d rows (expected %d)" % (
コード例 #5
0
#!/usr/bin/env python

import random
import sys
import time
from hypertable.thrift_client.thriftclient import ThriftClient
from hypertable.thrift_client.hyperthrift.gen.ttypes import *

if (len(sys.argv) < 2):
    print sys.argv[0], "<source-location>"
    sys.exit(1)

source = sys.argv[1]

try:
    client = ThriftClient("localhost", 15867)

    namespace = client.open_namespace("/sys")

    scanner = client.open_scanner(
        namespace, "METADATA",
        ScanSpec(None, None, None, 1, 0, None, None, ["StartRow", "Location"]))

    ranges = []
    cur = {}

    while True:
        cells = client.next_cells(scanner)
        if (len(cells) == 0):
            break
        for cell in cells:
コード例 #6
0
#!/usr/bin/env python

import sys
import time
from hypertable.thrift_client.thriftclient import ThriftClient
from hypertable.thrift_client.hyperthrift.gen.ttypes import *

if len(sys.argv) < 2:
    print(sys.argv[0], "<table>")
    sys.exit(1)

try:
    client = ThriftClient("localhost", 15867)

    namespace = client.open_namespace("/")

    scanner = client.open_scanner(namespace, sys.argv[1],
                                  ScanSpec(None, None, None, 1))

    while True:
        cells = client.next_cells(scanner)
        if len(cells) == 0:
            break
        for cell in cells:
            print('%s %s %s' %
                  (cell.key.row, cell.key.column_family, cell.value))

    client.close_namespace(namespace)

except ClientException, e:
    print('%s' % e.message)
コード例 #7
0
# -- coding: utf-8 --

from hypertable.thrift_client.thriftclient import ThriftClient
from hypertable.thrift_client.serialized_cells import Writer

print("SerializedCellsWriter Test")

num_cells = 1000000
value_multi = 10
test_input = []
output_test = []

client = ThriftClient("localhost", 15867)
try:
    client.create_namespace("test")
except:
    pass
namespace = client.namespace_open("test")
client.hql_query(namespace, "drop table if exists thrift_test")
client.hql_query(namespace, "create table thrift_test (col)")

# write with SerializedCellsWriter
scw = Writer(32896, True)
s_sz = 0
for i in range(0, num_cells):
    i = str(i)
    v = i * value_multi
    scw.add("row" + i, "col", 'qly' + i, 0, v, len(v), 255)
    test_input.append(('row' + i + '_' + 'col:' + 'qly' + i + '_' + v))
    s_sz += len(test_input[-1])
print('est scw sz: ' + str(s_sz))
コード例 #8
0
ファイル: populate.py プロジェクト: thither/hypertable
profound oblivion. No one would have dared to mention them; no one would
have dared to recall them.

M. Myriel had arrived at D---- accompanied by an elderly spinster,
Mademoiselle Baptistine, who was his sister, and ten years his junior.
"""

if len(sys.argv) < 2:
    print(sys.argv[0], "<amount-to-write>")
    sys.exit(1)

try:
    random.seed(1)
    story = story.replace("\n", " ")

    client = ThriftClient("localhost", 15867)

    namespace = client.namespace_open("/")

    mutator = client.mutator_open(namespace, "LargeRowTest", 0, 0)

    iterations = int(sys.argv[1]) / len(story)

    for x in range(0, iterations):
        cutoff = random.randint(0, len(story))
        story_cut = story[cutoff:] + story[:cutoff]
        client.mutator_set_cell(mutator,
                                Cell(Key(story_cut, "c", None), "dummy"))

    client.mutator_flush(mutator)
コード例 #9
0
ファイル: client_test_scr.py プロジェクト: thither/hypertable
# -- coding: utf-8 --

from hypertable.thrift_client.thriftclient import ThriftClient
from hypertable.thrift_client.serialized_cells import Reader, Writer
from hypertable.thrift_client.hyperthrift.gen.ttypes import *
print("SerializedCellsReader Test")

num_cells = 100
value_multi = 200
test_input = []
output_test = []

client = ThriftClient("localhost", 15867)
try:
    client.create_namespace("test")
except:
    pass
namespace = client.namespace_open("test")
client.hql_query(namespace, "drop table if exists thrift_test")
client.hql_query(namespace, "create table thrift_test (col MAX_VERSIONS 1)")

# write with SerializedCellsWriter
#scw = Writer(32896, True)
#s_sz = 0
#for i in range(0, num_cells):
#    i = str(i)
#    v = i*value_multi
#    scw.add("row"+i, "col", 'qly'+i, 0, v, len(v), 255)
#    test_input.append(('row'+i+'_'+'col:'+'qly'+i+'_'+v).encode())
#    s_sz += len(test_input[-1])
#print ('est scw sz: '+str(s_sz))