本文整理了Java中com.baidu.hugegraph.backend.query.Query.resultType
方法的一些代码示例,展示了Query.resultType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.resultType
方法的具体详情如下:
包路径:com.baidu.hugegraph.backend.query.Query
类名称:Query
方法名:resultType
暂无
代码示例来源:origin: hugegraph/hugegraph
public IdRangeQuery(Query originQuery,
Id start, boolean inclusiveStart,
Id end, boolean inclusiveEnd) {
this(originQuery.resultType(), originQuery,
start, inclusiveStart, end, inclusiveEnd);
}
代码示例来源:origin: hugegraph/hugegraph
public IdPrefixQuery(Query originQuery, Id prefix) {
this(originQuery.resultType(), originQuery, prefix, true, prefix);
}
代码示例来源:origin: hugegraph/hugegraph
public IdPrefixQuery(Query originQuery,
Id start, boolean inclusive, Id prefix) {
this(originQuery.resultType(), originQuery, start, inclusive, prefix);
}
代码示例来源:origin: hugegraph/hugegraph
public IdQuery(Query originQuery, Set<Id> ids) {
this(originQuery.resultType(), originQuery);
this.query(ids);
}
代码示例来源:origin: hugegraph/hugegraph
public IdQuery(Query originQuery, Id id) {
this(originQuery.resultType(), originQuery);
this.query(id);
}
代码示例来源:origin: hugegraph/hugegraph
private MysqlBackendEntry row2Entry(ResultSet result) throws SQLException {
HugeType type = this.query.resultType();
MysqlBackendEntry entry = new MysqlBackendEntry(type);
ResultSetMetaData metaData = result.getMetaData();
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String name = metaData.getColumnLabel(i);
Object value = result.getObject(i);
entry.column(MysqlTable.parseKey(name), value);
}
return entry;
}
代码示例来源:origin: hugegraph/hugegraph
protected Iterator<BackendEntry> results2Entries(Query q, ResultSet r) {
return new CassandraEntryIterator(r, q, (e1, row) -> {
CassandraBackendEntry e2 = row2Entry(q.resultType(), row);
return this.mergeEntries(e1, e2);
});
}
代码示例来源:origin: hugegraph/hugegraph
private Iterator<?> joinTxVertices(Query query,
Iterator<HugeVertex> vertices) {
assert query.resultType().isVertex();
return this.joinTxRecords(query, vertices,
(q, v) -> q.test(v) ? v : null,
this.addedVertexes, this.removedVertexes,
this.updatedVertexes);
}
代码示例来源:origin: hugegraph/hugegraph
protected Iterator<HugeEdge> queryEdgesFromBackend(Query query) {
assert query.resultType().isEdge();
Iterator<BackendEntry> entries = this.query(query);
return new FlatMapperIterator<>(entries, entry -> {
// Edges are in a vertex
HugeVertex vertex = this.serializer.readVertex(graph(), entry);
assert vertex != null;
if (query.ids().size() == 1) {
assert vertex.getEdges().size() == 1;
}
// Copy to avoid ConcurrentModificationException when removing edge
return ImmutableList.copyOf(vertex.getEdges()).iterator();
});
}
代码示例来源:origin: hugegraph/hugegraph
private Iterator<?> joinTxEdges(Query query, Iterator<HugeEdge> edges,
Map<Id, HugeVertex> removingVertexes) {
assert query.resultType().isEdge();
final BiFunction<Query, HugeEdge, HugeEdge> matchTxEdges = (q, e) -> {
assert q.resultType() == HugeType.EDGE;
return q.test(e) ? e : q.test(e = e.switchOwner()) ? e : null;
};
edges = this.joinTxRecords(query, edges, matchTxEdges,
this.addedEdges, this.removedEdges,
this.updatedEdges);
if (removingVertexes.isEmpty()) {
return edges;
}
// Filter edges that belong to deleted vertex
return new FilterIterator<HugeEdge>(edges, edge -> {
for (HugeVertex v : removingVertexes.values()) {
if (edge.belongToVertex(v)) {
return false;
}
}
return true;
});
}
代码示例来源:origin: hugegraph/hugegraph
/**
* Mapping query-type to table-type
* @param query origin query
* @return corresponding table type
*/
public static HugeType tableType(Query query) {
HugeType type = query.resultType();
// Mapping EDGE to EDGE_OUT/EDGE_IN
if (type == HugeType.EDGE) {
// We assume query OUT edges
type = HugeType.EDGE_OUT;
while (!(query instanceof ConditionQuery ||
query.originQuery() == null)) {
/*
* Some backends(like RocksDB) may trans ConditionQuery to
* IdQuery or IdPrefixQuery, so we should get the origin query.
*/
query = query.originQuery();
}
if (!query.conditions().isEmpty() &&
query instanceof ConditionQuery) {
ConditionQuery cq = (ConditionQuery) query;
// Does query IN edges
if (cq.condition(HugeKeys.DIRECTION) == Directions.IN) {
type = HugeType.EDGE_IN;
}
}
}
return type;
}
代码示例来源:origin: hugegraph/hugegraph
protected Iterator<HugeVertex> queryVerticesFromBackend(Query query) {
assert query.resultType().isVertex();
Iterator<BackendEntry> entries = this.query(query);
return new MapperIterator<>(entries, entry -> {
HugeVertex vertex = this.serializer.readVertex(graph(), entry);
assert vertex != null;
return vertex;
});
}
代码示例来源:origin: hugegraph/hugegraph
protected static BackendEntryIterator newEntryIterator(
BackendColumnIterator cols,
Query query) {
return new BinaryEntryIterator<BackendColumn>(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);
}
entry.columns(col);
return entry;
});
}
代码示例来源:origin: hugegraph/hugegraph
IdQuery ids = new IdQuery(query.resultType(), query);
for (ConditionQuery cq: ConditionQueryFlatten.flatten(
(ConditionQuery) query)) {
代码示例来源:origin: hugegraph/hugegraph
@Override
public Query writeQuery(Query query) {
HugeType type = query.resultType();
代码示例来源:origin: hugegraph/hugegraph
@Override
protected Query writeQueryCondition(Query query) {
HugeType type = query.resultType();
if (!type.isIndex()) {
return query;
}
ConditionQuery cq = (ConditionQuery) query;
// Convert secondary-index or search-index query to id query
if (type.isStringIndex()) {
return this.writeStringIndexQuery(cq);
}
// Convert range-index query to id range query
if (type.isRangeIndex()) {
return this.writeRangeIndexQuery(cq);
}
E.checkState(false, "Unsupported index query: %s", type);
return null;
}
代码示例来源:origin: hugegraph/hugegraph
@Override
protected Query writeQueryCondition(Query query) {
if (query.resultType().isGraph()) {
ConditionQuery result = (ConditionQuery) query;
// No user-prop when serialize
assert result.allSysprop();
for (Condition.Relation r : result.relations()) {
if (r.relation() == Condition.RelationType.CONTAINS) {
r.serialValue(JsonUtil.toJson(r.value()));
}
}
}
return query;
}
代码示例来源:origin: hugegraph/hugegraph
private BackendEntryIterator newEntryIterator(RowIterator rows,
Query query) {
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);
}
try {
this.parseRowColumns(row, entry, query);
} catch (IOException e) {
throw new BackendException("Failed to read HBase columns", e);
}
return entry;
});
}
代码示例来源:origin: hugegraph/hugegraph
public Iterator<Vertex> queryVertices(Query query) {
Iterator<HugeVertex> results = this.queryVerticesFromBackend(query);
// Filter unused or incorrect records
results = new FilterIterator<>(results, vertex -> {
assert vertex.schemaLabel() != VertexLabel.NONE;
// Filter hidden results
if (!query.showHidden() && Graph.Hidden.isHidden(vertex.label())) {
return false;
}
// Process results that query from left index or primary-key
if (query.resultType().isVertex() &&
!filterResultFromIndexQuery(query, vertex)) {
// Only index query will come here
return false;
}
return true;
});
@SuppressWarnings("unchecked")
Iterator<Vertex> r = (Iterator<Vertex>) joinTxVertices(query, results);
return r;
}
代码示例来源:origin: hugegraph/hugegraph
@Override
protected Query writeQueryCondition(Query query) {
ConditionQuery result = (ConditionQuery) query;
// No user-prop when serialize
assert result.allSysprop();
for (Condition.Relation r : result.relations()) {
// Serialize key
if (query.resultType().isSchema()) {
r.serialKey(((HugeKeys) r.key()).string());
} else {
r.serialKey(formatSyspropName((HugeKeys) r.key()));
}
if (r.value() instanceof Id) {
// Serialize id value
r.serialValue(writeId((Id) r.value()));
} else {
// Serialize other type value
r.serialValue(JsonUtil.toJson(r.value()));
}
if (r.relation() == Condition.RelationType.CONTAINS_KEY) {
// Serialize has-key
String key = (String) r.serialValue();
r.serialValue(formatPropertyName(key));
}
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!