示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void verifyRecordsWithPoisonedReference(org.neo4j.kernel.impl.store.record.RelationshipRecord source, org.neo4j.kernel.impl.store.record.RelationshipRecord target, long poisonedReference, int type) throws java.io.IOException
        private void VerifyRecordsWithPoisonedReference(RelationshipRecord source, RelationshipRecord target, long poisonedReference, int type)
        {
            bool nullPoison = poisonedReference == NULL;
            // first and second node can't be empty references so excluding them in case if poisoned reference is null
            int          differentReferences = nullPoison ? 5 : 7;
            IList <long> references          = BuildReferenceList(differentReferences, poisonedReference);

            for (int i = 0; i < differentReferences; i++)
            {
                cursor.Offset = 0;
                IEnumerator <long> iterator = references.GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                source.Initialize(true, iterator.next(), nullPoison ? RandomFixedReference() : iterator.next(), nullPoison ? RandomFixedReference() : iterator.next(), type, iterator.next(), iterator.next(), iterator.next(), iterator.next(), true, true);

                WriteReadRecord(source, target);

                if (nullPoison)
                {
                    assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
                }
                else
                {
                    assertFalse("Record should use variable length reference format.", target.UseFixedReferences);
                }
                VerifySameReferences(source, target);
                Collections.rotate(references, 1);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useFixedRecordFormatWhenAtLeastOneOfTheReferencesIsMissing() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UseFixedRecordFormatWhenAtLeastOneOfTheReferencesIsMissing()
        {
            RelationshipRecord source = new RelationshipRecord(1);
            RelationshipRecord target = new RelationshipRecord(1);

            VerifyRecordsWithPoisonedReference(source, target, NULL, RandomShortType());
        }
示例#3
0
        private void DecrementTotalRelationshipCount(long nodeId, RelationshipRecord rel, long firstRelId, RecordAccess <RelationshipRecord, Void> relRecords, ResourceLocker locks)
        {
            if (firstRelId == Record.NO_PREV_RELATIONSHIP.intValue())
            {
                return;
            }
            bool firstInChain = RelIsFirstInChain(nodeId, rel);

            if (!firstInChain)
            {
                locks.AcquireExclusive(LockTracer.NONE, ResourceTypes.RELATIONSHIP, firstRelId);
            }
            RelationshipRecord firstRel = relRecords.GetOrLoad(firstRelId, null).forChangingLinkage();

            if (nodeId == firstRel.FirstNode)
            {
                firstRel.FirstPrevRel      = firstInChain ? relCount(nodeId, rel) - 1 : relCount(nodeId, firstRel) - 1;
                firstRel.FirstInFirstChain = true;
            }
            if (nodeId == firstRel.SecondNode)
            {
                firstRel.SecondPrevRel      = firstInChain ? relCount(nodeId, rel) - 1 : relCount(nodeId, firstRel) - 1;
                firstRel.FirstInSecondChain = true;
            }
        }
示例#4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void checkRecord(RelationshipRecordFormat format, int recordSize, org.neo4j.io.pagecache.StubPageCursor cursor, long recordId, int recordOffset, org.neo4j.kernel.impl.store.record.RelationshipRecord record) throws java.io.IOException
        private void CheckRecord(RelationshipRecordFormat format, int recordSize, StubPageCursor cursor, long recordId, int recordOffset, RelationshipRecord record)
        {
            format.Write(record, cursor, recordSize);

            RelationshipRecord recordFromStore = format.NewRecord();

            recordFromStore.Id = recordId;
            ResetCursor(cursor, recordOffset);
            format.Read(recordFromStore, cursor, RecordLoad.NORMAL, recordSize);

            // records should be the same
            VerifySameReferences(record, recordFromStore);

            // now lets try to read same data into a record with different id - we should get different absolute references
            ResetCursor(cursor, recordOffset);
            RelationshipRecord recordWithOtherId = format.NewRecord();

            recordWithOtherId.Id = 1L;
            format.Read(recordWithOtherId, cursor, RecordLoad.NORMAL, recordSize);

            assertNotEquals(record.FirstNextRel, recordWithOtherId.FirstNextRel);
            assertNotEquals(record.FirstPrevRel, recordWithOtherId.FirstPrevRel);
            assertNotEquals(record.SecondNextRel, recordWithOtherId.SecondNextRel);
            assertNotEquals(record.SecondPrevRel, recordWithOtherId.SecondPrevRel);
        }
示例#5
0
 private void DisconnectRelationship(RelationshipRecord rel, RecordAccessSet recordChangeSet, ResourceLocker locks)
 {
     Disconnect(rel, RelationshipConnection.StartNext, recordChangeSet.RelRecords, locks);
     Disconnect(rel, RelationshipConnection.StartPrev, recordChangeSet.RelRecords, locks);
     Disconnect(rel, RelationshipConnection.EndNext, recordChangeSet.RelRecords, locks);
     Disconnect(rel, RelationshipConnection.EndPrev, recordChangeSet.RelRecords, locks);
 }
示例#6
0
        /*
         * This test acts as a test group for whoever uses BaseHighLimitRecordFormat base class,
         * the logic for marking both units as unused when deleting exists there.
         */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMarkBothUnitsAsUnusedWhenDeletingRecordWhichHasSecondaryUnit() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldMarkBothUnitsAsUnusedWhenDeletingRecordWhichHasSecondaryUnit()
        {
            // GIVEN a record which requires two units
            PagedFile storeFile = mock(typeof(PagedFile));

            when(storeFile.PageSize()).thenReturn(cursor.CurrentPageSize);
            long hugeValue            = 1L << 48;
            RelationshipRecord record = (new RelationshipRecord(5)).initialize(true, hugeValue + 1, hugeValue + 2, hugeValue + 3, 4, hugeValue + 5, hugeValue + 6, hugeValue + 7, hugeValue + 8, true, true);

            record.SecondaryUnitId       = 17;
            record.RequiresSecondaryUnit = true;
            cursor.Offset = offsetForId(record.Id, cursor.CurrentPageSize, _recordSize);
            _format.write(record, cursor, _recordSize);

            // WHEN deleting that record
            record.InUse  = false;
            cursor.Offset = offsetForId(record.Id, cursor.CurrentPageSize, _recordSize);
            _format.write(record, cursor, _recordSize);

            // THEN both units should have been marked as unused
            cursor.Offset = offsetForId(record.Id, cursor.CurrentPageSize, _recordSize);
            assertFalse(RecordInUse(cursor));
            cursor.Offset = offsetForId(record.SecondaryUnitId, cursor.CurrentPageSize, _recordSize);
            assertFalse(RecordInUse(cursor));
        }
示例#7
0
        private void Disconnect(RelationshipRecord rel, RelationshipConnection pointer, RecordAccess <RelationshipRecord, Void> relChanges, ResourceLocker locks)
        {
            long otherRelId = pointer.otherSide().get(rel);

            if (otherRelId == Record.NO_NEXT_RELATIONSHIP.intValue())
            {
                return;
            }

            locks.AcquireExclusive(LockTracer.NONE, ResourceTypes.RELATIONSHIP, otherRelId);
            RelationshipRecord otherRel = relChanges.GetOrLoad(otherRelId, null).forChangingLinkage();
            bool changed    = false;
            long newId      = pointer.get(rel);
            bool newIsFirst = pointer.isFirstInChain(rel);

            if (otherRel.FirstNode == pointer.compareNode(rel))
            {
                pointer.start().set(otherRel, newId, newIsFirst);
                changed = true;
            }
            if (otherRel.SecondNode == pointer.compareNode(rel))
            {
                pointer.end().set(otherRel, newId, newIsFirst);
                changed = true;
            }
            if (!changed)
            {
                throw new InvalidRecordException(otherRel + " don't match " + rel);
            }
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldContainFedRelationshipUpdate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldContainFedRelationshipUpdate()
        {
            OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(_nodeStore, _relationshipStore, _indexingService, _propertyPhysicalToLogicalConverter);

            long relId = 0;
            RelationshipRecord inUse    = GetRelationship(relId, true, ENTITY_TOKEN);
            Value propertyValue         = Values.of("hej");
            long  propertyId            = CreateRelationshipProperty(inUse, propertyValue, 1);
            RelationshipRecord notInUse = GetRelationship(relId, false, ENTITY_TOKEN);

            _relationshipStore.updateRecord(inUse);

            Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
            PropertyRecord propertyBlocks = new PropertyRecord(propertyId);

            propertyBlocks.RelId = relId;
            Command.PropertyCommand propertyCommand = new Command.PropertyCommand(_recordAccess.getIfLoaded(propertyId).forReadingData(), propertyBlocks);

            StoreIndexDescriptor indexDescriptor = forSchema(multiToken(_entityTokens, RELATIONSHIP, 1, 4, 6), EMPTY.ProviderDescriptor).withId(0);

            _indexingService.createIndexes(indexDescriptor);
            _indexingService.getIndexProxy(indexDescriptor.Schema()).awaitStoreScanCompleted(0, MILLISECONDS);

            onlineIndexUpdates.Feed(NodeGroup(null), RelationshipGroup(relationshipCommand, propertyCommand));
            assertTrue(onlineIndexUpdates.HasUpdates());
            IEnumerator <IndexEntryUpdate <SchemaDescriptor> > iterator = onlineIndexUpdates.GetEnumerator();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(iterator.next(), IndexEntryUpdate.remove(relId, indexDescriptor, propertyValue, null, null));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(iterator.hasNext());
        }
示例#9
0
        private void PrepareDbWithDeletedRelationshipPartOfTheChain()
        {
            GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(_testDirectory.databaseDir()).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig("dbms.backup.enabled", "false").newGraphDatabase();

            try
            {
                RelationshipType relationshipType = RelationshipType.withName("testRelationshipType");
                using (Transaction tx = Db.beginTx())
                {
                    Node node1 = set(Db.createNode());
                    Node node2 = set(Db.createNode(), property("key", "value"));
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    tx.Success();
                }

                RecordStorageEngine recordStorageEngine = Db.DependencyResolver.resolveDependency(typeof(RecordStorageEngine));

                NeoStores          neoStores          = recordStorageEngine.TestAccessNeoStores();
                RelationshipStore  relationshipStore  = neoStores.RelationshipStore;
                RelationshipRecord relationshipRecord = new RelationshipRecord(-1);
                RelationshipRecord record             = relationshipStore.GetRecord(4, relationshipRecord, RecordLoad.FORCE);
                record.InUse = false;
                relationshipStore.UpdateRecord(relationshipRecord);
            }
            finally
            {
                Db.shutdown();
            }
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useVariableLengthFormatWhenAtLeastOneOfTheReferencesIsTooBig() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UseVariableLengthFormatWhenAtLeastOneOfTheReferencesIsTooBig()
        {
            RelationshipRecord source = new RelationshipRecord(1);
            RelationshipRecord target = new RelationshipRecord(1);

            VerifyRecordsWithPoisonedReference(source, target, 1L << (sizeof(int) * 8) + 5, RandomType());
        }
示例#11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeReadRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord source, org.neo4j.kernel.impl.store.record.RelationshipRecord target, int recordSize) throws java.io.IOException
        private void WriteReadRecord(RelationshipRecord source, RelationshipRecord target, int recordSize)
        {
            _format.prepare(source, recordSize, _idSequence);
            _format.write(source, cursor, recordSize);
            cursor.Offset = 0;
            _format.read(target, cursor, RecordLoad.NORMAL, recordSize);
        }
        private void UnUseRecord(long recordId)
        {
            RelationshipStore  relationshipStore  = _neoStores.RelationshipStore;
            RelationshipRecord relationshipRecord = relationshipStore.GetRecord(recordId, new RelationshipRecord(-1), RecordLoad.FORCE);

            relationshipRecord.InUse = false;
            relationshipStore.UpdateRecord(relationshipRecord);
        }
示例#13
0
 private RelationshipRecord LoadRelationship(long relationshipId)
 {
     if (_relationshipRecord == null)
     {
         _relationshipRecord = _relationshipStore.newRecord();
     }
     _relationshipStore.getRecord(relationshipId, _relationshipRecord, RecordLoad.NORMAL);
     return(_relationshipRecord);
 }
示例#14
0
        /// <summary>
        /// Deletes a relationship by its id, returning its properties which are now
        /// removed. It is assumed that the nodes it connects have already been
        /// deleted in this
        /// transaction.
        /// </summary>
        /// <param name="id"> The id of the relationship to delete. </param>
        internal virtual void RelDelete(long id, RecordAccessSet recordChanges, ResourceLocker locks)
        {
            RelationshipRecord record = recordChanges.RelRecords.getOrLoad(id, null).forChangingLinkage();

            _propertyChainDeleter.deletePropertyChain(record, recordChanges.PropertyRecords);
            DisconnectRelationship(record, recordChanges, locks);
            UpdateNodesForDeletedRelationship(record, recordChanges, locks);
            record.InUse = false;
        }
示例#15
0
        private void ConnectRelationshipToDenseNode(NodeRecord node, RelationshipRecord rel, RecordAccess <RelationshipRecord, Void> relRecords, RecordAccess <RelationshipGroupRecord, int> relGroupRecords, ResourceLocker locks)
        {
            RelationshipGroupRecord group = _relGroupGetter.getOrCreateRelationshipGroup(node, rel.Type, relGroupRecords).forChangingData();
            DirectionWrapper        dir   = DirectionIdentifier.wrapDirection(rel, node);
            long nextRel = dir.getNextRel(group);

            SetCorrectNextRel(node, rel, nextRel);
            Connect(node.Id, nextRel, rel, relRecords, locks);
            dir.setNextRel(group, rel.Id);
        }
示例#16
0
 internal virtual void RelationshipFull(RelationshipRecord record, long reference, PageCursor pageCursor)
 {
     // We need to load forcefully for relationship chain traversal since otherwise we cannot
     // traverse over relationship records which have been concurrently deleted
     // (flagged as inUse = false).
     // see
     //      org.neo4j.kernel.impl.store.RelationshipChainPointerChasingTest
     //      org.neo4j.kernel.impl.locking.RelationshipCreateDeleteIT
     RelationshipStore.getRecordByCursor(reference, record, RecordLoad.FORCE, pageCursor);
 }
示例#17
0
        public static RelationshipCommand CreateRelationship(long id, long startNode, long endNode, int type)
        {
            RelationshipRecord before = new RelationshipRecord(id);

            before.InUse = false;
            RelationshipRecord after = new RelationshipRecord(id, startNode, endNode, type);

            after.InUse = true;
            after.SetCreated();
            return(new RelationshipCommand(before, after));
        }
示例#18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public <EXCEPTION extends Exception> void relationshipVisit(long relationshipId, org.neo4j.storageengine.api.RelationshipVisitor<EXCEPTION> relationshipVisitor) throws org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException, EXCEPTION
        public override void RelationshipVisit <EXCEPTION>(long relationshipId, RelationshipVisitor <EXCEPTION> relationshipVisitor) where EXCEPTION : Exception
        {
            // TODO Please don't create a record for this, it's ridiculous
            RelationshipRecord record = _relationshipStore.getRecord(relationshipId, _relationshipStore.newRecord(), CHECK);

            if (!record.InUse())
            {
                throw new EntityNotFoundException(EntityType.RELATIONSHIP, relationshipId);
            }
            relationshipVisitor.Visit(relationshipId, record.Type, record.FirstNode, record.SecondNode);
        }
示例#19
0
 private void SetCorrectNextRel(NodeRecord node, RelationshipRecord rel, long nextRel)
 {
     if (node.Id == rel.FirstNode)
     {
         rel.FirstNextRel = nextRel;
     }
     if (node.Id == rel.SecondNode)
     {
         rel.SecondNextRel = nextRel;
     }
 }
示例#20
0
 private void VerifySameReferences(RelationshipRecord record, RelationshipRecord recordFromStore)
 {
     assertEquals("Types should be equal.", record.Type, recordFromStore.Type);
     assertEquals("First Next references should be equal.", record.FirstNextRel, recordFromStore.FirstNextRel);
     assertEquals("First Node references should be equal.", record.FirstNode, recordFromStore.FirstNode);
     assertEquals("First Prev Rel references should be equal.", record.FirstPrevRel, recordFromStore.FirstPrevRel);
     assertEquals("Second Next Rel references should be equal.", record.SecondNextRel, recordFromStore.SecondNextRel);
     assertEquals("Second Node references should be equal.", record.SecondNode, recordFromStore.SecondNode);
     assertEquals("Second Prev Rel references should be equal.", record.SecondPrevRel, recordFromStore.SecondPrevRel);
     assertEquals("Next Prop references should be equal.", record.NextProp, recordFromStore.NextProp);
 }
示例#21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readWriteFixedReferencesRecord() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReadWriteFixedReferencesRecord()
        {
            RelationshipRecord source = new RelationshipRecord(1);
            RelationshipRecord target = new RelationshipRecord(1);

            source.Initialize(true, RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), RandomShortType(), RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), true, true);

            WriteReadRecord(source, target);

            assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#22
0
        public static DirectionWrapper WrapDirection(RelationshipRecord rel, NodeRecord startNode)
        {
            bool isOut = rel.FirstNode == startNode.Id;
            bool isIn  = rel.SecondNode == startNode.Id;

            Debug.Assert(isOut | isIn);
            if (isOut & isIn)
            {
                return(DirectionWrapper.BOTH);
            }
            return(isOut ? DirectionWrapper.OUTGOING : DirectionWrapper.INCOMING);
        }
示例#23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UseFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord()
        {
            RelationshipRecord source = new RelationshipRecord(1);
            RelationshipRecord target = new RelationshipRecord(1);

            source.Initialize(true, RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), RandomShortType(), RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), true, true);

            WriteReadRecord(source, target, RelationshipRecordFormat.FixedFormatRecordSize);

            assertTrue("Record should use fixed reference if can fit in format record.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#24
0
 private static RelationshipConnection RelChain(RelationshipRecord rel, long nodeId)
 {
     if (rel.FirstNode == nodeId)
     {
         return(RelationshipConnection.StartNext);
     }
     if (rel.SecondNode == nodeId)
     {
         return(RelationshipConnection.EndNext);
     }
     throw new Exception(nodeId + " neither start not end node in " + rel);
 }
示例#25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useVariableLengthFormatWhenTypeIsTooBig() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UseVariableLengthFormatWhenTypeIsTooBig()
        {
            RelationshipRecord source = new RelationshipRecord(1);
            RelationshipRecord target = new RelationshipRecord(1);

            source.Initialize(true, RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), 1 << 16, RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), true, true);

            WriteReadRecord(source, target);

            assertFalse("Record should use variable length format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#26
0
        public static RelationshipRecord Rel(long id, params System.Action <RelationshipRecord>[] modifiers)
        {
            RelationshipRecord record = new RelationshipRecord(id);

            record.Initialize(true, Record.NO_NEXT_PROPERTY.intValue(), -1, -1, 0, Record.NO_PREV_RELATIONSHIP.longValue(), Record.NO_NEXT_RELATIONSHIP.longValue(), Record.NO_PREV_RELATIONSHIP.longValue(), Record.NO_NEXT_RELATIONSHIP.longValue(), true, true);
            foreach (System.Action <RelationshipRecord> modifier in modifiers)
            {
                modifier(record);
            }

            return(record);
        }
示例#27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useFixedReferenceFormatWhenTypeIsSmallEnough() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UseFixedReferenceFormatWhenTypeIsSmallEnough()
        {
            RelationshipRecord source = new RelationshipRecord(1);
            RelationshipRecord target = new RelationshipRecord(1);

            source.Initialize(true, RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), (1 << 16) - 1, RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), true, true);

            WriteReadRecord(source, target);

            assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useVariableLengthFormatWhenRecordSizeIsTooSmall() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UseVariableLengthFormatWhenRecordSizeIsTooSmall()
        {
            RelationshipRecord source = new RelationshipRecord(1);
            RelationshipRecord target = new RelationshipRecord(1);

            source.Initialize(true, RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), RandomType(), RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), RandomFixedReference(), true, true);

            WriteReadRecord(source, target, RelationshipRecordFormat.FixedFormatRecordSize - 1);

            assertFalse("Record should use variable length reference if format record is too small.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#29
0
        /// <summary>
        /// Creates a relationship with the given id, from the nodes identified by id
        /// and of type typeId
        /// </summary>
        /// <param name="id"> The id of the relationship to create. </param>
        /// <param name="type"> The id of the relationship type this relationship will
        ///            have. </param>
        /// <param name="firstNodeId"> The id of the start node. </param>
        /// <param name="secondNodeId"> The id of the end node. </param>
        public virtual void RelationshipCreate(long id, int type, long firstNodeId, long secondNodeId, RecordAccessSet recordChangeSet, ResourceLocker locks)
        {
            // TODO could be unnecessary to mark as changed here already, dense nodes may not need to change
            NodeRecord firstNode  = recordChangeSet.NodeRecords.getOrLoad(firstNodeId, null).forChangingLinkage();
            NodeRecord secondNode = recordChangeSet.NodeRecords.getOrLoad(secondNodeId, null).forChangingLinkage();

            ConvertNodeToDenseIfNecessary(firstNode, recordChangeSet.RelRecords, recordChangeSet.RelGroupRecords, locks);
            ConvertNodeToDenseIfNecessary(secondNode, recordChangeSet.RelRecords, recordChangeSet.RelGroupRecords, locks);
            RelationshipRecord record = recordChangeSet.RelRecords.create(id, null).forChangingLinkage();

            record.SetLinks(firstNodeId, secondNodeId, type);
            record.InUse = true;
            record.SetCreated();
            ConnectRelationship(firstNode, secondNode, record, recordChangeSet.RelRecords, recordChangeSet.RelGroupRecords, locks);
        }
示例#30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void writeAndReadRecordWithRelativeReferences() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void WriteAndReadRecordWithRelativeReferences()
        {
            long recordId     = 0xF1F1F1F1F1F1L;
            int  recordOffset = cursor.Offset;

            RelationshipRecord record             = CreateCompactRecord(_format, recordId, false, false);
            RelationshipRecord firstInSecondChain = CreateCompactRecord(_format, recordId, false, true);
            RelationshipRecord firstInFirstChain  = CreateCompactRecord(_format, recordId, true, false);
            RelationshipRecord firstInBothChains  = CreateCompactRecord(_format, recordId, true, true);

            CheckRecord(_format, _recordSize, cursor, recordId, recordOffset, record);
            CheckRecord(_format, _recordSize, cursor, recordId, recordOffset, firstInSecondChain);
            CheckRecord(_format, _recordSize, cursor, recordId, recordOffset, firstInFirstChain);
            CheckRecord(_format, _recordSize, cursor, recordId, recordOffset, firstInBothChains);
        }