use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class HbaseStore method mutate.
private void mutate(Session session, BackendAction item) {
BackendEntry entry = item.entry();
HbaseTable table = this.table(entry.type());
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 MysqlEntryIterator method fetch.
@Override
protected final boolean fetch() {
assert this.current == null;
if (this.next != null) {
this.current = this.next;
this.next = null;
}
try {
while (this.results.next()) {
MysqlBackendEntry entry = this.row2Entry(this.results.resultSet());
this.lastest = entry;
BackendEntry merged = this.merger.apply(this.current, entry);
if (this.current == null) {
// The first time to read
this.current = merged;
} else if (merged == this.current) {
// Does the next entry belongs to the current entry
assert merged != null;
} else {
// New entry
assert this.next == null;
this.next = merged;
break;
}
// When limit exceed, stop fetching
if (this.reachLimit(this.fetched() - 1)) {
this.exceedLimit = true;
// Need remove last one because fetched limit + 1 records
this.removeLastRecord();
this.results.close();
break;
}
}
} catch (SQLException e) {
throw new BackendException("Fetch next error", e);
}
return this.current != null;
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class StoreDumper method dump.
public void dump(HugeType table, long offset, long limit) {
BackendStore store = this.backendStore(table);
Query query = new Query(table);
Iterator<BackendEntry> rs = store.query(query);
for (long i = 0; i < offset && rs.hasNext(); i++) {
rs.next();
}
LOG.info("Dump table {} (offset {} limit {}):", table, offset, limit);
for (long i = 0; i < limit && rs.hasNext(); i++) {
BackendEntry entry = rs.next();
LOG.info("{}", entry);
}
CloseableIterator.closeIterator(rs);
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class BinaryScatterSerializerTest method parse.
private static BackendEntry parse(BackendEntry originEntry) {
byte[] bytes = originEntry.id().asBytes();
BackendEntry parsedEntry = new BinaryBackendEntry(originEntry.type(), bytes);
parsedEntry.columns(originEntry.columns());
return parsedEntry;
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class BinaryScatterSerializerTest method testVertex.
@Test
public void testVertex() {
HugeConfig config = FakeObjects.newConfig();
BinaryScatterSerializer ser = new BinaryScatterSerializer(config);
HugeEdge edge = new FakeObjects().newEdge(123, 456);
BackendEntry entry1 = ser.writeVertex(edge.sourceVertex());
HugeVertex vertex1 = ser.readVertex(edge.graph(), entry1);
Assert.assertEquals(edge.sourceVertex(), vertex1);
assertCollectionEquals(edge.sourceVertex().getProperties(), vertex1.getProperties());
BackendEntry entry2 = ser.writeVertex(edge.targetVertex());
HugeVertex vertex2 = ser.readVertex(edge.graph(), entry2);
Assert.assertEquals(edge.targetVertex(), vertex2);
assertCollectionEquals(edge.targetVertex().getProperties(), vertex2.getProperties());
Whitebox.setInternalState(vertex2, "removed", true);
Assert.assertTrue(vertex2.removed());
BackendEntry entry3 = ser.writeVertex(vertex2);
Assert.assertEquals(0, entry3.columnsSize());
Assert.assertNull(ser.readVertex(edge.graph(), null));
}
Aggregations