private ResourceIterator <Relationship> GetRelationshipSelectionIterator(KernelTransaction transaction, Direction direction, int[] typeIds) { NodeCursor node = transaction.AmbientNodeCursor(); transaction.DataRead().singleNode(Id, node); if (!node.Next()) { throw new NotFoundException(format("Node %d not found", _nodeId)); } switch (direction.innerEnumValue) { case Direction.InnerEnum.OUTGOING: return(outgoingIterator(transaction.Cursors(), node, typeIds, this)); case Direction.InnerEnum.INCOMING: return(incomingIterator(transaction.Cursors(), node, typeIds, this)); case Direction.InnerEnum.BOTH: return(allIterator(transaction.Cursors(), node, typeIds, this)); default: throw new System.InvalidOperationException("Unknown direction " + direction); } }
public virtual int getDegree(Direction direction) { KernelTransaction transaction = SafeAcquireTransaction(); using (Statement ignore = transaction.AcquireStatement()) { NodeCursor nodes = transaction.AmbientNodeCursor(); SingleNode(transaction, nodes); switch (direction.innerEnumValue) { case Direction.InnerEnum.OUTGOING: return(Nodes.countOutgoing(nodes, transaction.Cursors())); case Direction.InnerEnum.INCOMING: return(Nodes.countIncoming(nodes, transaction.Cursors())); case Direction.InnerEnum.BOTH: return(Nodes.countAll(nodes, transaction.Cursors())); default: throw new System.InvalidOperationException("Unknown direction " + direction); } } }
public virtual int getDegree(RelationshipType type, Direction direction) { KernelTransaction transaction = SafeAcquireTransaction(); int typeId = transaction.TokenRead().relationshipType(type.Name()); if (typeId == NO_TOKEN) { // This type doesn't even exist. Return 0 return(0); } using (Statement ignore = transaction.AcquireStatement()) { NodeCursor nodes = transaction.AmbientNodeCursor(); SingleNode(transaction, nodes); switch (direction.innerEnumValue) { case Direction.InnerEnum.OUTGOING: return(Nodes.countOutgoing(nodes, transaction.Cursors(), typeId)); case Direction.InnerEnum.INCOMING: return(Nodes.countIncoming(nodes, transaction.Cursors(), typeId)); case Direction.InnerEnum.BOTH: return(Nodes.countAll(nodes, transaction.Cursors(), typeId)); default: throw new System.InvalidOperationException("Unknown direction " + direction); } } }
public override bool HasProperty(string key) { if (null == key) { return(false); } KernelTransaction transaction = SafeAcquireTransaction(); int propertyKey = transaction.TokenRead().propertyKey(key); if (propertyKey == [email protected]_Fields.NO_TOKEN) { return(false); } NodeCursor nodes = transaction.AmbientNodeCursor(); PropertyCursor properties = transaction.AmbientPropertyCursor(); SingleNode(transaction, nodes); nodes.Properties(properties); while (properties.Next()) { if (propertyKey == properties.PropertyKey()) { return(true); } } return(false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Object getProperty(String key) throws org.neo4j.graphdb.NotFoundException public override object GetProperty(string key) { if (null == key) { throw new System.ArgumentException("(null) property key is not allowed"); } KernelTransaction transaction = SafeAcquireTransaction(); int propertyKey = transaction.TokenRead().propertyKey(key); if (propertyKey == [email protected]_Fields.NO_TOKEN) { throw new NotFoundException(format("No such property, '%s'.", key)); } NodeCursor nodes = transaction.AmbientNodeCursor(); PropertyCursor properties = transaction.AmbientPropertyCursor(); SingleNode(transaction, nodes); nodes.Properties(properties); while (properties.Next()) { if (propertyKey == properties.PropertyKey()) { Value value = properties.PropertyValue(); if (value == Values.NO_VALUE) { throw new NotFoundException(format("No such property, '%s'.", key)); } return(value.AsObjectCopy()); } } throw new NotFoundException(format("No such property, '%s'.", key)); }
public override IDictionary <string, object> GetProperties(params string[] keys) { Objects.requireNonNull(keys, "Properties keys should be not null array."); if (keys.Length == 0) { return(Collections.emptyMap()); } KernelTransaction transaction = SafeAcquireTransaction(); int itemsToReturn = keys.Length; IDictionary <string, object> properties = new Dictionary <string, object>(itemsToReturn); TokenRead token = transaction.TokenRead(); //Find ids, note we are betting on that the number of keys //is small enough not to use a set here. int[] propertyIds = new int[itemsToReturn]; for (int i = 0; i < itemsToReturn; i++) { string key = keys[i]; if (string.ReferenceEquals(key, null)) { throw new System.NullReferenceException(string.Format("Key {0:D} was null", i)); } propertyIds[i] = token.PropertyKey(key); } NodeCursor nodes = transaction.AmbientNodeCursor(); PropertyCursor propertyCursor = transaction.AmbientPropertyCursor(); SingleNode(transaction, nodes); nodes.Properties(propertyCursor); int propertiesToFind = itemsToReturn; while (propertiesToFind > 0 && propertyCursor.Next()) { //Do a linear check if this is a property we are interested in. int currentKey = propertyCursor.PropertyKey(); for (int i = 0; i < itemsToReturn; i++) { if (propertyIds[i] == currentKey) { properties[keys[i]] = propertyCursor.PropertyValue().asObjectCopy(); propertiesToFind--; break; } } } return(properties); }
public override bool HasLabel(Label label) { KernelTransaction transaction = SafeAcquireTransaction(); NodeCursor nodes = transaction.AmbientNodeCursor(); using (Statement ignore = transaction.AcquireStatement()) { int labelId = transaction.TokenRead().nodeLabel(label.Name()); if (labelId == NO_SUCH_LABEL) { return(false); } transaction.DataRead().singleNode(_nodeId, nodes); return(nodes.Next() && nodes.HasLabel(labelId)); } }
public virtual int getDegree(RelationshipType type) { KernelTransaction transaction = SafeAcquireTransaction(); int typeId = transaction.TokenRead().relationshipType(type.Name()); if (typeId == NO_TOKEN) { // This type doesn't even exist. Return 0 return(0); } using (Statement ignore = transaction.AcquireStatement()) { NodeCursor nodes = transaction.AmbientNodeCursor(); SingleNode(transaction, nodes); return(Nodes.countAll(nodes, transaction.Cursors(), typeId)); } }