@Override public final Node rephase() { this._resolver.alignState(this); return this; }
protected final NodeState phasedState() { return this._resolver.alignState(this); }
protected final NodeState phasedState() { return this._resolver.alignState(this); }
@Override public final void rephase() { this._resolver.alignState(this); }
@Override public void setPropertyByIndex(long propIndex, byte propertyType, Object propertyValue) { _resolver.alignState(this).set(propIndex, propertyType, propertyValue); } }
@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; }
@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 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 void forceProperty(String propertyName, byte propertyType, Object propertyValue) { final long hashed = this._resolver.stringToHash(propertyName, true); 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 final void add(String relationName, Node relatedNode) { if (relatedNode != null) { NodeState preciseState = this._resolver.alignState(this); final long relHash = this._resolver.stringToHash(relationName, true); if (preciseState != null) { Relationship relationArray = (Relationship) preciseState.getOrCreate(relHash, Type.RELATION); relationArray.add(relatedNode.id()); } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } } }
@Override public final void remove(String relationName, Node relatedNode) { if (relatedNode != null) { final NodeState preciseState = this._resolver.alignState(this); final long relHash = this._resolver.stringToHash(relationName, false); if (preciseState != null) { Relationship relationArray = (Relationship) preciseState.get(relHash); if (relationArray != null) { relationArray.remove(relatedNode.id()); } } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } } }
@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 Node addToRelationAt(int relationIndex, Node relatedNode, String... attributes) { if (relatedNode != null) { NodeState preciseState = this._resolver.alignState(this); if (preciseState != null) { boolean attributesNotEmpty = (attributes != null && attributes.length > 0); if (attributesNotEmpty) { RelationIndexed indexedRel = (RelationIndexed) preciseState.getOrCreate(relationIndex, Type.RELATION_INDEXED); indexedRel.add(relatedNode, attributes); } else { Relation relationArray = (Relation) preciseState.getOrCreate(relationIndex, Type.RELATION); relationArray.add(relatedNode.id()); } } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } } return this; }
@Override public Node removeFromRelationAt(int relationIndex, Node relatedNode, String... attributes) { if (relatedNode != null) { final NodeState preciseState = this._resolver.alignState(this); if (preciseState != null) { boolean attributesNotEmpty = (attributes != null && attributes.length > 0); if (attributesNotEmpty) { RelationIndexed indexedRel = (RelationIndexed) preciseState.getOrCreate(relationIndex, Type.RELATION_INDEXED); indexedRel.remove(relatedNode, attributes); } else { Relation relationArray = (Relation) preciseState.getOrCreate(relationIndex, Type.RELATION); relationArray.remove(relatedNode.id()); } } else { throw new RuntimeException(Constants.CACHE_MISS_ERROR); } } return this; }
@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 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); } }
final NodeState currentNodeState = this._resolver.alignState(this); if (currentNodeState == null) { throw new RuntimeException(Constants.CACHE_MISS_ERROR);