@Override public Relationship getOrCreateRel(String propertyName) { return (Relationship) getOrCreate(propertyName, Type.RELATION); }
@Override public final void rel(String relationName, final Callback<Node[]> callback) { relByIndex(this._resolver.stringToHash(relationName, false), callback); }
@Override public final void removeProperty(String attributeName) { setProperty(attributeName, Type.INT, null); }
@Override public void find(String indexName, String query, Callback<Node[]> callback) { final Query queryObj = _graph.newQuery(); queryObj.setWorld(world()); queryObj.setTime(time()); queryObj.setIndexName(indexName); queryObj.parse(query); findByQuery(queryObj, callback); }
@Override public void findAll(final String indexName, final Callback<Node[]> callback) { final NodeState currentNodeState = this._resolver.resolveState(this); if (currentNodeState == null) { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } final LongLongArrayMap indexMap = (LongLongArrayMap) currentNodeState.get(this._resolver.stringToHash(indexName, false)); if (indexMap != null) { final long[] ids = new long[(int) indexMap.size()]; final int[] idIndex = {0}; indexMap.each(new LongLongArrayMapCallBack() { @Override public void on(final long hash, final long nodeId) { ids[idIndex[0]] = nodeId; idIndex[0]++; } }); _resolver.lookupAll(world(), time(), ids, new Callback<Node[]>() { @Override public void on(Node[] result) { //TODO shrink result callback.on(result); } }); } else { callback.on(new org.mwg.plugin.AbstractNode[0]); } }
@Override public void setProperty(String propertyName, byte propertyType, Object propertyValue) { //hash the property a single time final long hashed = this._resolver.stringToHash(propertyName, true); final NodeState unPhasedState = this._resolver.resolveState(this); boolean isDiff = (propertyType != unPhasedState.getType(hashed)); if (!isDiff) { isDiff = !isEquals(unPhasedState.get(hashed), propertyValue, propertyType); } if (isDiff) { final NodeState preciseState = this._resolver.alignState(this); if (preciseState != null) { preciseState.set(hashed, propertyType, propertyValue); } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } } }
public final void set(String propertyName, Object propertyValue) { if (propertyValue instanceof String) { setProperty(propertyName, Type.STRING, propertyValue); } else if (propertyValue instanceof Double) { setProperty(propertyName, Type.DOUBLE, propertyValue); } else if (propertyValue instanceof Long) { setProperty(propertyName, Type.LONG, propertyValue); } else if (propertyValue instanceof Float) { setProperty(propertyName, Type.DOUBLE, (double) ((Float) propertyValue)); } else if (propertyValue instanceof Integer) { setProperty(propertyName, Type.INT, propertyValue); } else if (propertyValue instanceof Boolean) { setProperty(propertyName, Type.BOOL, propertyValue); } else if (propertyValue instanceof int[]) { setProperty(propertyName, Type.INT_ARRAY, propertyValue); } else if (propertyValue instanceof double[]) { setProperty(propertyName, Type.DOUBLE_ARRAY, propertyValue); } else if (propertyValue instanceof long[]) { setProperty(propertyName, Type.LONG_ARRAY, propertyValue); } else { throw new RuntimeException("Invalid property type: " + propertyValue + ", please use a Type listed in org.mwg.Type");