use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class CassandraEntryIterator method fetch.
@Override
protected final boolean fetch() {
assert this.current == null;
if (this.next != null) {
this.current = this.next;
this.next = null;
}
while (this.expected > 0L && this.rows.hasNext()) {
// Limit expected count, due to rows.hasNext() will fetch next page
this.expected--;
Row row = this.rows.next();
if (this.query.paging()) {
// Update fetchdPageSize if auto fetch the next page
if (this.expected > 0L && this.availableLocal() == 0) {
if (this.rows.hasNext()) {
this.fetchdPageSize = this.availableLocal();
}
}
}
BackendEntry merged = this.merger.apply(this.current, row);
if (this.current == null) {
// The first time to read
this.current = merged;
} else if (merged == this.current) {
// The next entry belongs to the current entry
assert merged != null;
} else {
// New entry
assert this.next == null;
this.next = merged;
break;
}
}
return this.current != null;
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class RocksDBStore method mutate.
private void mutate(Session session, BackendAction item) {
BackendEntry entry = item.entry();
RocksDBTable table;
if (!entry.olap()) {
// Oltp table
table = this.table(entry.type());
} else {
if (entry.type().isIndex()) {
// Olap index
table = this.table(this.olapTableName(entry.type()));
} else {
// Olap vertex
table = this.table(this.olapTableName(entry.subId()));
}
session = this.session(HugeType.OLAP);
}
switch(item.action()) {
case INSERT:
table.insert(session, entry);
break;
case DELETE:
table.delete(session, entry);
break;
case APPEND:
table.append(session, entry);
break;
case ELIMINATE:
table.eliminate(session, entry);
break;
default:
throw new AssertionError(String.format("Unsupported mutate action: %s", item.action()));
}
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class BackendMutationTest method testDeleteAndInsertEntry.
@Test
public void testDeleteAndInsertEntry() {
BackendMutation mutation = new BackendMutation();
BackendEntry entry1 = constructBackendEntry("1");
BackendEntry entry2 = constructBackendEntry("2");
BackendEntry entry3 = constructBackendEntry("1");
mutation.add(entry1, Action.DELETE);
mutation.add(entry2, Action.DELETE);
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.DELETE, get(mutation, "2").get(0).action());
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class BackendMutationTest method testAppendAndDeleteEntry.
@Test
public void testAppendAndDeleteEntry() {
BackendMutation mutation = new BackendMutation();
BackendEntry entry1 = constructBackendEntry("1", "name", "marko");
BackendEntry entry2 = constructBackendEntry("1");
mutation.add(entry1, Action.APPEND);
mutation.add(entry2, Action.DELETE);
Assert.assertEquals(1, get(mutation, "1").size());
Assert.assertEquals(Action.DELETE, get(mutation, "1").get(0).action());
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class BackendMutationTest method testEliminateAndEliminateEntryWithSameId.
@Test
public void testEliminateAndEliminateEntryWithSameId() {
BackendMutation mutation = new BackendMutation();
BackendEntry entry1 = constructBackendEntry("1", "name", "marko");
BackendEntry entry2 = constructBackendEntry("1", "city", "Wuhan");
mutation.add(entry1, Action.ELIMINATE);
mutation.add(entry2, Action.ELIMINATE);
Assert.assertEquals(2, get(mutation, "1").size());
Assert.assertEquals(Action.ELIMINATE, get(mutation, "1").get(0).action());
Assert.assertEquals(Action.ELIMINATE, get(mutation, "1").get(1).action());
}
Aggregations