Exemplo n.º 1
0
 def testRocksdbAdapterGetMapValues(self):
     rocksdb_adapter = RocksdbSortedKvAdapter(
         options={"path": leveldbMapvaluesPath})
     for i in range(10):
         print("value of key:{} is: {}".format(
             i, rocksdb_adapter.get(bytes(str(i), encoding='utf8'))))
     rocksdb_adapter.close()
Exemplo n.º 2
0
  def test_check_result(self):
    input_adapter = RocksdbSortedKvAdapter(options={'path': TestIo.result_path})
    iterator = input_adapter.iteritems()

    print("path:", TestIo.result_path)

    for k, v in iterator:
      print(k, v)
Exemplo n.º 3
0
  def test_write_batch(self):
    path_prefix = TestIo._name_prefix
    for p in range(4):
      adapter = RocksdbSortedKvAdapter(options={'path': f'{path_prefix}/{p}'})

      writebatch = adapter.new_batch()

      for i in range(10):
        target = str(i).encode()
        writebatch.put(b'k' + target, b'v' + target)

      writebatch.close()
      adapter.close()
Exemplo n.º 4
0
 def testRocksdbAdapterPut(self):
     rocksdb_adapter = RocksdbSortedKvAdapter(options={"path": leveldbPath})
     for i in range(10):
         rocksdb_adapter.put(bytes(str(i), encoding='utf8'),
                             bytes("a", encoding='utf8'))
     print("finish put")
     for i in range(10):
         print("value of key:{} is: {}".format(
             i, rocksdb_adapter.get(bytes(str(i), encoding='utf8'))))
     #must call close, otherwise will not put sucessfully
     rocksdb_adapter.close()
Exemplo n.º 5
0
 def testRocksdbIterator(self):
     rocksdb_adapter = RocksdbSortedKvAdapter(options={"path": leveldbPath})
     rocksdb_iterator = rocksdb_adapter.iteritems()
     for k, v in rocksdb_iterator:
         print("iterate table of key:{} value: {}".format(k, v))
     rocksdb_adapter.close()