Search in sources :

Example 1 with BackendColumn

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);
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn)

Example 2 with BackendColumn

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;
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) BinaryId(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry.BinaryId) Id(com.baidu.hugegraph.backend.id.Id) EdgeId(com.baidu.hugegraph.backend.id.EdgeId) HugeVertex(com.baidu.hugegraph.structure.HugeVertex)

Example 3 with BackendColumn

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;
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) BinaryId(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry.BinaryId) Id(com.baidu.hugegraph.backend.id.Id) EdgeId(com.baidu.hugegraph.backend.id.EdgeId)

Example 4 with BackendColumn

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);
    }
}
Also used : BackendColumn(com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn) BinaryId(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry.BinaryId) Id(com.baidu.hugegraph.backend.id.Id) EdgeId(com.baidu.hugegraph.backend.id.EdgeId)

Example 5 with BackendColumn

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();
        }
    }
}
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