use of com.baidu.hugegraph.backend.serializer.MergeIterator in project incubator-hugegraph by apache.
the class CassandraStore method query.
@Override
public Iterator<BackendEntry> query(Query query) {
this.checkOpened();
HugeType type = CassandraTable.tableType(query);
String tableName = query.olap() ? this.olapTableName(type) : type.string();
CassandraTable table = this.table(tableName);
Iterator<BackendEntry> entries = table.query(this.session(), query);
// Merge olap results as needed
Set<Id> olapPks = query.olapPks();
if (this.isGraphStore && !olapPks.isEmpty()) {
List<Iterator<BackendEntry>> iterators = new ArrayList<>();
for (Id pk : olapPks) {
Query q = query.copy();
table = this.table(this.olapTableName(pk));
iterators.add(table.query(this.session(), q));
}
entries = new MergeIterator<>(entries, iterators, BackendEntry::mergeable);
}
return entries;
}
use of com.baidu.hugegraph.backend.serializer.MergeIterator in project incubator-hugegraph by apache.
the class RocksDBStore method query.
@Override
public Iterator<BackendEntry> query(Query query) {
Lock readLock = this.storeLock.readLock();
readLock.lock();
try {
this.checkOpened();
HugeType tableType = RocksDBTable.tableType(query);
RocksDBTable table;
RocksDBSessions.Session session;
if (query.olap()) {
table = this.table(this.olapTableName(tableType));
session = this.session(HugeType.OLAP);
} else {
table = this.table(tableType);
session = this.session(tableType);
}
Iterator<BackendEntry> entries = table.query(session, query);
// Merge olap results as needed
Set<Id> olapPks = query.olapPks();
if (this.isGraphStore && !olapPks.isEmpty()) {
List<Iterator<BackendEntry>> iterators = new ArrayList<>();
for (Id pk : olapPks) {
Query q = query.copy();
table = this.table(this.olapTableName(pk));
iterators.add(table.query(this.session(HugeType.OLAP), q));
}
entries = new MergeIterator<>(entries, iterators, BackendEntry::mergeable);
}
return entries;
} finally {
readLock.unlock();
}
}
Aggregations