@Override public int hashCode() { return getVertex().hashCode(); }
@Override public void removeVertex(Vertex vertex, Authorizations authorizations) { if (!((InMemoryVertex) vertex).canRead(authorizations)) { return; } List<Edge> edgesToRemove = toList(vertex.getEdges(Direction.BOTH, authorizations)); for (Edge edgeToRemove : edgesToRemove) { removeEdge(edgeToRemove, authorizations); } this.vertices.remove(vertex.getId()); getSearchIndex().removeElement(this, vertex, authorizations); if (hasEventListeners()) { fireGraphEvent(new RemoveVertexEvent(this, vertex)); } }
@Override public void removeVertex(Vertex vertex, Authorizations authorizations) { if (vertex == null) { throw new IllegalArgumentException("vertex cannot be null"); } getSearchIndex().removeElement(this, vertex, authorizations); // Remove all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { removeEdge(edge, authorizations); } addMutations(getVerticesWriter(), getDeleteRowMutation(AccumuloConstants.VERTEX_ROW_KEY_PREFIX + vertex.getId())); if (hasEventListeners()) { queueEvent(new RemoveVertexEvent(this, vertex)); } }
@Test public void testRemoveVertexWithProperties() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Property prop1 = v1.getProperty("prop1"); assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A))); graph.removeVertex(v1, AUTHORIZATIONS_A); assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A_AND_B))); graph.flush(); assertEvents( new AddVertexEvent(graph, v1), new AddPropertyEvent(graph, v1, prop1), new RemoveVertexEvent(graph, v1) ); }
@Override public int hashCode() { return getVertex().hashCode(); }
@Test public void testRemoveVertexWithProperties() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Property prop1 = v1.getProperty("prop1"); assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A))); graph.removeVertex(v1, AUTHORIZATIONS_A); assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A_AND_B))); graph.flush(); assertEvents( new AddVertexEvent(graph, v1), new AddPropertyEvent(graph, v1, prop1), new RemoveVertexEvent(graph, v1) ); }