Search in sources :

Example 1 with BinaryEntryIterator

use of com.baidu.hugegraph.backend.serializer.BinaryEntryIterator in project incubator-hugegraph by apache.

the class HbaseTable method newEntryIterator.

protected BackendEntryIterator newEntryIterator(Query query, RowIterator rows) {
    return new BinaryEntryIterator<>(rows, query, (entry, row) -> {
        E.checkState(!row.isEmpty(), "Can't parse empty HBase result");
        byte[] id = row.getRow();
        if (entry == null || !Bytes.prefixWith(id, entry.id().asBytes())) {
            HugeType type = query.resultType();
            // NOTE: only support BinaryBackendEntry currently
            entry = new BinaryBackendEntry(type, id, this.enablePartition);
        }
        try {
            this.parseRowColumns(row, entry, query, this.enablePartition);
        } catch (IOException e) {
            throw new BackendException("Failed to read HBase columns", e);
        }
        return entry;
    });
}
Also used : BinaryEntryIterator(com.baidu.hugegraph.backend.serializer.BinaryEntryIterator) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) IOException(java.io.IOException) HugeType(com.baidu.hugegraph.type.HugeType) BackendException(com.baidu.hugegraph.backend.BackendException)

Example 2 with BinaryEntryIterator

use of com.baidu.hugegraph.backend.serializer.BinaryEntryIterator in project incubator-hugegraph by apache.

the class RocksDBTable method newEntryIterator.

protected static final BackendEntryIterator newEntryIterator(BackendColumnIterator cols, Query query) {
    return new BinaryEntryIterator<>(cols, query, (entry, col) -> {
        if (entry == null || !entry.belongToMe(col)) {
            HugeType type = query.resultType();
            // NOTE: only support BinaryBackendEntry currently
            entry = new BinaryBackendEntry(type, col.name);
        } else {
            assert !Bytes.equals(entry.id().asBytes(), col.name);
        }
        entry.columns(col);
        return entry;
    });
}
Also used : BinaryEntryIterator(com.baidu.hugegraph.backend.serializer.BinaryEntryIterator) BinaryBackendEntry(com.baidu.hugegraph.backend.serializer.BinaryBackendEntry) HugeType(com.baidu.hugegraph.type.HugeType)

Aggregations

BinaryBackendEntry (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry)2 BinaryEntryIterator (com.baidu.hugegraph.backend.serializer.BinaryEntryIterator)2 HugeType (com.baidu.hugegraph.type.HugeType)2 BackendException (com.baidu.hugegraph.backend.BackendException)1 IOException (java.io.IOException)1