Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsLabelIds()
        public virtual void VisitsLabelIds()
        {
            // GIVEN
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));

            _graph.createNode(label("Person"));
            _graph.createNode(label("Party"));
            _graph.createNode(label("Animal"));
            int personLabelId;
            int partyLabelId;
            int animalLabelId;

            KernelTransaction ktx       = ktx();
            TokenRead         tokenRead = ktx.TokenRead();

            personLabelId = tokenRead.NodeLabel("Person");
            partyLabelId  = tokenRead.NodeLabel("Party");
            animalLabelId = tokenRead.NodeLabel("Animal");

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitLabel(personLabelId, "Person");
            verify(visitor).visitLabel(partyLabelId, "Party");
            verify(visitor).visitLabel(animalLabelId, "Animal");
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addingUniqueNodeWithUnrelatedValueShouldNotAffectLookup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AddingUniqueNodeWithUnrelatedValueShouldNotAffectLookup()
        {
            // given
            CreateConstraint("Person", "id");

            long ourNode;
            {
                Transaction transaction = NewTransaction(AnonymousContext.writeToken());
                ourNode = CreateLabeledNode(transaction, "Person", "id", 1);
                Commit();
            }

            Transaction    transaction = NewTransaction(AnonymousContext.writeToken());
            TokenRead      tokenRead   = transaction.TokenRead();
            int            person      = tokenRead.NodeLabel("Person");
            int            propId      = tokenRead.PropertyKey("id");
            IndexReference idx         = transaction.SchemaRead().index(person, propId);

            // when
            CreateLabeledNode(transaction, "Person", "id", 2);

            // then I should find the original node
            assertThat(transaction.DataRead().lockingNodeUniqueIndexSeek(idx, exact(propId, Values.of(1))), equalTo(ourNode));
            Commit();
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitsRelationshipTypeIds()
        public virtual void VisitsRelationshipTypeIds()
        {
            // GIVEN
            DbStructureVisitor visitor = mock(typeof(DbStructureVisitor));
            Node lhs = _graph.createNode();
            Node rhs = _graph.createNode();

            lhs.CreateRelationshipTo(rhs, withName("KNOWS"));
            lhs.CreateRelationshipTo(rhs, withName("LOVES"));
            lhs.CreateRelationshipTo(rhs, withName("FAWNS_AT"));
            int knowsId;
            int lovesId;
            int fawnsAtId;
            KernelTransaction ktx = ktx();

            TokenRead tokenRead = ktx.TokenRead();

            knowsId   = tokenRead.RelationshipType("KNOWS");
            lovesId   = tokenRead.RelationshipType("LOVES");
            fawnsAtId = tokenRead.RelationshipType("FAWNS_AT");

            // WHEN
            Accept(visitor);

            // THEN
            verify(visitor).visitRelationshipType(knowsId, "KNOWS");
            verify(visitor).visitRelationshipType(lovesId, "LOVES");
            verify(visitor).visitRelationshipType(fawnsAtId, "FAWNS_AT");
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            KernelTransaction transaction = mock(typeof(KernelTransaction));

            _tokenRead  = mock(typeof(TokenRead));
            _schemaRead = mock(typeof(SchemaRead));
            _procedure  = new IndexProcedures(transaction, null);

            when(transaction.TokenRead()).thenReturn(_tokenRead);
            when(transaction.SchemaRead()).thenReturn(_schemaRead);
            _indexingService = mock(typeof(IndexingService));
            _procedure       = new IndexProcedures(transaction, _indexingService);
        }
Esempio n. 5
0
        /// <param name="start"> the label of the start node of relationships to get the number of, or {@code null} for "any". </param>
        /// <param name="type">  the type of the relationships to get the number of, or {@code null} for "any". </param>
        /// <param name="end">   the label of the end node of relationships to get the number of, or {@code null} for "any". </param>
        private long CountsForRelationship(Label start, RelationshipType type, Label end)
        {
            KernelTransaction ktx = _ktxSupplier.get();

            using (Statement ignore = ktx.AcquireStatement())
            {
                TokenRead tokenRead = ktx.TokenRead();
                int       startId;
                int       typeId;
                int       endId;
                // start
                if (start == null)
                {
                    startId = [email protected]_Fields.ANY_LABEL;
                }
                else
                {
                    if ([email protected]_Fields.NO_TOKEN == (startId = tokenRead.NodeLabel(start.Name())))
                    {
                        return(0);
                    }
                }
                // type
                if (type == null)
                {
                    typeId = [email protected]_Fields.ANY_RELATIONSHIP_TYPE;
                }
                else
                {
                    if ([email protected]_Fields.NO_TOKEN == (typeId = tokenRead.RelationshipType(type.Name())))
                    {
                        return(0);
                    }
                }
                // end
                if (end == null)
                {
                    endId = [email protected]_Fields.ANY_LABEL;
                }
                else
                {
                    if ([email protected]_Fields.NO_TOKEN == (endId = tokenRead.NodeLabel(end.Name())))
                    {
                        return(0);
                    }
                }
                return(ktx.DataRead().countsForRelationship(startId, typeId, endId));
            }
        }
Esempio n. 6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void lockNodeUsingUniqueIndexSeek(org.neo4j.kernel.internal.GraphDatabaseAPI database, org.neo4j.graphdb.Label label, String nameProperty) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private static void LockNodeUsingUniqueIndexSeek(GraphDatabaseAPI database, Label label, string nameProperty)
        {
            using (Transaction transaction = database.BeginTx())
            {
                ThreadToStatementContextBridge contextBridge = database.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge));
                KernelTransaction kernelTransaction          = contextBridge.GetKernelTransactionBoundToThisThread(true);
                TokenRead         tokenRead = kernelTransaction.TokenRead();
                Read dataRead = kernelTransaction.DataRead();

                int            labelId        = tokenRead.NodeLabel(label.Name());
                int            propertyId     = tokenRead.PropertyKey(nameProperty);
                IndexReference indexReference = kernelTransaction.SchemaRead().index(labelId, propertyId);
                dataRead.LockingNodeUniqueIndexSeek(indexReference, IndexQuery.ExactPredicate.exact(propertyId, "value"));
                transaction.Success();
            }
        }
Esempio n. 7
0
 public SilentTokenNameLookup(TokenRead tokenRead)
 {
     this._tokenRead = tokenRead;
 }