Пример #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.RelationshipGroupRecord source, org.neo4j.kernel.impl.store.record.RelationshipGroupRecord target, long poisonedReference) throws java.io.IOException
        private void VerifyRecordsWithPoisonedReference(RelationshipGroupRecord source, RelationshipGroupRecord target, long poisonedReference)
        {
            bool         nullPoisoned        = poisonedReference == BaseHighLimitRecordFormat.Null;
            int          differentReferences = 5;
            IList <long> references          = BuildReferenceList(differentReferences, poisonedReference);

            for (int i = 0; i < differentReferences; i++)
            {
                _pageCursor.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, 0, iterator.next(), iterator.next(), iterator.next(), iterator.next(), iterator.next());

                WriteReadRecord(source, target);

                if (nullPoisoned)
                {
                    assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
                }
                else
                {
                    assertFalse("Record should use variable length reference format.", target.UseFixedReferences);
                }
                VerifySame(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 readWriteFixedReferencesRecord() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReadWriteFixedReferencesRecord()
        {
            RelationshipGroupRecord source = new RelationshipGroupRecord(1);
            RelationshipGroupRecord target = new RelationshipGroupRecord(1);

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

            WriteReadRecord(source, target);

            assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
            VerifySame(source, target);
        }
Пример #3
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()
        {
            RelationshipGroupRecord source = new RelationshipGroupRecord(1);
            RelationshipGroupRecord target = new RelationshipGroupRecord(1);

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

            WriteReadRecord(source, target, RelationshipGroupRecordFormat.FixedFormatRecordSize);

            assertTrue("Record should use fixed reference if can fit in format record.", target.UseFixedReferences);
            VerifySame(source, target);
        }
Пример #4
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()
        {
            RelationshipGroupRecord source = new RelationshipGroupRecord(1);
            RelationshipGroupRecord target = new RelationshipGroupRecord(1);

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

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

            assertFalse("Record should use variable length reference if format record is too small.", target.UseFixedReferences);
            VerifySame(source, target);
        }
Пример #5
0
        public static RelationshipGroupRecord RelGroup(long id, params System.Action <RelationshipGroupRecord>[] modifiers)
        {
            RelationshipGroupRecord record = new RelationshipGroupRecord(id);

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

            return(record);
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDefragmentRelationshipGroupsWhenSomeDense()
        public virtual void ShouldDefragmentRelationshipGroupsWhenSomeDense()
        {
            // GIVEN some nodes which has their groups scattered
            int nodeCount             = 100;
            int relationshipTypeCount = 50;
            RecordStore <RelationshipGroupRecord> groupStore = _stores.TemporaryRelationshipGroupStore;
            RelationshipGroupRecord  groupRecord             = groupStore.NewRecord();
            RecordStore <NodeRecord> nodeStore = _stores.NodeStore;
            NodeRecord nodeRecord       = nodeStore.NewRecord();
            long       cursor           = 0;
            BitArray   initializedNodes = new BitArray();

            for (int typeId = relationshipTypeCount - 1; typeId >= 0; typeId--)
            {
                for (int nodeId = 0; nodeId < nodeCount; nodeId++, cursor++)
                {
                    // Reasoning behind this thing is that we want to have roughly 10% of the nodes dense
                    // right from the beginning and then some stray dense nodes coming into this in the
                    // middle of the type range somewhere
                    double comparison = typeId == 0 || initializedNodes.Get(nodeId) ? 0.1 : 0.001;

                    if (_random.NextDouble() < comparison)
                    {
                        // next doesn't matter at all, as we're rewriting it anyway
                        // firstOut/In/Loop we could use in verification phase later
                        groupRecord.Initialize(true, typeId, cursor, cursor + 1, cursor + 2, nodeId, 4);
                        groupRecord.Id = groupStore.nextId();
                        groupStore.UpdateRecord(groupRecord);

                        if (!initializedNodes.Get(nodeId))
                        {
                            nodeRecord.Initialize(true, -1, true, groupRecord.Id, 0);
                            nodeRecord.Id = nodeId;
                            nodeStore.UpdateRecord(nodeRecord);
                            nodeStore.HighestPossibleIdInUse = nodeId;
                            initializedNodes.Set(nodeId, true);
                        }
                    }
                }
            }

            // WHEN
            Defrag(nodeCount, groupStore);

            // THEN all groups should sit sequentially in the store
            VerifyGroupsAreSequentiallyOrderedByNode();
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDefragmentRelationshipGroupsWhenAllDense()
        public virtual void ShouldDefragmentRelationshipGroupsWhenAllDense()
        {
            // GIVEN some nodes which has their groups scattered
            int nodeCount             = 100;
            int relationshipTypeCount = 50;
            RecordStore <RelationshipGroupRecord> groupStore = _stores.TemporaryRelationshipGroupStore;
            RelationshipGroupRecord  groupRecord             = groupStore.NewRecord();
            RecordStore <NodeRecord> nodeStore = _stores.NodeStore;
            NodeRecord nodeRecord = nodeStore.NewRecord();
            long       cursor     = 0;

            for (int typeId = relationshipTypeCount - 1; typeId >= 0; typeId--)
            {
                for (long nodeId = 0; nodeId < nodeCount; nodeId++, cursor++)
                {
                    // next doesn't matter at all, as we're rewriting it anyway
                    // firstOut/In/Loop we could use in verification phase later
                    groupRecord.Initialize(true, typeId, cursor, cursor + 1, cursor + 2, nodeId, 4);
                    groupRecord.Id = groupStore.nextId();
                    groupStore.UpdateRecord(groupRecord);

                    if (typeId == 0)
                    {
                        // first round also create the nodes
                        nodeRecord.Initialize(true, -1, true, groupRecord.Id, 0);
                        nodeRecord.Id = nodeId;
                        nodeStore.UpdateRecord(nodeRecord);
                        nodeStore.HighestPossibleIdInUse = nodeId;
                    }
                }
            }

            // WHEN
            Defrag(nodeCount, groupStore);

            // THEN all groups should sit sequentially in the store
            VerifyGroupsAreSequentiallyOrderedByNode();
        }