Esempio n. 1
0
        public override RelationshipGroupCursor AllocateRelationshipGroupCursor()
        {
            RelationshipGroupCursor n = _cursors.allocateRelationshipGroupCursor();

            _allCursors.Add(n);
            return(n);
        }
Esempio n. 2
0
 /// <summary>
 /// Counts the number of incoming relationships from node where the cursor is positioned.
 /// <para>
 /// NOTE: The number of incoming relationships also includes eventual loops.
 ///
 /// </para>
 /// </summary>
 /// <param name="nodeCursor"> a cursor positioned at the node whose relationships we're counting </param>
 /// <param name="cursors"> a factory for cursors </param>
 /// <returns> the number of incoming - including loops - relationships from the node </returns>
 public static int CountIncoming(NodeCursor nodeCursor, CursorFactory cursors)
 {
     if (nodeCursor.Dense)
     {
         using (RelationshipGroupCursor group = cursors.AllocateRelationshipGroupCursor())
         {
             nodeCursor.Relationships(group);
             int count = 0;
             while (group.next())
             {
                 count += group.IncomingCount() + group.LoopCount();
             }
             return(count);
         }
     }
     else
     {
         using (RelationshipTraversalCursor traversal = cursors.AllocateRelationshipTraversalCursor())
         {
             int count = 0;
             nodeCursor.AllRelationships(traversal);
             while (traversal.next())
             {
                 if (traversal.TargetNodeReference() == nodeCursor.NodeReference())
                 {
                     count++;
                 }
             }
             return(count);
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Counts all the relationships of the given type from node where the cursor is positioned.
 /// </summary>
 /// <param name="nodeCursor"> a cursor positioned at the node whose relationships we're counting </param>
 /// <param name="cursors"> a factory for cursors </param>
 /// <param name="type"> the type of the relationship we're counting </param>
 /// <returns> the number relationships from the node with the given type </returns>
 public static int CountAll(NodeCursor nodeCursor, CursorFactory cursors, int type)
 {
     if (nodeCursor.Dense)
     {
         using (RelationshipGroupCursor group = cursors.AllocateRelationshipGroupCursor())
         {
             nodeCursor.Relationships(group);
             int count = 0;
             while (group.next())
             {
                 if (group.Type() == type)
                 {
                     return(group.TotalCount());
                 }
             }
             return(count);
         }
     }
     else
     {
         using (RelationshipTraversalCursor traversal = cursors.AllocateRelationshipTraversalCursor())
         {
             int count = 0;
             nodeCursor.AllRelationships(traversal);
             while (traversal.next())
             {
                 if (traversal.Type() == type)
                 {
                     count++;
                 }
             }
             return(count);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Counts the number of outgoing relationships of the given type from node where the cursor is positioned.
 /// <para>
 /// NOTE: The number of outgoing relationships also includes eventual loops.
 ///
 /// </para>
 /// </summary>
 /// <param name="nodeCursor"> a cursor positioned at the node whose relationships we're counting </param>
 /// <param name="cursors"> a factory for cursors </param>
 /// <param name="type"> the type of the relationship we're counting </param>
 /// <returns> the number of outgoing - including loops - relationships from the node with the given type </returns>
 public static int CountOutgoing(NodeCursor nodeCursor, CursorFactory cursors, int type)
 {
     if (nodeCursor.Dense)
     {
         using (RelationshipGroupCursor group = cursors.AllocateRelationshipGroupCursor())
         {
             nodeCursor.Relationships(group);
             while (group.next())
             {
                 if (group.Type() == type)
                 {
                     return(group.OutgoingCount() + group.LoopCount());
                 }
             }
             return(0);
         }
     }
     else
     {
         using (RelationshipTraversalCursor traversal = cursors.AllocateRelationshipTraversalCursor())
         {
             int count = 0;
             nodeCursor.AllRelationships(traversal);
             while (traversal.next())
             {
                 if (traversal.SourceNodeReference() == nodeCursor.NodeReference() && traversal.Type() == type)
                 {
                     count++;
                 }
             }
             return(count);
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Traverse all incoming relationships including loops of the provided relationship types.
 /// </summary>
 /// <param name="groupCursor"> Group cursor to use. Pre-initialized on node. </param>
 /// <param name="relationshipCursor"> Relationship traversal cursor to use. </param>
 /// <param name="types"> Relationship types to traverse </param>
 public void Incoming(RelationshipGroupCursor groupCursor, RelationshipTraversalCursor relationshipCursor, int[] types)
 {
     this._groupCursor       = groupCursor;
     this.RelationshipCursor = relationshipCursor;
     this._types             = types;
     this._directions[0]     = Dir.In;
     this._directions[1]     = Dir.Loop;
     this._nDirections       = 2;
     this._currentDirection  = _directions.Length;
     this._onRelationship    = false;
     this._onGroup           = false;
     this._foundTypes        = 0;
 }
Esempio n. 6
0
        private static void SetupAllDense(RelationshipDenseSelection denseSelection, CursorFactory cursors, NodeCursor node, int[] types)
        {
            RelationshipGroupCursor     groupCursor     = cursors.AllocateRelationshipGroupCursor();
            RelationshipTraversalCursor traversalCursor = cursors.AllocateRelationshipTraversalCursor();

            try
            {
                node.Relationships(groupCursor);
                denseSelection.All(groupCursor, traversalCursor, types);
            }
            catch (Exception t)
            {
                groupCursor.close();
                traversalCursor.close();
                throw t;
            }
        }
Esempio n. 7
0
        public virtual void Close()
        {
            Exception closeGroupError = null;

            try
            {
                if (_groupCursor != null)
                {
                    _groupCursor.close();
                }
            }
            catch (Exception t)
            {
                closeGroupError = t;
            }

            try
            {
                if (RelationshipCursor != null)
                {
                    RelationshipCursor.close();
                }
            }
            catch (Exception t)
            {
                if (closeGroupError != null)
                {
                    t.addSuppressed(closeGroupError);
                }
                throw t;
            }
            finally
            {
                RelationshipCursor = null;
                _groupCursor       = null;
            }
        }
Esempio n. 8
0
 public override void RelationshipGroups(long nodeReference, long reference, RelationshipGroupCursor cursor)
 {
     throw new System.NotSupportedException();
 }
Esempio n. 9
0
 /// <summary>
 /// Traverse all incoming relationships including loops of the provided relationship types.
 /// </summary>
 /// <param name="groupCursor"> Group cursor to use. Pre-initialized on node. </param>
 /// <param name="relationshipCursor"> Relationship traversal cursor to use. </param>
 public void Incoming(RelationshipGroupCursor groupCursor, RelationshipTraversalCursor relationshipCursor)
 {
     Incoming(groupCursor, relationshipCursor, null);
 }
Esempio n. 10
0
 /// <summary>
 /// Traverse all outgoing relationships including loops of the provided relationship types.
 /// </summary>
 /// <param name="groupCursor"> Group cursor to use. Pre-initialized on node. </param>
 /// <param name="relationshipCursor"> Relationship traversal cursor to use. </param>
 public void Outgoing(RelationshipGroupCursor groupCursor, RelationshipTraversalCursor relationshipCursor)
 {
     Outgoing(groupCursor, relationshipCursor, null);
 }
Esempio n. 11
0
 /// <summary>
 /// Traverse all relationships of the provided relationship types.
 /// </summary>
 /// <param name="groupCursor"> Group cursor to use. Pre-initialized on node. </param>
 /// <param name="relationshipCursor"> Relationship traversal cursor to use. </param>
 public void All(RelationshipGroupCursor groupCursor, RelationshipTraversalCursor relationshipCursor)
 {
     All(groupCursor, relationshipCursor, null);
 }
Esempio n. 12
0
 public override void RelationshipGroups(long nodeReference, long reference, RelationshipGroupCursor cursor)
 {
     (( DefaultRelationshipGroupCursor )cursor).Init(nodeReference, reference, this);
 }
Esempio n. 13
0
 public override void Relationships(RelationshipGroupCursor cursor)
 {
     (( StubGroupCursor )cursor).Rewind();
 }