Beispiel #1
0
        // Sparse traversal but with tx-state filtering

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void sparseTraversalWithTxStateFiltering()
        public virtual void SparseTraversalWithTxStateFiltering()
        {
            // given
            StorageRelationshipTraversalCursor storeCursor = storeCursor(Rel(100, _node, 50, _type), Rel(102, _node, 51, _type), Rel(104, _node, 52, _type));

            DefaultRelationshipTraversalCursor cursor = new DefaultRelationshipTraversalCursor(_pool, storeCursor);
            Read read = TxState(Rel(3, _node, 50, _type), Rel(4, 50, _node, _type), Rel(5, _node, 50, _type2), Rel(6, _node, _node, _type), Rel(7, _node, 52, _type));

            // when
            cursor.Init(_node, RelationshipReferenceEncoding.encodeForTxStateFiltering(_relationship), read);

            // then
            AssertRelationships(cursor, 100, 3, 7, 102, 104);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void emptyStoreLoopsOfType()
        public virtual void EmptyStoreLoopsOfType()
        {
            // given
            StorageRelationshipTraversalCursor storeCursor = EmptyStoreCursor();

            DefaultRelationshipTraversalCursor cursor = new DefaultRelationshipTraversalCursor(_pool, storeCursor);
            Read read = TxState(Rel(3, _node, 50, _type), Rel(2, _node, _node, _type), Rel(5, 50, _node, _type2), Rel(6, _node, _node, _type), Rel(7, 56, _node, _type), Rel(8, _node, 52, _type));

            // when
            cursor.Init(_node, RelationshipReferenceEncoding.encodeNoLoopRels(_type), read);

            // then
            AssertRelationships(cursor, 2, 6);
        }
        internal virtual void Init(long nodeReference, long reference, Read read)
        {
            /* There are 5 different ways a relationship traversal cursor can be initialized:
             *
             * 1. From a batched group in a detached way. This happens when the user manually retrieves the relationships
             *    references from the group cursor and passes it to this method and if the group cursor was based on having
             *    batched all the different types in the single (mixed) chain of relationships.
             *    In this case we should pass a reference marked with some flag to the first relationship in the chain that
             *    has the type of the current group in the group cursor. The traversal cursor then needs to read the type
             *    from that first record and use that type as a filter for when reading the rest of the chain.
             *    - NOTE: we probably have to do the same sort of filtering for direction - so we need a flag for that too.
             *
             * 2. From a batched group in a DIRECT way. This happens when the traversal cursor is initialized directly from
             *    the group cursor, in this case we can simply initialize the traversal cursor with the buffered state from
             *    the group cursor, so this method here does not have to be involved, and things become pretty simple.
             *
             * 3. Traversing all relationships - regardless of type - of a node that has grouped relationships. In this case
             *    the traversal cursor needs to traverse through the group records in order to get to the actual
             *    relationships. The initialization of the cursor (through this here method) should be with a FLAGGED
             *    reference to the (first) group record.
             *
             * 4. Traversing a single chain - this is what happens in the cases when
             *    a) Traversing all relationships of a node without grouped relationships.
             *    b) Traversing the relationships of a particular group of a node with grouped relationships.
             *
             * 5. There are no relationships - i.e. passing in NO_ID to this method.
             *
             * This means that we need reference encodings (flags) for cases: 1, 3, 4, 5
             */

            RelationshipReferenceEncoding encoding = RelationshipReferenceEncoding.parseEncoding(reference);

            switch (encoding.innerEnumValue)
            {
            case Org.Neo4j.Kernel.Impl.Newapi.RelationshipReferenceEncoding.InnerEnum.NONE:
            case Org.Neo4j.Kernel.Impl.Newapi.RelationshipReferenceEncoding.InnerEnum.GROUP:
                StoreCursor.init(nodeReference, reference);
                InitFiltering(FilterState.None, false);
                break;

            case Org.Neo4j.Kernel.Impl.Newapi.RelationshipReferenceEncoding.InnerEnum.FILTER_TX_STATE:
                // The relationships in tx-state needs to be filtered according to the first relationship we discover,
                // but let's not have the store cursor bother with this detail.
                StoreCursor.init(nodeReference, clearEncoding(reference));
                InitFiltering(FilterState.NotInitialized, false);
                break;

            case Org.Neo4j.Kernel.Impl.Newapi.RelationshipReferenceEncoding.InnerEnum.FILTER:
                // The relationships needs to be filtered according to the first relationship we discover
                StoreCursor.init(nodeReference, clearEncoding(reference));
                InitFiltering(FilterState.NotInitialized, true);
                break;

            case Org.Neo4j.Kernel.Impl.Newapi.RelationshipReferenceEncoding.InnerEnum.NO_OUTGOING_OF_TYPE:               // nothing in store, but proceed to check tx-state changes
                StoreCursor.init(nodeReference, NO_ID);
                InitFiltering(FilterState.fromRelationshipDirection(OUTGOING), false);
                this._filterType = ( int )clearEncoding(reference);
                break;

            case Org.Neo4j.Kernel.Impl.Newapi.RelationshipReferenceEncoding.InnerEnum.NO_INCOMING_OF_TYPE:               // nothing in store, but proceed to check tx-state changes
                StoreCursor.init(nodeReference, NO_ID);
                InitFiltering(FilterState.fromRelationshipDirection(INCOMING), false);
                this._filterType = ( int )clearEncoding(reference);
                break;

            case Org.Neo4j.Kernel.Impl.Newapi.RelationshipReferenceEncoding.InnerEnum.NO_LOOP_OF_TYPE:               // nothing in store, but proceed to check tx-state changes
                StoreCursor.init(nodeReference, NO_ID);
                InitFiltering(FilterState.fromRelationshipDirection(LOOP), false);
                this._filterType = ( int )clearEncoding(reference);
                break;

            default:
                throw new System.InvalidOperationException("Unknown encoding " + encoding);
            }

            Init(read);
            this._addedRelationships = ImmutableEmptyLongIterator.INSTANCE;
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void regularDenseTraversalWithTxState()
        public virtual void RegularDenseTraversalWithTxState()
        {
            RegularTraversalWithTxState(RelationshipReferenceEncoding.encodeGroup(_relationshipGroup));
        }