use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn in project incubator-hugegraph by apache.
the class RocksDBTable method getById.
protected BackendColumnIterator getById(Session session, Id id) {
byte[] value = session.get(this.table(), id.asBytes());
if (value == null) {
return BackendColumnIterator.empty();
}
BackendColumn col = BackendColumn.of(id.asBytes(), value);
return BackendColumnIterator.iterator(col);
}
use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn in project incubator-hugegraph by apache.
the class BinarySerializer method readVertex.
@Override
public HugeVertex readVertex(HugeGraph graph, BackendEntry bytesEntry) {
if (bytesEntry == null) {
return null;
}
BinaryBackendEntry entry = this.convertEntry(bytesEntry);
// Parse id
Id id = entry.id().origin();
Id vid = id.edge() ? ((EdgeId) id).ownerVertexId() : id;
HugeVertex vertex = new HugeVertex(graph, vid, VertexLabel.NONE);
// Parse all properties and edges of a Vertex
Iterator<BackendColumn> iterator = entry.columns().iterator();
for (int index = 0; iterator.hasNext(); index++) {
BackendColumn col = iterator.next();
if (entry.type().isEdge()) {
// NOTE: the entry id type is vertex even if entry type is edge
// Parse vertex edges
this.parseColumn(col, vertex);
} else {
assert entry.type().isVertex();
// Parse vertex properties
assert entry.columnsSize() >= 1 : entry.columnsSize();
if (index == 0) {
this.parseVertex(col.value, vertex);
} else {
this.parseVertexOlap(col.value, vertex);
}
}
}
return vertex;
}
use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn in project incubator-hugegraph by apache.
the class BinarySerializer method formatLabel.
protected BackendColumn formatLabel(HugeElement elem) {
BackendColumn col = new BackendColumn();
col.name = this.formatSyspropName(elem.id(), HugeKeys.LABEL);
Id label = elem.schemaLabel().id();
BytesBuffer buffer = BytesBuffer.allocate(label.length() + 1);
col.value = buffer.writeId(label).bytes();
return col;
}
use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn in project incubator-hugegraph by apache.
the class BinarySerializer method parseIndexName.
protected void parseIndexName(HugeGraph graph, ConditionQuery query, BinaryBackendEntry entry, HugeIndex index, Object fieldValues) {
for (BackendColumn col : entry.columns()) {
if (indexFieldValuesUnmatched(col.value, fieldValues)) {
// Skip if field-values is not matched (just the same hash)
continue;
}
BytesBuffer buffer = BytesBuffer.wrap(col.name);
if (this.indexWithIdPrefix) {
buffer.readIndexId(index.type());
}
Id elemId = buffer.readId();
long expiredTime = index.hasTtl() ? buffer.readVLong() : 0L;
index.elementIds(elemId, expiredTime);
}
}
use of com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn in project incubator-hugegraph by apache.
the class RocksDBPerfTest method testScanByPrefix.
@Test
public void testScanByPrefix() 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();
for (int i = 0; i < TIMES; i++) {
Iterator<BackendColumn> iter = session.scan(TABLE, getBytes("person:1"));
while (iter.hasNext()) {
iter.next();
}
}
}
Aggregations