def tombs_c0_lc(kvdb: hse.Kvdb, kvs: hse.Kvs, cursor_sync: bool = False): with kvdb.transaction() as t: kvs.put(b"ab01", b"val-cn", txn=t) with kvdb.transaction() as t: kvs.put(b"ab02", b"val-lc", txn=t) kvdb.sync() with kvdb.transaction() as t: kvs.delete(b"ab02", txn=t) # Cursor with kvdb.transaction() as t: with kvs.cursor(filt=b"ab", txn=t) as c: if cursor_sync: kvdb.sync() # Point Get assert kvs.get(b"ab01", txn=t) == b"val-cn" assert kvs.get(b"ab02", txn=t) == None # Probe cnt, *kv = kvs.prefix_probe(b"ab0", txn=t) assert cnt == hse.KvsPfxProbeCnt.ONE assert kv == [b"ab01", b"val-cn"] # Read all keys assert c.read() == (b"ab01", b"val-cn") assert c.read() == (None, None) and c.eof == True # Seek, read c.seek(b"ab00") assert c.read() == (b"ab01", b"val-cn") c.seek(b"ab01") assert c.read() == (b"ab01", b"val-cn") c.seek(b"ab02") assert c.read() == (None, None) and c.eof == True # Read, update, read c.seek(b"ab01") ##c.update() assert c.read() == (b"ab01", b"val-cn") ##c.update() assert c.read() == (None, None) and c.eof == True # Seek, update, read c.seek(b"ab01") ##c.update() assert c.read() == (b"ab01", b"val-cn") c.seek(b"ab02") ##c.update() assert c.read() == (None, None) and c.eof == True
def tombs_lc_cn(kvdb: hse.Kvdb, kvs: hse.Kvs, cursor_sync: bool = False): with kvdb.transaction() as t: kvs.put(b"ab01", b"val-cn", txn=t) with kvdb.transaction() as t: kvs.delete(b"ab01", txn=t) kvdb.sync() with kvdb.transaction() as t: kvs.put(b"ab02", b"val-c0", txn=t) # Cursor with kvs.cursor(filt=b"ab") as c: if cursor_sync: kvdb.sync() # Point Get assert kvs.get(b"ab01")[0] == None assert kvs.get(b"ab02")[0] == b"val-c0" # Probe cnt, k, _, v, _ = kvs.prefix_probe(b"ab0") assert cnt == hse.KvsPfxProbeCnt.ONE assert (k, v) == (b"ab02", b"val-c0") # Read all keys assert c.read() == (b"ab02", b"val-c0") assert c.read() == (None, None) and c.eof == True # Seek, read c.seek(b"ab01") assert c.read() == (b"ab02", b"val-c0") c.seek(b"ab02") assert c.read() == (b"ab02", b"val-c0") # Read, update, read c.seek(b"ab01") c.update_view() assert c.read() == (b"ab02", b"val-c0") c.update_view() assert c.read() == (None, None) and c.eof == True # Seek, update, read c.seek(b"ab01") c.update_view() assert c.read() == (b"ab02", b"val-c0") c.seek(b"ab02") c.update_view() assert c.read() == (b"ab02", b"val-c0")
def tombs_c0_lc(kvdb: hse.Kvdb, kvs: hse.Kvs, cursor_sync: bool = False): with kvdb.transaction() as t: kvs.put(b"ab01", b"val-cn", txn=t) with kvdb.transaction() as t: kvs.put(b"ab02", b"val-lc", txn=t) kvdb.sync() with kvdb.transaction() as t: kvs.delete(b"ab02", txn=t) # Cursor with kvs.cursor(filt=b"ab", flags=hse.CursorFlag.REVERSE) as c: if cursor_sync: kvdb.sync() # Read all keys assert c.read() == (b"ab01", b"val-cn") assert c.read() == (None, None) and c.eof == True # Seek, read c.seek(b"ab02") assert c.read() == (b"ab01", b"val-cn") c.seek(b"ab01") assert c.read() == (b"ab01", b"val-cn") c.seek(b"ab00") assert c.read() == (None, None) and c.eof == True # Read, update, read c.seek(b"ab01") c.update_view() assert c.read() == (b"ab01", b"val-cn") c.update_view() assert c.read() == (None, None) and c.eof == True # Seek, update, read c.seek(b"ab01") c.update_view() assert c.read() == (b"ab01", b"val-cn") c.seek(b"ab00") c.update_view() assert c.read() == (None, None) and c.eof == True