org.vertexium.Graph.getVertex()方法的使用及代码示例

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

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

Graph.getVertex介绍

[英]Get a vertex from the graph.
[中]从图中获取顶点。

代码示例

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

public void retrieve(String vertexId, Graph graph, Authorizations authorizations) {
  Vertex retrievedVertex = graph.getVertex(vertexId, authorizations);
  if (retrievedVertex == null) {
    throw new VisalloException("failed to retrieve vertex by id: " + vertexId);
  }
}

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

public Vertex getVertex(Graph graph, boolean includeHidden, Authorizations authorizations) {
  if (this.workspaceVertex == null) {
    this.workspaceVertex = graph.getVertex(getWorkspaceId(), includeHidden ? FetchHint.ALL_INCLUDING_HIDDEN : FetchHint.ALL, authorizations);
  }
  return this.workspaceVertex;
}

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

private void benchmarkFindVerticesById(Random random, int vertexCount, int findVerticesByIdCount) {
  double startTime = System.currentTimeMillis();
  for (int i = 0; i < findVerticesByIdCount; i++) {
    String vertexId = "v" + random.nextInt(vertexCount);
    graph.getVertex(vertexId, AUTHORIZATIONS_ALL);
  }
  graph.flush();
  double endTime = System.currentTimeMillis();
  LOGGER.info("find vertices by id in %.3fs", (endTime - startTime) / 1000);
}

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

private void benchmarkFindVerticesById(Random random, int vertexCount, int findVerticesByIdCount) {
  double startTime = System.currentTimeMillis();
  for (int i = 0; i < findVerticesByIdCount; i++) {
    String vertexId = "v" + random.nextInt(vertexCount);
    graph.getVertex(vertexId, AUTHORIZATIONS_ALL);
  }
  graph.flush();
  double endTime = System.currentTimeMillis();
  LOGGER.info("find vertices by id in %.3fs", (endTime - startTime) / 1000);
}

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

/**
 * Get the attach vertex on either side of the edge.
 *
 * @param direction  The side of the edge to get the vertex from (IN or OUT).
 * @param fetchHints Hint on what should be fetched from the datastore.
 * @return The vertex.
 */
default Vertex getVertex(Direction direction, FetchHints fetchHints, Authorizations authorizations) {
  String vertexId = getVertexId(direction);
  return getGraph().getVertex(vertexId, fetchHints, authorizations);
}

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

@Override
public JSONObject findById(String longRunningProcessId, User user) {
  Authorizations authorizations = getAuthorizations(user);
  Vertex vertex = this.graph.getVertex(longRunningProcessId, authorizations);
  if (vertex == null) {
    return null;
  }
  return LongRunningProcessProperties.QUEUE_ITEM_JSON_PROPERTY.getPropertyValue(vertex);
}

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

/**
 * Find all term mentions connected to the vertex.
 */
public Iterable<Vertex> findByVertexId(String vertexId, Authorizations authorizations) {
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  Vertex vertex = graph.getVertex(vertexId, authorizationsWithTermMention);
  String[] labels = new String[]{
      VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION,
      VisalloProperties.TERM_MENTION_LABEL_RESOLVED_TO
  };
  return vertex.getVertices(Direction.BOTH, labels, authorizationsWithTermMention);
}

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

public Iterable<Vertex> findByOutVertex(String outVertexId, Authorizations authorizations) {
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  Vertex outVertex = graph.getVertex(outVertexId, authorizationsWithTermMention);
  return outVertex.getVertices(
      Direction.OUT,
      VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION,
      authorizationsWithTermMention
  );
}

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

public Iterable<Vertex> findResolvedTo(String inVertexId, Authorizations authorizations) {
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  Vertex inVertex = graph.getVertex(inVertexId, authorizationsWithTermMention);
  return inVertex.getVertices(
      Direction.IN,
      VisalloProperties.TERM_MENTION_LABEL_RESOLVED_TO,
      authorizationsWithTermMention
  );
}

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

/**
 * Given a vertexId that represents one side of a relationship, get me the vertex of the other side.
 */
default Vertex getOtherVertex(String myVertexId, FetchHints fetchHints, Authorizations authorizations) {
  String vertexId = getOtherVertexId(myVertexId);
  return getGraph().getVertex(vertexId, fetchHints, authorizations);
}

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

private Iterable<ClientApiSearch> getUserSavedSearches(User user, Authorizations authorizations) {
  Vertex userVertex = graph.getVertex(user.getUserId(), authorizations);
  checkNotNull(userVertex, "Could not find user vertex with id " + user.getUserId());
  Iterable<Vertex> userSearchVertices = userVertex.getVertices(
      Direction.OUT,
      SearchProperties.HAS_SAVED_SEARCH,
      authorizations
  );
  return stream(userSearchVertices)
      .map(searchVertex -> toClientApiSearch(searchVertex, ClientApiSearch.Scope.User))
      .collect(Collectors.toList());
}

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

public Vertex getProductVertex(String workspaceId, String productId, User user) {
  Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations(
      user,
      VISIBILITY_STRING,
      workspaceId
  );
  return getGraph().getVertex(productId, authorizations);
}

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

@Override
protected void processInternal(JSONObject jsonObject) {
  PingLongRunningProcessQueueItem queueItem = ClientApiConverter.toClientApi(
      jsonObject.toString(),
      PingLongRunningProcessQueueItem.class
  );
  Authorizations authorizations = authorizationRepository.getGraphAuthorizations(userRepository.getSystemUser());
  Vertex vertex = graph.getVertex(queueItem.getVertexId(), authorizations);
  pingUtil.lrpUpdate(vertex, graph, authorizations);
}

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

private Vertex getVertexFromWorkspace(Workspace workspace, boolean includeHidden, Authorizations authorizations) {
  if (workspace instanceof VertexiumWorkspace) {
    return ((VertexiumWorkspace) workspace).getVertex(getGraph(), includeHidden, authorizations);
  }
  return getGraph().getVertex(
      workspace.getWorkspaceId(),
      includeHidden ? FetchHint.ALL_INCLUDING_HIDDEN : FetchHint.ALL,
      authorizations
  );
}

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

@Test
public void testGetSingleVertexWithSameRowPrefix() {
  graph.addVertex("prefix", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
  graph.addVertex("prefixA", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
  graph.flush();
  Vertex v = graph.getVertex("prefix", AUTHORIZATIONS_EMPTY);
  assertEquals("prefix", v.getId());
  v = graph.getVertex("prefixA", AUTHORIZATIONS_EMPTY);
  assertEquals("prefixA", v.getId());
}

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

@Override
public Vertex getVertex(Object id) {
  if (id == null) {
    throw new IllegalArgumentException("Id cannot be null");
  }
  Authorizations authorizations = getAuthorizationsProvider().getAuthorizations();
  return VertexiumBlueprintsVertex.create(this, getGraph().getVertex(VertexiumBlueprintsConvert.idToString(id), getFetchHints(), authorizations), authorizations);
}

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

@Test
public void testAddRowWithErrorThatSkipsRow() throws Exception {
  PropertyMapping fraudMapping = findPropertyMapping(TX_FRAUD_NAME);
  fraudMapping.errorHandlingStrategy = PropertyMapping.ErrorHandlingStrategy.SKIP_ROW;
  doParse(false, true, 0, new String[]{"John Smith", "3/13/2015", "you bet"});
  Iterable<Vertex> vertices = getGraph().getVertices(authorizations);
  assertEquals("Expected new vertices to be created", 1, Iterables.size(vertices)); // CSV, PERSON
  Vertex personVertex = getGraph().getVertex("PERSON_VERTEX", authorizations);
  assertNull("Should not have found new person vertex", personVertex);
  Vertex txVertex = getGraph().getVertex("TX_VERTEX", authorizations);
  assertNull("Should not have found the transaction vertex", txVertex);
}

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

@Test
public void testBlankVisibilityString() {
  Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
  assertNotNull(v);
  assertEquals("v1", v.getId());
  graph.flush();
  v = graph.getVertex("v1", AUTHORIZATIONS_EMPTY);
  assertNotNull(v);
  assertEquals("v1", v.getId());
  assertEquals(VISIBILITY_EMPTY, v.getVisibility());
}

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

@Test
public void testBlankVisibilityString() {
  Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
  assertNotNull(v);
  assertEquals("v1", v.getId());
  graph.flush();
  v = graph.getVertex("v1", AUTHORIZATIONS_EMPTY);
  assertNotNull(v);
  assertEquals("v1", v.getId());
  assertEquals(VISIBILITY_EMPTY, v.getVisibility());
}

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

@Test
public void testStreamingPropertyValueReadAsString() {
  graph.prepareVertex("v1", VISIBILITY_EMPTY)
      .setProperty("spv", StreamingPropertyValue.create("Hello World"), VISIBILITY_EMPTY)
      .save(AUTHORIZATIONS_EMPTY);
  graph.flush();
  Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_EMPTY);
  assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString());
  assertEquals("Wor", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(6, 3));
  assertEquals("", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString("Hello World".length(), 1));
  assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(0, 100));
}

相关文章