Search in sources :

Example 11 with BackendEntry

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

the class BackendMutationTest method testEliminateAndInsertEntry.

@Test
public void testEliminateAndInsertEntry() {
    BackendMutation mutation = new BackendMutation();
    BackendEntry entry1 = constructBackendEntry("1");
    BackendEntry entry2 = constructBackendEntry("1", "name", "marko");
    mutation.add(entry1, Action.ELIMINATE);
    mutation.add(entry2, Action.INSERT);
    Assert.assertEquals(1, get(mutation, "1").size());
    Assert.assertEquals(Action.INSERT, get(mutation, "1").get(0).action());
}
Also used : BackendMutation(com.baidu.hugegraph.backend.store.BackendMutation) BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) TextBackendEntry(com.baidu.hugegraph.backend.serializer.TextBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 12 with BackendEntry

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

the class BackendMutationTest method testInsertAndInsertEntry.

@Test
public void testInsertAndInsertEntry() {
    BackendMutation mutation = new BackendMutation();
    BackendEntry entry1 = constructBackendEntry("1");
    BackendEntry entry2 = constructBackendEntry("2");
    BackendEntry entry3 = constructBackendEntry("1");
    mutation.add(entry1, Action.INSERT);
    mutation.add(entry2, Action.INSERT);
    mutation.add(entry3, Action.INSERT);
    Assert.assertEquals(1, get(mutation, "1").size());
    Assert.assertEquals(Action.INSERT, get(mutation, "1").get(0).action());
    Assert.assertEquals(1, get(mutation, "2").size());
    Assert.assertEquals(Action.INSERT, get(mutation, "2").get(0).action());
}
Also used : BackendMutation(com.baidu.hugegraph.backend.store.BackendMutation) BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) TextBackendEntry(com.baidu.hugegraph.backend.serializer.TextBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 13 with BackendEntry

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

the class BackendMutationTest method testInsertAndEliminateEntry.

@Test
public void testInsertAndEliminateEntry() {
    BackendMutation mutation = new BackendMutation();
    BackendEntry entry1 = constructBackendEntry("1", "name", "marko");
    BackendEntry entry2 = constructBackendEntry("1", "name", "marko");
    mutation.add(entry1, Action.INSERT);
    Assert.assertThrows(HugeException.class, () -> {
        mutation.add(entry2, Action.ELIMINATE);
    });
}
Also used : BackendMutation(com.baidu.hugegraph.backend.store.BackendMutation) BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) TextBackendEntry(com.baidu.hugegraph.backend.serializer.TextBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 14 with BackendEntry

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

the class BackendMutationTest method testInsertAndDeleteEntry.

@Test
public void testInsertAndDeleteEntry() {
    BackendMutation mutation = new BackendMutation();
    BackendEntry entry1 = constructBackendEntry("1");
    BackendEntry entry2 = constructBackendEntry("1");
    mutation.add(entry1, Action.INSERT);
    Assert.assertThrows(HugeException.class, () -> {
        mutation.add(entry2, Action.DELETE);
    });
}
Also used : BackendMutation(com.baidu.hugegraph.backend.store.BackendMutation) BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) TextBackendEntry(com.baidu.hugegraph.backend.serializer.TextBackendEntry) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 15 with BackendEntry

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

the class CassandraStore method query.

@Override
public Iterator<BackendEntry> query(Query query) {
    this.checkOpened();
    HugeType type = CassandraTable.tableType(query);
    String tableName = query.olap() ? this.olapTableName(type) : type.string();
    CassandraTable table = this.table(tableName);
    Iterator<BackendEntry> entries = table.query(this.session(), query);
    // Merge olap results as needed
    Set<Id> olapPks = query.olapPks();
    if (this.isGraphStore && !olapPks.isEmpty()) {
        List<Iterator<BackendEntry>> iterators = new ArrayList<>();
        for (Id pk : olapPks) {
            Query q = query.copy();
            table = this.table(this.olapTableName(pk));
            iterators.add(table.query(this.session(), q));
        }
        entries = new MergeIterator<>(entries, iterators, BackendEntry::mergeable);
    }
    return entries;
}
Also used : BackendEntry(com.baidu.hugegraph.backend.store.BackendEntry) Query(com.baidu.hugegraph.backend.query.Query) Iterator(java.util.Iterator) MergeIterator(com.baidu.hugegraph.backend.serializer.MergeIterator) ArrayList(java.util.ArrayList) Id(com.baidu.hugegraph.backend.id.Id) HugeType(com.baidu.hugegraph.type.HugeType)

Aggregations

BackendEntry (com.baidu.hugegraph.backend.store.BackendEntry)54 Test (org.junit.Test)27 TextBackendEntry (com.baidu.hugegraph.backend.serializer.TextBackendEntry)26 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)26 BackendMutation (com.baidu.hugegraph.backend.store.BackendMutation)21 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)7 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)7 Id (com.baidu.hugegraph.backend.id.Id)6 FakeObjects (com.baidu.hugegraph.unit.FakeObjects)6 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)5 BinaryBackendEntry (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry)5 HugeIndex (com.baidu.hugegraph.structure.HugeIndex)5 Query (com.baidu.hugegraph.backend.query.Query)4 BinarySerializer (com.baidu.hugegraph.backend.serializer.BinarySerializer)4 HugeConfig (com.baidu.hugegraph.config.HugeConfig)4 ArrayList (java.util.ArrayList)4 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)3 LockUtil (com.baidu.hugegraph.util.LockUtil)3 BackendException (com.baidu.hugegraph.backend.BackendException)2 Condition (com.baidu.hugegraph.backend.query.Condition)2