本文整理了Java中com.baidu.hugegraph.backend.query.Query.empty
方法的一些代码示例,展示了Query.empty
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.empty
方法的具体详情如下:
包路径:com.baidu.hugegraph.backend.query.Query
类名称:Query
方法名:empty
暂无
代码示例来源:origin: hugegraph/hugegraph
@Override
protected Iterator<HugeEdge> queryEdgesFromBackend(Query query) {
if (query.empty()) {
// Query all edges, don't cache it
return super.queryEdgesFromBackend(query);
}
Id id = new QueryId(query);
@SuppressWarnings("unchecked")
List<HugeEdge> edges = (List<HugeEdge>) this.edgesCache.get(id);
if (edges == null) {
// Iterator can't be cached, caching list instead
edges = ImmutableList.copyOf(super.queryEdgesFromBackend(query));
if (edges.size() <= MAX_CACHE_EDGES_PER_QUERY) {
this.edgesCache.update(id, edges);
}
}
return edges.iterator();
}
代码示例来源:origin: hugegraph/hugegraph
@Watched(prefix = "tx")
public Iterator<BackendEntry> query(Query query) {
LOG.debug("Transaction query: {}", query);
/*
* NOTE: it's dangerous if an IdQuery/ConditionQuery is empty
* check if the query is empty and its class is not the Query itself
*/
if (query.empty() && !query.getClass().equals(Query.class)) {
throw new BackendException("Query without any id or condition");
}
query = this.serializer.writeQuery(query);
this.beforeRead();
try {
return this.store.query(query);
} finally {
this.afterRead(); // TODO: not complete the iteration currently
}
}
代码示例来源:origin: hugegraph/hugegraph
@SuppressWarnings("unchecked")
@Override
public Iterator<BackendEntry> query(Query query) {
if (query.empty()) {
return this.store.query(query);
}
QueryId id = new QueryId(query);
Object result = this.cache.get(id);
if (result != null) {
return (Iterator<BackendEntry>) result;
} else {
Iterator<BackendEntry> rs = this.store.query(query);
if (rs.hasNext()) {
this.cache.update(id, rs);
}
return rs;
}
}
代码示例来源:origin: hugegraph/hugegraph
} else if (!q.empty()) {
代码示例来源:origin: hugegraph/hugegraph
if (query.empty()) {
return newEntryIterator(this.queryAll(session, query), query);
代码示例来源:origin: hugegraph/hugegraph
if (query.empty()) {
return newEntryIterator(this.queryAll(session, query), query);
代码示例来源:origin: com.baidu.hugegraph/hugegraph-core
@Override
protected Iterator<HugeEdge> queryEdgesFromBackend(Query query) {
if (query.empty()) {
// Query all edges, don't cache it
return super.queryEdgesFromBackend(query);
}
Id id = new QueryId(query);
@SuppressWarnings("unchecked")
List<HugeEdge> edges = (List<HugeEdge>) this.edgesCache.get(id);
if (edges == null) {
// Iterator can't be cached, caching list instead
edges = ImmutableList.copyOf(super.queryEdgesFromBackend(query));
if (edges.size() <= MAX_CACHE_EDGES_PER_QUERY) {
this.edgesCache.update(id, edges);
}
}
return edges.iterator();
}
代码示例来源:origin: com.baidu.hugegraph/hugegraph-core
@Watched(prefix = "tx")
public Iterator<BackendEntry> query(Query query) {
LOG.debug("Transaction query: {}", query);
/*
* NOTE: it's dangerous if an IdQuery/ConditionQuery is empty
* check if the query is empty and its class is not the Query itself
*/
if (query.empty() && !query.getClass().equals(Query.class)) {
throw new BackendException("Query without any id or condition");
}
query = this.serializer.writeQuery(query);
this.beforeRead();
try {
return this.store.query(query);
} finally {
this.afterRead(); // TODO: not complete the iteration currently
}
}
代码示例来源:origin: com.baidu.hugegraph/hugegraph-core
@SuppressWarnings("unchecked")
@Override
public Iterator<BackendEntry> query(Query query) {
if (query.empty()) {
return this.store.query(query);
}
QueryId id = new QueryId(query);
Object result = this.cache.get(id);
if (result != null) {
return (Iterator<BackendEntry>) result;
} else {
Iterator<BackendEntry> rs = this.store.query(query);
if (rs.hasNext()) {
this.cache.update(id, rs);
}
return rs;
}
}
代码示例来源:origin: com.baidu.hugegraph/hugegraph-core
@Override
public Iterator<BackendEntry> query(Query query) {
if (!(query instanceof ConditionQuery)) {
return super.query(query);
}
List<Query> queries = new ArrayList<>();
for (ConditionQuery cq: ConditionQueryFlatten.flatten(
(ConditionQuery) query)) {
Query q = this.optimizeQuery(cq);
/*
* NOTE: There are two possibilities for this query:
* 1.sysprop-query, which would not be empty.
* 2.index-query result(ids after optimization), which may be empty.
*/
if (!q.empty()) {
// Return empty if there is no result after index-query
queries.add(q);
}
}
ExtendableIterator<BackendEntry> rs = new ExtendableIterator<>();
for (Query q : queries) {
rs.extend(super.query(q));
}
return rs;
}
代码示例来源:origin: com.baidu.hugegraph/hugegraph-rocksdb
@Override
public Iterator<BackendEntry> query(Session session, Query query) {
if (query.limit() == 0 && query.limit() != Query.NO_LIMIT) {
LOG.debug("Return empty result(limit=0) for query {}", query);
return ImmutableList.<BackendEntry>of().iterator();
}
// Query all
if (query.empty()) {
return newEntryIterator(this.queryAll(session, query), query);
}
// Query by id
if (query.conditions().isEmpty()) {
assert !query.ids().isEmpty();
ExtendableIterator<BackendEntry> rs = new ExtendableIterator<>();
for (Id id : query.ids()) {
rs.extend(newEntryIterator(this.queryById(session, id), query));
}
return rs;
}
// Query by condition (or condition + id)
ConditionQuery cq = (ConditionQuery) query;
return newEntryIterator(this.queryByCond(session, cq), query);
}
内容来源于网络,如有侵权,请联系作者删除!