Search in sources :

Example 1 with BackendColumnIterator

use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumnIterator in project incubator-hugegraph by apache.

the class RocksDBPerfTest method testMultiGet3Keys.

@Test
public void testMultiGet3Keys() 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();
    BackendColumnIterator iter;
    for (int i = 0; i < TIMES; i++) {
        List<byte[]> keys = Arrays.asList(getBytes("person:1gname"), getBytes("person:1gage"), getBytes("person:1gcity"));
        iter = session.get(TABLE, keys);
        iter.next();
        iter.next();
        iter.next();
    }
}
Also used : BackendColumnIterator(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumnIterator) Session(com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session) Test(org.junit.Test)

Example 2 with BackendColumnIterator

use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumnIterator in project incubator-hugegraph by apache.

the class RocksDBSessionTest method testPutAndMultiGet.

@Test
public void testPutAndMultiGet() throws RocksDBException {
    BackendColumnIterator values = this.rocks.session().get(TABLE, Arrays.asList(getBytes("person:1gname")));
    Assert.assertFalse(values.hasNext());
    this.rocks.session().put(TABLE, getBytes("person:1gname"), getBytes("James"));
    this.rocks.session().put(TABLE, getBytes("person:1gage"), getBytes(19));
    this.rocks.session().put(TABLE, getBytes("person:1gcity"), getBytes("Beijing"));
    this.commit();
    values = this.rocks.session().get(TABLE, Arrays.asList(getBytes("person:1gname"), getBytes("person:1gage")));
    Assert.assertTrue(values.hasNext());
    Assert.assertEquals("James", getString(values.next().value));
    Assert.assertEquals(19, getLong(values.next().value));
    Assert.assertFalse(values.hasNext());
    values = this.rocks.session().get(TABLE, Arrays.asList(getBytes("person:1gname"), getBytes("person:1gage"), getBytes("person:1gcity")));
    Assert.assertTrue(values.hasNext());
    Assert.assertEquals("James", getString(values.next().value));
    Assert.assertEquals(19, getLong(values.next().value));
    Assert.assertEquals("Beijing", getString(values.next().value));
    Assert.assertFalse(values.hasNext());
    values = this.rocks.session().get(TABLE, Arrays.asList(getBytes("person:1gname"), getBytes("person:1gage-non-exist"), getBytes("person:1gcity")));
    Assert.assertTrue(values.hasNext());
    Assert.assertEquals("James", getString(values.next().value));
    Assert.assertEquals("Beijing", getString(values.next().value));
    Assert.assertFalse(values.hasNext());
    values = this.rocks.session().get(TABLE, Arrays.asList(getBytes("person:1gname"), getBytes("person:1gage-non-exist"), getBytes("person:1gcity"), getBytes("person:1gname")));
    Assert.assertTrue(values.hasNext());
    Assert.assertEquals("James", getString(values.next().value));
    Assert.assertEquals("Beijing", getString(values.next().value));
    Assert.assertEquals("James", getString(values.next().value));
    Assert.assertFalse(values.hasNext());
}
Also used : BackendColumnIterator(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumnIterator) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Aggregations

BackendColumnIterator (com.baidu.hugegraph.backend.store.BackendEntry.BackendColumnIterator)2 Test (org.junit.Test)2 Session (com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session)1 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)1