@Override public Node setAt(int index, byte type, Object value) { final NodeState unPhasedState = this._resolver.resolveState(this); boolean isDiff = (type != unPhasedState.getType(index)); if (!isDiff) { isDiff = !isEquals(unPhasedState.get(index), value, type); } if (isDiff) { final NodeState preciseState = this._resolver.alignState(this); if (preciseState != null) { preciseState.set(index, type, value); } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } } return this; }
@Override public Object getOrCreateAt(int index, byte type) { final NodeState preciseState = this._resolver.alignState(this); if (preciseState != null) { return preciseState.getOrCreate(index, type); } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } }
@Override public final long lastModification() { final NodeState state = this._resolver.resolveState(this); if (state != null) { return state.time(); } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } }
for (int i = 0; i < keyAttributes.length; i++) { String attKey = keyAttributes[i]; Object attValue = toIndexNodeState.getFromKey(attKey); if (attValue != null) { flatQuery.add(attKey, attValue.toString()); final NodeState previousState = this._resolver.resolveState(this); if (previousState != null) { LongLongArrayMap previousMap = (LongLongArrayMap) previousState.get(hashName); if (previousMap != null) { alreadyIndexed = previousMap.contains(flatQuery.hash(), nodeToIndex.id()); throw new RuntimeException(Constants.CACHE_MISS_ERROR); LongLongArrayMap indexMap = (LongLongArrayMap) currentNodeState.getOrCreate(hashName, Type.LONG_TO_LONG_ARRAY_MAP); indexMap.put(flatQuery.hash(), nodeToIndex.id());
@Override public Object getAt(int propIndex) { return _resolver.resolveState(this).get(propIndex); }
@Override public void unindex(String indexName, org.mwg.Node nodeToIndex, String flatKeyAttributes, Callback<Boolean> callback) { final String[] keyAttributes = flatKeyAttributes.split(Constants.QUERY_SEP + ""); final NodeState currentNodeState = this._resolver.alignState(this); if (currentNodeState == null) { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } LongLongArrayMap indexMap = (LongLongArrayMap) currentNodeState.get(this._resolver.stringToHash(indexName, false)); if (indexMap != null) { Query flatQuery = _graph.newQuery(); final NodeState toIndexNodeState = this._resolver.resolveState(nodeToIndex); for (int i = 0; i < keyAttributes.length; i++) { String attKey = keyAttributes[i]; Object attValue = toIndexNodeState.getFromKey(attKey); if (attValue != null) { flatQuery.add(attKey, attValue.toString()); } else { flatQuery.add(attKey, null); } } //TODO AUTOMATIC UPDATE indexMap.remove(flatQuery.hash(), nodeToIndex.id()); } if (Constants.isDefined(callback)) { callback.on(true); } }
switch (resolved.getType(relationIndex)) { case Type.RELATION: final Relation relation = (Relation) resolved.get(relationIndex); if (relation == null || relation.size() == 0) { callback.on(new Node[0]); final RelationIndexed relation_indexed = (RelationIndexed) resolved.get(relationIndex); if (relation_indexed == null || relation_indexed.size() == 0) { callback.on(new Node[0]);
@Override public byte typeAt(final int index) { final NodeState resolved = this._resolver.resolveState(this); if (resolved != null) { return resolved.getType(index); } return -1; }
@Override public void setPropertyByIndex(long propIndex, byte propertyType, Object propertyValue) { _resolver.alignState(this).set(propIndex, propertyType, propertyValue); } }
final NodeState state = this._resolver.resolveState(this); if (state != null) { state.each(new NodeStateCallback() { @Override public void on(int attributeKey, byte elemType, Object elem) {
private void internal_add_remove(boolean isIndex, Node node, String... attributeNames) { Query flatQuery = node.graph().newQuery(); final NodeState toIndexNodeState = node.graph().resolver().resolveState(node); for (int i = 0; i < attributeNames.length; i++) { final String attKey = attributeNames[i]; final Object attValue = toIndexNodeState.getFromKey(attKey); if (attValue != null) { flatQuery.add(attKey, attValue.toString()); } else { flatQuery.add(attKey, null); } } if (isIndex) { put(flatQuery.hash(), node.id()); } else { delete(flatQuery.hash(), node.id()); } }
@Override public Object getByIndex(long propIndex) { return _resolver.resolveState(this).get(propIndex); }
@Override public byte type(String name) { final NodeState resolved = this._resolver.resolveState(this); if (resolved != null) { return resolved.getType(this._resolver.stringToHash(name, false)); } return -1; }
@Override public Node forceSetAt(int index, byte type, Object value) { final NodeState preciseState = this._resolver.alignState(this); if (preciseState != null) { preciseState.set(index, type, value); } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } return this; }
final NodeState state = this._resolver.resolveState(this); if (state != null) { state.each(new NodeStateCallback() { @Override public void on(long attributeKey, byte elemType, Object elem) {
@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); } } }
@Override public Object get(String name) { final NodeState resolved = this._resolver.resolveState(this); if (resolved != null) { return resolved.get(this._resolver.stringToHash(name, false)); } return null; }
@Override public final Object getOrCreate(String propertyName, byte propertyType) { final NodeState preciseState = this._resolver.alignState(this); if (preciseState != null) { return preciseState.getOrCreate(this._resolver.stringToHash(propertyName, true), propertyType); } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } }
@Override public final long timeDephasing() { final NodeState state = this._resolver.resolveState(this); if (state != null) { return (this._time - state.time()); } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } }
@Override public byte type(String propertyName) { final NodeState resolved = this._resolver.resolveState(this); if (resolved != null) { return resolved.getType(this._resolver.stringToHash(propertyName, false)); } return -1; }