use of com.baidu.hugegraph.type.HugeType in project incubator-hugegraph by apache.
the class RocksDBStore method mutate.
@Override
public void mutate(BackendMutation mutation) {
Lock readLock = this.storeLock.readLock();
readLock.lock();
try {
this.checkOpened();
if (LOG.isDebugEnabled()) {
LOG.debug("Store {} mutation: {}", this.store, mutation);
}
for (HugeType type : mutation.types()) {
Session session = this.session(type);
for (Iterator<BackendAction> it = mutation.mutation(type); it.hasNext(); ) {
this.mutate(session, it.next());
}
}
} finally {
readLock.unlock();
}
}
use of com.baidu.hugegraph.type.HugeType 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.type.HugeType in project incubator-hugegraph by apache.
the class BinarySerializer method writeIndex.
@Override
public BackendEntry writeIndex(HugeIndex index) {
BinaryBackendEntry entry;
if (index.fieldValues() == null && index.elementIds().size() == 0) {
/*
* When field-values is null and elementIds size is 0, it is
* meaningful for deletion of index data by index label.
* TODO: improve
*/
entry = this.formatILDeletion(index);
} else {
Id id = index.id();
HugeType type = index.type();
byte[] value = null;
if (!type.isNumericIndex() && indexIdLengthExceedLimit(id)) {
id = index.hashId();
// Save field-values as column value if the key is a hash string
value = StringEncoding.encode(index.fieldValues().toString());
}
entry = newBackendEntry(type, id);
if (index.indexLabel().olap()) {
entry.olap(true);
}
entry.column(this.formatIndexName(index), value);
entry.subId(index.elementId());
if (index.hasTtl()) {
entry.ttl(index.ttl());
}
}
return entry;
}
use of com.baidu.hugegraph.type.HugeType in project incubator-hugegraph by apache.
the class TraversalUtil method fillConditionQuery.
public static ConditionQuery fillConditionQuery(ConditionQuery query, List<HasContainer> hasContainers, HugeGraph graph) {
HugeType resultType = query.resultType();
for (HasContainer has : hasContainers) {
Condition condition = convHas2Condition(has, resultType, graph);
query.query(condition);
}
return query;
}
use of com.baidu.hugegraph.type.HugeType 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;
});
}
Aggregations