diff --git a/src/main/java/edu/jhuapl/tinkerpop/AccumuloElement.java b/src/main/java/edu/jhuapl/tinkerpop/AccumuloElement.java index 77a5903..8ff27e5 100644 --- a/src/main/java/edu/jhuapl/tinkerpop/AccumuloElement.java +++ b/src/main/java/edu/jhuapl/tinkerpop/AccumuloElement.java @@ -79,7 +79,11 @@ public abstract class AccumuloElement implements Element { @Override public void setProperty(String key, Object value) { makeCache(); - globals.getGraph().setProperty(type, this, key, value); + globals.getGraph().setPropertyForIndexes(type, this, key, value); + // MDL 31 Dec 2014: The above calls getProperty, so this + // order is important (for now). + globals.getElementWrapper(type).writeProperty(this, key, value); + globals.getGraph().checkedFlush(); propertyCache.put(key, value); } diff --git a/src/main/java/edu/jhuapl/tinkerpop/AccumuloGraph.java b/src/main/java/edu/jhuapl/tinkerpop/AccumuloGraph.java index 9380bcd..5716359 100644 --- a/src/main/java/edu/jhuapl/tinkerpop/AccumuloGraph.java +++ b/src/main/java/edu/jhuapl/tinkerpop/AccumuloGraph.java @@ -838,7 +838,7 @@ public class AccumuloGraph implements Graph, KeyIndexableGraph, IndexableGraph { } } - private void checkedFlush() { + void checkedFlush() { if (config.getAutoFlush()) { flush(); } @@ -858,30 +858,25 @@ public class AccumuloGraph implements Graph, KeyIndexableGraph, IndexableGraph { * @param key * @param val */ - void setProperty(Class type, Element element, String key, Object val) { + void setPropertyForIndexes(Class type, Element element, String key, Object val) { checkProperty(key, val); try { - byte[] newByteVal = AccumuloByteSerializer.serialize(val); - Mutation m = null; - if (config.getAutoIndex() || getIndexedKeys(type).contains(key)) { + byte[] newByteVal = AccumuloByteSerializer.serialize(val); + BatchWriter bw = getIndexBatchWriter(type); Object old = element.getProperty(key); if (old != null) { byte[] oldByteVal = AccumuloByteSerializer.serialize(old); - m = new Mutation(oldByteVal); + Mutation m = new Mutation(oldByteVal); m.putDelete(key, element.getId().toString()); bw.addMutation(m); } - m = new Mutation(newByteVal); + Mutation m = new Mutation(newByteVal); m.put(key.getBytes(), element.getId().toString().getBytes(), EMPTY); bw.addMutation(m); checkedFlush(); } - - getElementTableWrapper(type).writeProperty(element, key, val); - - checkedFlush(); } catch (MutationsRejectedException e) { e.printStackTrace(); }