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

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

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

Query.vertices介绍

暂无

代码示例

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

public String search(Graph graph, Authorizations authorizations) {
  Query query = graph.query(authorizations).limit(1);
  List<Vertex> vertices = Lists.newArrayList(query.vertices());
  if (vertices.size() == 0) {
    throw new VisalloException("query returned no vertices");
  } else if (vertices.size() > 1) {
    throw new VisalloException("query returned more than one vertex");
  }
  return vertices.get(0).getId();
}

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

private Vertex findExistingVertexWithHash(String hash, Authorizations authorizations) {
  Iterator<Vertex> existingVertices = this.graph.query(authorizations)
      .has(VisalloProperties.CONTENT_HASH.getPropertyName(), hash)
      .vertices()
      .iterator();
  if (existingVertices.hasNext()) {
    return existingVertices.next();
  }
  return null;
}

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

private StatisticsResult queryGraphQueryWithStatisticsAggregation(String propertyName, Authorizations authorizations) {
  Query q = graph.query(authorizations).limit(0);
  StatisticsAggregation agg = new StatisticsAggregation("stats", propertyName);
  if (!q.isAggregationSupported(agg)) {
    LOGGER.warn("%s unsupported", StatisticsAggregation.class.getName());
    return null;
  }
  q.addAggregation(agg);
  return q.vertices().getAggregationResult("stats", StatisticsResult.class);
}

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

private CardinalityResult queryGraphQueryWithCardinalityAggregation(String propertyName, Authorizations authorizations) {
  Query q = graph.query(authorizations).limit(0);
  CardinalityAggregation agg = new CardinalityAggregation("card", propertyName);
  if (!q.isAggregationSupported(agg)) {
    LOGGER.warn("%s unsupported", CardinalityAggregation.class.getName());
    return null;
  }
  q.addAggregation(agg);
  return q.vertices().getAggregationResult("card", CardinalityResult.class);
}

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

private CardinalityResult queryGraphQueryWithCardinalityAggregation(String propertyName, Authorizations authorizations) {
  Query q = graph.query(authorizations).limit(0);
  CardinalityAggregation agg = new CardinalityAggregation("card", propertyName);
  if (!q.isAggregationSupported(agg)) {
    LOGGER.warn("%s unsupported", CardinalityAggregation.class.getName());
    return null;
  }
  q.addAggregation(agg);
  return q.vertices().getAggregationResult("card", CardinalityResult.class);
}

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

@Override
public Iterable<Vertex> getVertices(final String key, final Object value) {
  final Authorizations authorizations = getAuthorizationsProvider().getAuthorizations();
  return new ConvertingIterable<org.vertexium.Vertex, Vertex>(getGraph().query(authorizations).has(key, Compare.EQUAL, value).vertices(getFetchHints())) {
    @Override
    protected Vertex convert(org.vertexium.Vertex vertex) {
      return VertexiumBlueprintsVertex.create(VertexiumBlueprintsGraph.this, vertex, authorizations);
    }
  };
}

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

private Map<Object, Long> queryGraphQueryWithTermsAggregation(String queryString, String propertyName, ElementType elementType, Authorizations authorizations) {
  Query q = (queryString == null ? graph.query(authorizations) : graph.query(queryString, authorizations)).limit(0);
  TermsAggregation agg = new TermsAggregation("terms-count", propertyName);
  if (!q.isAggregationSupported(agg)) {
    LOGGER.warn("%s unsupported", agg.getClass().getName());
    return null;
  }
  q.addAggregation(agg);
  QueryResultsIterable<? extends Element> elements = elementType == ElementType.VERTEX ? q.vertices() : q.edges();
  TermsResult aggregationResult = elements.getAggregationResult("terms-count", TermsResult.class);
  return termsBucketToMap(aggregationResult.getBuckets());
}

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

private Map<Object, Long> queryGraphQueryWithTermsAggregation(String queryString, String propertyName, ElementType elementType, Authorizations authorizations) {
  Query q = (queryString == null ? graph.query(authorizations) : graph.query(queryString, authorizations)).limit(0);
  TermsAggregation agg = new TermsAggregation("terms-count", propertyName);
  if (!q.isAggregationSupported(agg)) {
    LOGGER.warn("%s unsupported", agg.getClass().getName());
    return null;
  }
  q.addAggregation(agg);
  QueryResultsIterable<? extends Element> elements = elementType == ElementType.VERTEX ? q.vertices() : q.edges();
  TermsResult aggregationResult = elements.getAggregationResult("terms-count", TermsResult.class);
  return termsBucketToMap(aggregationResult.getBuckets());
}

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

private Map<String, Long> queryGraphQueryWithGeohashAggregation(String propertyName, int precision, Authorizations authorizations) {
  Query q = graph.query(authorizations).limit(0);
  GeohashAggregation agg = new GeohashAggregation("geo-count", propertyName, precision);
  if (!q.isAggregationSupported(agg)) {
    LOGGER.warn("%s unsupported", GeohashAggregation.class.getName());
    return null;
  }
  q.addAggregation(agg);
  return geoHashBucketToMap(q.vertices().getAggregationResult("geo-count", GeohashResult.class).getBuckets());
}

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

private Map<String, Long> queryGraphQueryWithGeohashAggregation(String propertyName, int precision, Authorizations authorizations) {
  Query q = graph.query(authorizations).limit(0);
  GeohashAggregation agg = new GeohashAggregation("geo-count", propertyName, precision);
  if (!q.isAggregationSupported(agg)) {
    LOGGER.warn("%s unsupported", GeohashAggregation.class.getName());
    return null;
  }
  q.addAggregation(agg);
  return geoHashBucketToMap(q.vertices().getAggregationResult("geo-count", GeohashResult.class).getBuckets());
}

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

@Override
public User findByPasswordResetToken(String token) {
  QueryResultsIterable<Vertex> userVertices = graph.query(authorizations)
      .has(UserVisalloProperties.PASSWORD_RESET_TOKEN.getPropertyName(), token)
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), userConceptId)
      .vertices();
  Vertex user = singleOrDefault(userVertices, null);
  return createFromVertex(user);
}

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

@Test
public void testGraphQueryVertexHasWithSecurityCantSeeProperty() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("age", 25, VISIBILITY_B)
      .save(AUTHORIZATIONS_A_AND_B);
  Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A)
      .has("age", Compare.EQUAL, 25)
      .vertices();
  Assert.assertEquals(0, count(vertices));
}

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

@Override
public Iterable<Relationship> getRelationshipsByIRI(List<String> relationshipIRIs, String workspaceId) {
  QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_RELATIONSHIP)
      .has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, relationshipIRIs)
      .vertices();
  return transformRelationships(vertices, workspaceId);
}

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

@Override
protected List<Concept> findLoadedConceptsByIntent(String intent, String workspaceId) {
  QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_CONCEPT)
      .has(OntologyProperties.INTENT.getPropertyName(), intent)
      .vertices();
  return transformConcepts(vertices, workspaceId);
}

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

@Override
public Iterable<OntologyProperty> getPropertiesByIRI(List<String> propertyIRIs, String workspaceId) {
  QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_PROPERTY)
      .has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, propertyIRIs)
      .vertices();
  return transformProperties(vertices, workspaceId);
}

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

@Override
public List<OntologyProperty> getPropertiesByIntent(String intent, String workspaceId) {
  QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_PROPERTY)
      .has(OntologyProperties.INTENT.getPropertyName(), intent)
      .vertices();
  return transformProperties(vertices, workspaceId);
}

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

@Override
public Iterable<Concept> getConceptsByIRI(List<String> conceptIRIs, String workspaceId) {
  QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_CONCEPT)
      .has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, conceptIRIs)
      .vertices();
  return transformConcepts(vertices, workspaceId);
}

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

@Override
protected List<Relationship> findLoadedRelationshipsByIntent(String intent, String workspaceId) {
  QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
      .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_RELATIONSHIP)
      .has(OntologyProperties.INTENT.getPropertyName(), intent)
      .vertices();
  return transformRelationships(vertices, workspaceId);
}

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

@Test
public void testGraphQueryVertexHasWithSecurityCantSeeProperty() {
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("age", 25, VISIBILITY_B)
      .save(AUTHORIZATIONS_A_AND_B);
  Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A)
      .has("age", Compare.EQUAL, 25)
      .vertices();
  Assert.assertEquals(0, count(vertices));
}

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

@Test
public void testAddVertexWithoutIndexing() {
  assumeTrue("add vertex without indexing not supported", !isDefaultSearchIndex());
  graph.prepareVertex("v1", VISIBILITY_A)
      .setProperty("prop1", "value1", VISIBILITY_A)
      .setIndexHint(IndexHint.DO_NOT_INDEX)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A_AND_B)
      .has("prop1", "value1")
      .vertices();
  assertVertexIds(vertices);
}

相关文章