use of com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session in project incubator-hugegraph by apache.
the class RocksDBPerfTest method testGet3Keys.
@Test
public void testGet3Keys() throws RocksDBException {
put("person:1gname", "James");
put("person:1gage", "19");
put("person:1gcity", "Beijing");
put("person:2gname", "Lisa");
put("person:2gage", "20");
put("person:2gcity", "Beijing");
Session session = this.rocks.session();
for (int i = 0; i < TIMES; i++) {
session.get(TABLE, getBytes("person:1gname"));
session.get(TABLE, getBytes("person:1gage"));
session.get(TABLE, getBytes("person:1gcity"));
}
}
use of com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session in project incubator-hugegraph by apache.
the class RocksDBPerfTest method testGetNonExistKey.
@Test
public void testGetNonExistKey() throws RocksDBException {
put("exist", "value");
Session session = this.rocks.session();
for (int i = 0; i < TIMES; i++) {
byte[] value = session.get(TABLE, getBytes("non-exist"));
assert value == null;
}
}
use of com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session in project incubator-hugegraph by apache.
the class RocksDBPerfTest method testGetExistKey.
@Test
public void testGetExistKey() throws RocksDBException {
put("exist", "value");
Session session = this.rocks.session();
for (int i = 0; i < TIMES; i++) {
byte[] value = session.get(TABLE, getBytes("exist"));
assert value.length == "value".length();
}
}
use of com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session in project incubator-hugegraph by apache.
the class RocksDBPerfTest method testUpdate.
@Test
public void testUpdate() throws RocksDBException {
Session session = this.rocks.session();
Random r = new Random();
Map<Integer, Integer> comms = new HashMap<>();
byte[] empty = new byte[0];
int n = 1000;
for (int i = 0; i < n; i++) {
int value = i;
comms.put(i, value);
String key = String.format("index:%3d:%d", i, value);
session.put(TABLE, getBytes(key), empty);
}
session.commit();
// 30w
int updateTimes = 300;
for (int j = 0; j < updateTimes; j++) {
for (int i = 0; i < n; i++) {
int value = comms.get(i);
String old = String.format("index:%3d:%d", i, value);
session.delete(TABLE, getBytes(old));
// TODO: aggregate
value = r.nextInt(n);
value = i + 1;
comms.put(i, value);
String key = String.format("index:%3d:%d", i, value);
session.put(TABLE, getBytes(key), empty);
}
session.commit();
}
}
use of com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session in project incubator-hugegraph by apache.
the class RocksDBPerfTest method testScanByPrefix.
@Test
public void testScanByPrefix() throws RocksDBException {
put("person:1gname", "James");
put("person:1gage", "19");
put("person:1gcity", "Beijing");
put("person:2gname", "Lisa");
put("person:2gage", "20");
put("person:2gcity", "Beijing");
Session session = this.rocks.session();
for (int i = 0; i < TIMES; i++) {
Iterator<BackendColumn> iter = session.scan(TABLE, getBytes("person:1"));
while (iter.hasNext()) {
iter.next();
}
}
}
Aggregations