mirror of
https://github.com/JHUAPL/AccumuloGraph.git
synced 2026-01-09 20:57:55 -05:00
Move removeEdge functionality into AccumuloEdge
Other cleanup
This commit is contained in:
@@ -18,6 +18,8 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.tinkerpop.blueprints.Direction;
|
||||
import com.tinkerpop.blueprints.Edge;
|
||||
import com.tinkerpop.blueprints.Element;
|
||||
import com.tinkerpop.blueprints.Index;
|
||||
import com.tinkerpop.blueprints.Vertex;
|
||||
import com.tinkerpop.blueprints.util.StringFactory;
|
||||
|
||||
@@ -70,7 +72,40 @@ public class AccumuloEdge extends AccumuloElement implements Edge {
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
globals.getGraph().removeEdge(this);
|
||||
// Load edge and all properties.
|
||||
AccumuloEdge copy = globals.getEdgeWrapper()
|
||||
.readEdgeAndAllProperties(id);
|
||||
|
||||
// Remove from named indexes.
|
||||
if (!globals.getConfig().getIndexableGraphDisabled()) {
|
||||
removeElementFromNamedIndexes(copy);
|
||||
}
|
||||
|
||||
// Remove from key/value indexes.
|
||||
for (String key : copy.getPropertyKeysInMemory()) {
|
||||
globals.getEdgeIndexWrapper().removePropertyFromIndex(copy,
|
||||
key, copy.getPropertyInMemory(key));
|
||||
}
|
||||
|
||||
// Get rid of the endpoints and edge themselves.
|
||||
globals.getVertexWrapper().deleteEdgeEndpoints(copy);
|
||||
globals.getEdgeWrapper().deleteEdge(copy);
|
||||
|
||||
// Remove element from cache.
|
||||
globals.getCaches().remove(id, Edge.class);
|
||||
|
||||
globals.checkedFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This will go away when {@link AccumuloGraph#getIndices()} refactoring is done.
|
||||
* @param element
|
||||
*/
|
||||
@Deprecated
|
||||
private void removeElementFromNamedIndexes(Element element) {
|
||||
for (Index<? extends Element> index : globals.getGraph().getIndices()) {
|
||||
((AccumuloIndex<? extends Element>) index).getWrapper().removeElementFromIndex(element);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVertices(AccumuloVertex inVertex, AccumuloVertex outVertex) {
|
||||
|
||||
@@ -164,10 +164,20 @@ public class AccumuloGraph implements Graph, KeyIndexableGraph, IndexableGraph {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This will go away along with {@link #vertexBW}.
|
||||
* @throws Exception
|
||||
*/
|
||||
private void setupWriters() throws Exception {
|
||||
vertexBW = globals.getMtbw().getBatchWriter(globals.getConfig().getVertexTableName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Move this somewhere appropriate
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
protected Scanner getElementScanner(Class<? extends Element> type) {
|
||||
try {
|
||||
String tableName = globals.getConfig().getEdgeTableName();
|
||||
@@ -179,6 +189,12 @@ public class AccumuloGraph implements Graph, KeyIndexableGraph, IndexableGraph {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Move this somewhere appropriate
|
||||
* @param tablename
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
protected Scanner getScanner(String tablename) {
|
||||
try {
|
||||
return globals.getConfig().getConnector().createScanner(tablename,
|
||||
@@ -406,6 +422,10 @@ public class AccumuloGraph implements Graph, KeyIndexableGraph, IndexableGraph {
|
||||
}
|
||||
|
||||
// Maybe an Custom Iterator could make this better.
|
||||
/**
|
||||
* @deprecated Move to appropriate location.
|
||||
* @param element
|
||||
*/
|
||||
private void removeElementFromNamedIndexes(Element element) {
|
||||
for (Index<? extends Element> index : getIndices()) {
|
||||
((AccumuloIndex<? extends Element>) index).getWrapper().removeElementFromIndex(element);
|
||||
@@ -499,31 +519,7 @@ public class AccumuloGraph implements Graph, KeyIndexableGraph, IndexableGraph {
|
||||
|
||||
@Override
|
||||
public void removeEdge(Edge edge) {
|
||||
// TODO Move the below into AccumuloEdge.
|
||||
|
||||
// Load edge and all properties.
|
||||
AccumuloEdge copy = globals.getEdgeWrapper()
|
||||
.readEdgeAndAllProperties(edge.getId().toString());
|
||||
|
||||
// Remove from named indexes.
|
||||
if (!globals.getConfig().getIndexableGraphDisabled()) {
|
||||
removeElementFromNamedIndexes(copy);
|
||||
}
|
||||
|
||||
// Remove from key/value indexes.
|
||||
for (String key : copy.getPropertyKeysInMemory()) {
|
||||
globals.getEdgeIndexWrapper().removePropertyFromIndex(copy,
|
||||
key, copy.getPropertyInMemory(key));
|
||||
}
|
||||
|
||||
// Get rid of the endpoints and edge themselves.
|
||||
globals.getVertexWrapper().deleteEdgeEndpoints(copy);
|
||||
globals.getEdgeWrapper().deleteEdge(edge);
|
||||
|
||||
// Remove element from cache.
|
||||
globals.getCaches().remove(edge.getId(), Edge.class);
|
||||
|
||||
globals.checkedFlush();
|
||||
edge.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -665,6 +661,8 @@ public class AccumuloGraph implements Graph, KeyIndexableGraph, IndexableGraph {
|
||||
|
||||
@Override
|
||||
public Iterable<Index<? extends Element>> getIndices() {
|
||||
// TODO Move the below into the suitable index metadata wrapper.
|
||||
|
||||
if (globals.getConfig().getIndexableGraphDisabled())
|
||||
throw new UnsupportedOperationException("IndexableGraph is disabled via the configuration");
|
||||
List<Index<? extends Element>> toRet = new ArrayList<Index<? extends Element>>();
|
||||
|
||||
Reference in New Issue
Block a user