Search in sources :

Example 16 with BackendColumn

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

the class TableBackendEntryTest method testNotImplemented.

@Test
public void testNotImplemented() {
    TableBackendEntry entry = new TableBackendEntry(HugeType.VERTEX);
    BackendColumn col = BackendColumn.of(new byte[] { 1 }, new byte[] { 12 });
    Assert.assertThrows(NotImplementedException.class, () -> {
        entry.columnsSize();
    });
    Assert.assertThrows(NotImplementedException.class, () -> {
        entry.columns();
    });
    Assert.assertThrows(NotImplementedException.class, () -> {
        entry.columns(ImmutableList.of(col));
    });
    Assert.assertThrows(NotImplementedException.class, () -> {
        entry.columns(col);
    });
    Assert.assertThrows(NotImplementedException.class, () -> {
        entry.merge(entry);
    });
    Assert.assertThrows(NotImplementedException.class, () -> {
        entry.clear();
    });
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) TableBackendEntry(com.baidu.hugegraph.backend.serializer.TableBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 17 with BackendColumn

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

the class RocksDBSessionTest method testScanByRangeWithBytes.

@Test
public void testScanByRangeWithBytes() throws RocksDBException {
    Session session = this.rocks.session();
    byte[] key11 = new byte[] { 1, 1 };
    byte[] value11 = getBytes("value-1-1");
    session.put(TABLE, key11, value11);
    byte[] key12 = new byte[] { 1, 2 };
    byte[] value12 = getBytes("value-1-2");
    session.put(TABLE, key12, value12);
    byte[] key21 = new byte[] { 2, 1 };
    byte[] value21 = getBytes("value-2-1");
    session.put(TABLE, key21, value21);
    byte[] key22 = new byte[] { 2, 2 };
    byte[] value22 = getBytes("value-2-2");
    session.put(TABLE, key22, value22);
    byte[] key23 = new byte[] { 2, 3 };
    byte[] value23 = getBytes("value-2-3");
    session.put(TABLE, key23, value23);
    this.commit();
    Map<ByteBuffer, byte[]> results = new HashMap<>();
    Iterator<BackendColumn> iter = session.scan(TABLE, new byte[] { 1, 0 }, new byte[] { 2, 3 });
    while (iter.hasNext()) {
        BackendColumn col = iter.next();
        results.put(ByteBuffer.wrap(col.name), col.value);
    }
    Assert.assertEquals(4, results.size());
    Assert.assertArrayEquals(value11, results.get(ByteBuffer.wrap(key11)));
    Assert.assertArrayEquals(value12, results.get(ByteBuffer.wrap(key12)));
    Assert.assertArrayEquals(value21, results.get(ByteBuffer.wrap(key21)));
    Assert.assertArrayEquals(value22, results.get(ByteBuffer.wrap(key22)));
    Assert.assertArrayEquals(value23, session.get(TABLE, key23));
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) HashMap(java.util.HashMap) ByteBuffer(java.nio.ByteBuffer) Session(com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 18 with BackendColumn

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

the class BinaryBackendEntryTest method testClear.

@Test
public void testClear() {
    BinaryBackendEntry entry = new BinaryBackendEntry(HugeType.VERTEX, new byte[] { 1, 2 });
    BackendColumn col = BackendColumn.of(new byte[] { 1, 2 }, new byte[] { 3, 4 });
    entry.column(col);
    Assert.assertEquals(1, entry.columnsSize());
    Assert.assertEquals(ImmutableList.of(col), entry.columns());
    entry.clear();
    Assert.assertEquals(0, entry.columnsSize());
    Assert.assertEquals(ImmutableList.of(), entry.columns());
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 19 with BackendColumn

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

the class RocksDBPerfTest method testSeekNonExistKey.

@Test
public void testSeekNonExistKey() throws RocksDBException {
    put("exist", "value");
    Session session = this.rocks.session();
    for (int i = 0; i < TIMES; i++) {
        Iterator<BackendColumn> iter = session.scan(TABLE, getBytes("non-exist"));
        while (iter.hasNext()) {
            iter.next();
        }
    }
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) Session(com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session) Test(org.junit.Test)

Example 20 with BackendColumn

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

the class RocksDBPerfTest method testSeekExistKey.

@Test
public void testSeekExistKey() throws RocksDBException {
    put("exist", "value");
    Session session = this.rocks.session();
    for (int i = 0; i < TIMES; i++) {
        Iterator<BackendColumn> iter = session.scan(TABLE, getBytes("exist"));
        while (iter.hasNext()) {
            iter.next();
        }
    }
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) Session(com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session) Test(org.junit.Test)

Aggregations

BackendColumn (com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn)21 Test (org.junit.Test)15 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)11 Session (com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions.Session)9 BinaryBackendEntry (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry)5 HashMap (java.util.HashMap)5 Id (com.baidu.hugegraph.backend.id.Id)4 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)3 BinaryId (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry.BinaryId)3 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)2 ByteBuffer (java.nio.ByteBuffer)2 BytesBuffer (com.baidu.hugegraph.backend.serializer.BytesBuffer)1 TableBackendEntry (com.baidu.hugegraph.backend.serializer.TableBackendEntry)1 TextBackendEntry (com.baidu.hugegraph.backend.serializer.TextBackendEntry)1 BackendAction (com.baidu.hugegraph.backend.store.BackendAction)1 BackendEntry (com.baidu.hugegraph.backend.store.BackendEntry)1 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)1