@Override public Iterable<Vertex> getVertices(final Iterable<String> ids, final Authorizations authorizations) { return getVertices(ids, FetchHint.ALL, authorizations); }
@Override public Iterable<Vertex> getVertices(final Iterable<String> ids, final Authorizations authorizations) { return getVertices(ids, FetchHint.ALL, authorizations); }
@Override public abstract Iterable<Vertex> getVertices(EnumSet<FetchHint> fetchHints, Authorizations authorizations);
@Override public abstract Iterable<Vertex> getVertices(EnumSet<FetchHint> fetchHints, Authorizations authorizations);
@Override public Vertex getVertex(String vertexId, EnumSet<FetchHint> fetchHints, Authorizations authorizations) { LOGGER.warn("Performing scan of all vertices! Override getVertex."); for (Vertex vertex : getVertices(fetchHints, authorizations)) { if (vertex.getId().equals(vertexId)) { return vertex; } } return null; }
@Override public Map<String, Boolean> doVerticesExist(List<String> ids, Authorizations authorizations) { Map<String, Boolean> results = new HashMap<String, Boolean>(); for (String id : ids) { results.put(id, false); } for (Vertex vertex : getVertices(ids, FetchHint.NONE, authorizations)) { results.put(vertex.getId(), true); } return results; }
@Override public Map<String, Boolean> doVerticesExist(List<String> ids, Authorizations authorizations) { Map<String, Boolean> results = new HashMap<String, Boolean>(); for (String id : ids) { results.put(id, false); } for (Vertex vertex : getVertices(ids, FetchHint.NONE, authorizations)) { results.put(vertex.getId(), true); } return results; }
@Override public Vertex getVertex(String vertexId, EnumSet<FetchHint> fetchHints, Authorizations authorizations) { LOGGER.warn("Performing scan of all vertices! Override getVertex."); for (Vertex vertex : getVertices(fetchHints, authorizations)) { if (vertex.getId().equals(vertexId)) { return vertex; } } return null; }
@Override public List<Vertex> getVerticesInOrder(Iterable<String> ids, EnumSet<FetchHint> fetchHints, Authorizations authorizations) { final List<String> vertexIds = toList(ids); List<Vertex> vertices = toList(getVertices(vertexIds, authorizations)); Collections.sort(vertices, new Comparator<Vertex>() { @Override public int compare(Vertex v1, Vertex v2) { Integer i1 = vertexIds.indexOf(v1.getId()); Integer i2 = vertexIds.indexOf(v2.getId()); return i1.compareTo(i2); } }); return vertices; }
@Override public List<Vertex> getVerticesInOrder(Iterable<String> ids, EnumSet<FetchHint> fetchHints, Authorizations authorizations) { final List<String> vertexIds = toList(ids); List<Vertex> vertices = toList(getVertices(vertexIds, authorizations)); Collections.sort(vertices, new Comparator<Vertex>() { @Override public int compare(Vertex v1, Vertex v2) { Integer i1 = vertexIds.indexOf(v1.getId()); Integer i2 = vertexIds.indexOf(v2.getId()); return i1.compareTo(i2); } }); return vertices; }
@Override public Iterable<String> findRelatedEdges(Iterable<String> vertexIds, Authorizations authorizations) { Set<String> results = new HashSet<String>(); List<Vertex> vertices = toList(getVertices(vertexIds, authorizations)); // since we are checking bi-directional edges we should only have to check v1->v2 and not v2->v1 Map<String, String> checkedCombinations = new HashMap<String, String>(); for (Vertex sourceVertex : vertices) { for (Vertex destVertex : vertices) { if (checkedCombinations.containsKey(sourceVertex.getId() + destVertex.getId())) { continue; } Iterable<String> edgeIds = sourceVertex.getEdgeIds(destVertex, Direction.BOTH, authorizations); for (String edgeId : edgeIds) { results.add(edgeId); } checkedCombinations.put(sourceVertex.getId() + destVertex.getId(), ""); checkedCombinations.put(destVertex.getId() + sourceVertex.getId(), ""); } } return results; }
@Override public Iterable<String> findRelatedEdges(Iterable<String> vertexIds, Authorizations authorizations) { Set<String> results = new HashSet<String>(); List<Vertex> vertices = toList(getVertices(vertexIds, authorizations)); // since we are checking bi-directional edges we should only have to check v1->v2 and not v2->v1 Map<String, String> checkedCombinations = new HashMap<String, String>(); for (Vertex sourceVertex : vertices) { for (Vertex destVertex : vertices) { if (checkedCombinations.containsKey(sourceVertex.getId() + destVertex.getId())) { continue; } Iterable<String> edgeIds = sourceVertex.getEdgeIds(destVertex, Direction.BOTH, authorizations); for (String edgeId : edgeIds) { results.add(edgeId); } checkedCombinations.put(sourceVertex.getId() + destVertex.getId(), ""); checkedCombinations.put(destVertex.getId() + sourceVertex.getId(), ""); } } return results; }