示例#1
0
def test():
    assert_equal(None, hbase_util.get_col('test', 'row1', 'fam1', 'col1'))
    assert_true(hbase_util.put_col('test', 'row1', 'fam1', 'col1', 'content1'))
    assert_equal({'fam1:col1': 'content1'},
                 hbase_util.get_col('test', 'row1', 'fam1', 'col1'))
    assert_true(hbase_util.delete('test', 'row1'))
    assert_equal(None, hbase_util.get_col('test', 'row1', 'fam1', 'col1'))
    assert_true(hbase_util.delete('test', 'row1'))

    assert_true(hbase_util.put_cols('test', 'row1',  \
        [('fam1', 'col1', 'content1'), ('fam2', 'col2', 'content2')]))
    assert_equal({'fam1:col1': 'content1'},
                 hbase_util.get_col('test', 'row1', 'fam1', 'col1'))
    assert_equal({'fam2:col2': 'content2'},
                 hbase_util.get_col('test', 'row1', 'fam2', 'col2'))
示例#2
0
def get_batch_list(track_id, tpid, tpe, seq, image_type):
    table = get_table_name()
    #row = '%s-%s_%s_%s_%s' % (track_id, tpid, tpe, seq, image_type)
    row = rowkey.gen_v2(track_id, tpid, tpe, seq, image_type)
    ret = hbase_util.get_col(table, row, 'meta', 'batch_list')
    if ret:
        assert ret.keys() == ['meta:batch_list']
        return ret['meta:batch_list']
    else:
        return None
示例#3
0
def image_exist(track_id, tpid, tpe, seq, image_type, batch=''):
    row_key = rowkey.gen(track_id, tpid, tpe, seq, image_type)
    logger().info('row_key[%s], batch[%s]', row_key, batch)
    if not batch:
        last_batch = batch_manager.get_last_batch(track_id, tpid, tpe, seq,
                                                  image_type)
        return last_batch != None
    else:
        if tpe == '00' and seq == '004':
            return False
        else:
            table = get_table_name()
            ret = hbase_util.get_col(table, row_key, 'content', batch)
            return not not ret
示例#4
0
def image_get(track_id, tpid, tpe, seq, image_type, batch=None):
    #row_key = '%s-%s_%s_%s_%s' % (track_id, tpid, tpe, seq, image_type)
    row_key = rowkey.gen(track_id, tpid, tpe, seq, image_type)
    if not batch:
        batch = batch_manager.get_last_batch(track_id, tpid, tpe, seq,
                                             image_type)
        if not batch:
            logger().error('get empty batch for row_key[%s]', row_key)
            return None

    table = get_table_name()
    logger().debug('row [%s], batch[%s]', row_key, batch)
    ret = hbase_util.get_col(table, row_key, 'content', batch)
    if ret:
        return ret['content:' + batch]
    return None
示例#5
0
 def get(self, key):
     rowkey = self.gen_rowkey(key)
     val = hbase_util.get_col(self.table, rowkey, 'data', 'data')
     return val