org.vertexium.query.Query.limit()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(13.3k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.vertexium.query.Query.limit方法的一些代码示例,展示了Query.limit的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.limit方法的具体详情如下:
包路径:org.vertexium.query.Query
类名称:Query
方法名:limit

Query.limit介绍

[英]Limits the number of items returned. null will return all elements.
[中]限制返回的项目数。null将返回所有元素。

代码示例

代码示例来源:origin: org.visallo/visallo-model-vertexium

@Override
public Iterable<User> find(int skip, int limit) {
  QueryResultsIterable<Vertex> userVertices = graph.query(authorizations)
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), userConceptId)
      .skip(skip)
      .limit(limit)
      .vertices();
  return new ConvertingIterable<Vertex, User>(userVertices) {
    @Override
    protected User convert(Vertex vertex) {
      return createFromVertex(vertex);
    }
  };
}

代码示例来源:origin: org.visallo/visallo-model-vertexium

@Override
public Iterable<User> findByStatus(int skip, int limit, UserStatus status) {
  QueryResultsIterable<Vertex> userVertices = graph.query(authorizations)
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), userConceptId)
      .has(UserVisalloProperties.STATUS.getPropertyName(), status.toString())
      .skip(skip)
      .limit(limit)
      .vertices();
  return new ConvertingIterable<Vertex, User>(userVertices) {
    @Override
    protected User convert(Vertex vertex) {
      return createFromVertex(vertex);
    }
  };
}

代码示例来源:origin: org.visallo/visallo-core

public JSONObject getAverages(int minutes, Graph graph, Authorizations authorizations) {
  Date minutesAgo = new Date(System.currentTimeMillis() - minutes * 60 * 1000);
  Query q = graph.query(authorizations)
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), PingOntology.IRI_CONCEPT_PING)
      .has(PingOntology.CREATE_DATE.getPropertyName(), Compare.GREATER_THAN, minutesAgo)
      .limit(0);
  q.addAggregation(new StatisticsAggregation(PingOntology.SEARCH_TIME_MS.getPropertyName(), PingOntology.SEARCH_TIME_MS.getPropertyName()));
  q.addAggregation(new StatisticsAggregation(PingOntology.RETRIEVAL_TIME_MS.getPropertyName(), PingOntology.RETRIEVAL_TIME_MS.getPropertyName()));
  q.addAggregation(new StatisticsAggregation(PingOntology.GRAPH_PROPERTY_WORKER_WAIT_TIME_MS.getPropertyName(), PingOntology.GRAPH_PROPERTY_WORKER_WAIT_TIME_MS.getPropertyName()));
  q.addAggregation(new StatisticsAggregation(PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.getPropertyName(), PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.getPropertyName()));
  QueryResultsIterable<Vertex> vertices = q.vertices();
  StatisticsResult searchTimeAgg = vertices.getAggregationResult(PingOntology.SEARCH_TIME_MS.getPropertyName(), StatisticsResult.class);
  StatisticsResult retrievalTimeAgg = vertices.getAggregationResult(PingOntology.RETRIEVAL_TIME_MS.getPropertyName(), StatisticsResult.class);
  StatisticsResult gpwWaitTimeAgg = vertices.getAggregationResult(PingOntology.GRAPH_PROPERTY_WORKER_WAIT_TIME_MS.getPropertyName(), StatisticsResult.class);
  StatisticsResult lrpWaitTimeAgg = vertices.getAggregationResult(PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.getPropertyName(), StatisticsResult.class);
  JSONObject json = new JSONObject();
  json.put("pingCount", searchTimeAgg.getCount());
  json.put("averageSearchTime", searchTimeAgg.getAverage());
  json.put("averageRetrievalTime", retrievalTimeAgg.getAverage());
  json.put("graphPropertyWorkerCount", gpwWaitTimeAgg.getCount());
  json.put("averageGraphPropertyWorkerWaitTime", gpwWaitTimeAgg.getAverage());
  json.put("longRunningProcessCount", lrpWaitTimeAgg.getCount());
  json.put("averageLongRunningProcessWaitTime", lrpWaitTimeAgg.getAverage());
  return json;
}

代码示例来源:origin: visallo/vertexium

@Test
public void testVertexQueryWithNestedTermsAggregationOnExtendedData() {
  graph.defineProperty("name").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH, TextIndexHint.FULL_TEXT).define();
  graph.defineProperty("gender").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH).define();
  graph.prepareVertex("v1", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r1", "name", "Joe", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r1", "gender", "male", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r2", "name", "Sam", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r2", "gender", "male", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r3", "name", "Sam", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r3", "gender", "female", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r4", "name", "Sam", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r4", "gender", "female", VISIBILITY_EMPTY)
      .save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B);
  Query q = v1.getExtendedData("t1").query(AUTHORIZATIONS_A_AND_B).limit(0);
  TermsAggregation agg = new TermsAggregation("terms-count", "name");
  agg.addNestedAggregation(new TermsAggregation("nested", "gender"));
  assumeTrue("terms aggregation not supported", q.isAggregationSupported(agg));
  q.addAggregation(agg);
  TermsResult aggregationResult = q.extendedDataRows().getAggregationResult("terms-count", TermsResult.class);
  Map<Object, Map<Object, Long>> vertexPropertyCountByValue = nestedTermsBucketToMap(aggregationResult.getBuckets(), "nested");
  assertEquals(2, vertexPropertyCountByValue.size());
  assertEquals(1, vertexPropertyCountByValue.get("Joe").size());
  assertEquals(1L, (long) vertexPropertyCountByValue.get("Joe").get("male"));
  assertEquals(2, vertexPropertyCountByValue.get("Sam").size());
  assertEquals(1L, (long) vertexPropertyCountByValue.get("Sam").get("male"));
  assertEquals(2L, (long) vertexPropertyCountByValue.get("Sam").get("female"));
}

代码示例来源:origin: org.vertexium/vertexium-test

@Test
public void testVertexQueryWithNestedTermsAggregationOnExtendedData() {
  graph.defineProperty("name").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH, TextIndexHint.FULL_TEXT).define();
  graph.defineProperty("gender").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH).define();
  graph.prepareVertex("v1", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r1", "name", "Joe", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r1", "gender", "male", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r2", "name", "Sam", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r2", "gender", "male", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r3", "name", "Sam", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r3", "gender", "female", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r4", "name", "Sam", VISIBILITY_EMPTY)
      .addExtendedData("t1", "r4", "gender", "female", VISIBILITY_EMPTY)
      .save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B);
  Query q = v1.getExtendedData("t1").query(AUTHORIZATIONS_A_AND_B).limit(0);
  TermsAggregation agg = new TermsAggregation("terms-count", "name");
  agg.addNestedAggregation(new TermsAggregation("nested", "gender"));
  assumeTrue("terms aggregation not supported", q.isAggregationSupported(agg));
  q.addAggregation(agg);
  TermsResult aggregationResult = q.extendedDataRows().getAggregationResult("terms-count", TermsResult.class);
  Map<Object, Map<Object, Long>> vertexPropertyCountByValue = nestedTermsBucketToMap(aggregationResult.getBuckets(), "nested");
  assertEquals(2, vertexPropertyCountByValue.size());
  assertEquals(1, vertexPropertyCountByValue.get("Joe").size());
  assertEquals(1L, (long) vertexPropertyCountByValue.get("Joe").get("male"));
  assertEquals(2, vertexPropertyCountByValue.get("Sam").size());
  assertEquals(1L, (long) vertexPropertyCountByValue.get("Sam").get("male"));
  assertEquals(2L, (long) vertexPropertyCountByValue.get("Sam").get("female"));
}

代码示例来源:origin: visallo/vertexium

.limit(0L);
rows = q.extendedDataRows();
aggResult = termsBucketToMap(rows.getAggregationResult("agg", TermsResult.class).getBuckets());
    .limit(0L);
rows = q.extendedDataRows();
aggResult = termsBucketToMap(rows.getAggregationResult("agg", TermsResult.class).getBuckets());
    .limit(0L);
rows = q.extendedDataRows();
aggResult = termsBucketToMap(rows.getAggregationResult("agg", TermsResult.class).getBuckets());

代码示例来源:origin: org.vertexium/vertexium-test

.limit(0L);
rows = q.extendedDataRows();
aggResult = termsBucketToMap(rows.getAggregationResult("agg", TermsResult.class).getBuckets());
    .limit(0L);
rows = q.extendedDataRows();
aggResult = termsBucketToMap(rows.getAggregationResult("agg", TermsResult.class).getBuckets());
    .limit(0L);
rows = q.extendedDataRows();
aggResult = termsBucketToMap(rows.getAggregationResult("agg", TermsResult.class).getBuckets());

代码示例来源:origin: org.visallo/visallo-core

@Override
public QueryResultsIterableSearchResults run(
    SearchOptions searchOptions,
    User user,
    Authorizations authorizations
) {
  JSONArray filterJson = getFilterJson(searchOptions, searchOptions.getWorkspaceId());
  QueryAndData queryAndData = getQuery(searchOptions, authorizations);
  applyFiltersToQuery(queryAndData, filterJson, user, searchOptions);
  applyConceptTypeFilterToQuery(queryAndData, searchOptions);
  applyEdgeLabelFilterToQuery(queryAndData, searchOptions);
  applySortToQuery(queryAndData, searchOptions);
  applyAggregationsToQuery(queryAndData, searchOptions);
  applyExtendedDataFilters(queryAndData, searchOptions);
  EnumSet<FetchHint> fetchHints = getFetchHints(searchOptions);
  Long size = searchOptions.getOptionalParameter("size", defaultSearchResultCount);
  if (size != null) {
    queryAndData.getQuery().limit(size);
  }
  Long offset = searchOptions.getOptionalParameter("offset", 0L);
  if (offset != null) {
    queryAndData.getQuery().skip(offset.intValue());
  }
  QueryResultsIterable<? extends VertexiumObject> searchResults = getSearchResults(queryAndData, fetchHints);
  return new QueryResultsIterableSearchResults(searchResults, queryAndData, offset, size);
}

代码示例来源:origin: visallo/vertexium

.sort(Element.ID_PROPERTY_NAME, SortDirection.ASCENDING)
    .skip(0)
    .limit(1)
    .vertexIds();
assertIdsAnyOrder(idsIterable, "v1");
    .sort(Element.ID_PROPERTY_NAME, SortDirection.ASCENDING)
    .skip(1)
    .limit(1)
    .vertexIds();
assertIdsAnyOrder(idsIterable, "v2");
    .sort(Element.ID_PROPERTY_NAME, SortDirection.ASCENDING)
    .skip(2)
    .limit(1)
    .vertexIds();
assertIdsAnyOrder(idsIterable, "v3");
    .sort(namePropertyName, SortDirection.ASCENDING)
    .skip(0)
    .limit(1)
    .vertices());
assertEquals(1, vertices.size());

代码示例来源:origin: org.vertexium/vertexium-test

.sort(Element.ID_PROPERTY_NAME, SortDirection.ASCENDING)
    .skip(0)
    .limit(1)
    .vertexIds();
assertIdsAnyOrder(idsIterable, "v1");
    .sort(Element.ID_PROPERTY_NAME, SortDirection.ASCENDING)
    .skip(1)
    .limit(1)
    .vertexIds();
assertIdsAnyOrder(idsIterable, "v2");
    .sort(Element.ID_PROPERTY_NAME, SortDirection.ASCENDING)
    .skip(2)
    .limit(1)
    .vertexIds();
assertIdsAnyOrder(idsIterable, "v3");
    .sort(namePropertyName, SortDirection.ASCENDING)
    .skip(0)
    .limit(1)
    .vertices());
assertEquals(1, vertices.size());

代码示例来源:origin: org.visallo/visallo-web

.limit(size)
.edges();

代码示例来源:origin: org.vertexium/vertexium-test

QueryResultsIterable<Vertex> results = graph.query(AUTHORIZATIONS_ALL)
    .addAggregation(agg)
    .limit(0)
    .vertices();

代码示例来源:origin: visallo/vertexium

QueryResultsIterable<Vertex> results = graph.query(AUTHORIZATIONS_ALL)
    .addAggregation(agg)
    .limit(0)
    .vertices();

代码示例来源:origin: org.vertexium/vertexium-test

.limit(0)
.vertices();
.limit(0)
.vertices();
.limit(0)
.vertices();
.limit(0)
.vertices();
.limit(0)
.vertices();
.limit(0)
.vertices();

代码示例来源:origin: visallo/vertexium

.limit(0)
.vertices();
.limit(0)
.vertices();
.limit(0)
.vertices();
.limit(0)
.vertices();
.limit(0)
.vertices();
.limit(0)
.vertices();

代码示例来源:origin: org.vertexium/vertexium-test

assertResultsCount(1, 3, idsIterable);
idsIterable = graph.query(AUTHORIZATIONS_A).skip(1).limit(1).vertexIds();
assertResultsCount(1, 3, idsIterable);
assertResultsCount(0, 3, idsIterable);
idsIterable = graph.query(AUTHORIZATIONS_A).skip(2).limit(2).vertexIds();
assertResultsCount(1, 3, idsIterable);

代码示例来源:origin: visallo/vertexium

assertResultsCount(1, 3, idsIterable);
idsIterable = graph.query(AUTHORIZATIONS_A).skip(1).limit(1).vertexIds();
assertResultsCount(1, 3, idsIterable);
assertResultsCount(0, 3, idsIterable);
idsIterable = graph.query(AUTHORIZATIONS_A).skip(2).limit(2).vertexIds();
assertResultsCount(1, 3, idsIterable);

代码示例来源:origin: org.vertexium/vertexium-test

assertResultsCount(1, 2, vertices);
vertices = graph.query(AUTHORIZATIONS_A).skip(1).limit(1).vertices();
assertResultsCount(1, 2, vertices);
assertResultsCount(0, 2, vertices);
vertices = graph.query(AUTHORIZATIONS_A).skip(1).limit(2).vertices();
assertResultsCount(1, 2, vertices);

代码示例来源:origin: visallo/vertexium

assertResultsCount(1, 2, vertices);
vertices = graph.query(AUTHORIZATIONS_A).skip(1).limit(1).vertices();
assertResultsCount(1, 2, vertices);
assertResultsCount(0, 2, vertices);
vertices = graph.query(AUTHORIZATIONS_A).skip(1).limit(2).vertices();
assertResultsCount(1, 2, vertices);

相关文章