Esempio n. 1
0
        private void MarkRandomRelsInGroupNotInUse(long nodeId, TestRelType type)
        {
            NodeRecord node = GetNodeRecord(nodeId);

            assertTrue(node.Dense);

            long relGroupId = node.NextRel;

            while (relGroupId != NO_NEXT_RELATIONSHIP.intValue())
            {
                RelationshipGroupRecord relGroup = GetRelGroupRecord(relGroupId);

                if (type == RelTypeForId(relGroup.Type))
                {
                    MarkRandomRelsInChainNotInUse(relGroup.FirstOut);
                    MarkRandomRelsInChainNotInUse(relGroup.FirstIn);
                    MarkRandomRelsInChainNotInUse(relGroup.FirstLoop);
                    return;
                }

                relGroupId = relGroup.Next;
            }

            throw new System.InvalidOperationException("No relationship group with type: " + type + " found");
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCombineProperFiveByteLabelField() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCombineProperFiveByteLabelField()
        {
            // GIVEN
            // -- a store
            EphemeralFileSystemAbstraction fs = _efs.get();

            _nodeStore = NewNodeStore(fs);

            // -- a record with the msb carrying a negative value
            long       nodeId = 0;
            long       labels = 0x8000000001L;
            NodeRecord record = new NodeRecord(nodeId, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue());

            record.InUse = true;
            record.SetLabelField(labels, Collections.emptyList());
            _nodeStore.updateRecord(record);

            // WHEN
            // -- reading that record back
            NodeRecord readRecord = _nodeStore.getRecord(nodeId, _nodeStore.newRecord(), NORMAL);

            // THEN
            // -- the label field must be the same
            assertEquals(labels, readRecord.LabelField);
        }
        private NodeCommand Node(long nodeId)
        {
            NodeRecord after = new NodeRecord(nodeId, true, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue(), 0);

            NodeLabelsField.parseLabelsField(after).add(1, null, null);

            return(new NodeCommand(new NodeRecord(nodeId), after));
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldKeepRecordLightWhenSettingLabelFieldWithoutDynamicRecords()
        public virtual void ShouldKeepRecordLightWhenSettingLabelFieldWithoutDynamicRecords()
        {
            // GIVEN
            NodeRecord record = new NodeRecord(0, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue());

            // WHEN
            record.SetLabelField(0, Collections.emptyList());

            // THEN
            assertTrue(record.Light);
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMarkRecordHeavyWhenSettingLabelFieldWithDynamicRecords()
        public virtual void ShouldMarkRecordHeavyWhenSettingLabelFieldWithDynamicRecords()
        {
            // GIVEN
            NodeRecord record = new NodeRecord(0, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue());

            // WHEN
            DynamicRecord dynamicRecord = new DynamicRecord(1);

            record.SetLabelField(0x8000000001L, asList(dynamicRecord));

            // THEN
            assertFalse(record.Light);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleDenseNodeWithNoRelationships()
        public virtual void ShouldHandleDenseNodeWithNoRelationships()
        {
            // This can actually happen, since we upgrade sparse node --> dense node when creating relationships,
            // but we don't downgrade dense --> sparse when we delete relationships. So if we have a dense node
            // which no longer has relationships, there was this assumption that we could just call getRecord
            // on the NodeRecord#getNextRel() value. Although that value could actually be -1
            using (RecordRelationshipTraversalCursor cursor = NodeRelationshipCursor)
            {
                // WHEN
                cursor.Init(FIRST_OWNING_NODE, NO_NEXT_RELATIONSHIP.intValue());

                // THEN
                assertFalse(cursor.Next());
            }
        }
        private void CreateNodeRelationships()
        {
            RelationshipStore relationshipStore = _neoStores.RelationshipStore;

            if (Dense)
            {
                RecordStore <RelationshipGroupRecord> relationshipGroupStore = _neoStores.RelationshipGroupStore;
                relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(1, 1));
                relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(2, 2));
                relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(3, 3));
            }

            relationshipStore.UpdateRecord(CreateRelationship(1, NO_NEXT_RELATIONSHIP.intValue()));
            relationshipStore.UpdateRecord(CreateRelationship(2, NO_NEXT_RELATIONSHIP.intValue()));
            relationshipStore.UpdateRecord(CreateRelationship(3, NO_NEXT_RELATIONSHIP.intValue()));
        }
        private void CreateRelationshipChain(int recordsInChain)
        {
            RelationshipStore relationshipStore = _neoStores.RelationshipStore;

            for (int i = 1; i < recordsInChain; i++)
            {
                relationshipStore.UpdateRecord(CreateRelationship(i, i + 1));
            }
            relationshipStore.UpdateRecord(CreateRelationship(recordsInChain, NO_NEXT_RELATIONSHIP.intValue()));
            if (Dense)
            {
                RecordStore <RelationshipGroupRecord> relationshipGroupStore = _neoStores.RelationshipGroupStore;
                for (int i = 1; i < recordsInChain; i++)
                {
                    relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(i, i));
                }
                relationshipGroupStore.UpdateRecord(CreateRelationshipGroup(recordsInChain, NO_NEXT_RELATIONSHIP.intValue()));
            }
        }
Esempio n. 9
0
        private void MarkRandomRelsInChainNotInUse(long relId)
        {
            if (relId != NO_NEXT_RELATIONSHIP.intValue())
            {
                RelationshipRecord record = GetRelRecord(relId);

                bool shouldBeMarked = Random.nextBoolean();
                if (shouldBeMarked)
                {
                    record.InUse = false;
                    Update(record);
                }

                MarkRandomRelsInChainNotInUse(record.FirstNextRel);
                bool isLoopRelationship = record.FirstNextRel == record.SecondNextRel;
                if (!isLoopRelationship)
                {
                    MarkRandomRelsInChainNotInUse(record.SecondNextRel);
                }
            }
        }
Esempio n. 10
0
        private void MarkRelGroupNotInUse(long nodeId, params TestRelType[] types)
        {
            NodeRecord node = GetNodeRecord(nodeId);

            assertTrue(node.Dense);

            ISet <TestRelType> typesToRemove = asSet(types);

            long relGroupId = node.NextRel;

            while (relGroupId != NO_NEXT_RELATIONSHIP.intValue())
            {
                RelationshipGroupRecord relGroup = GetRelGroupRecord(relGroupId);
                TestRelType             type     = RelTypeForId(relGroup.Type);

                if (typesToRemove.Contains(type))
                {
                    relGroup.InUse = false;
                    Update(relGroup);
                }

                relGroupId = relGroup.Next;
            }
        }
 private RelationshipRecord CreateRelationship(long id, long nextRelationship)
 {
     return(new RelationshipRecord(id, true, FirstNode, SecondNode, TYPE, NO_NEXT_RELATIONSHIP.intValue(), nextRelationship, NO_NEXT_RELATIONSHIP.intValue(), nextRelationship, false, false));
 }
Esempio n. 12
0
 private RelationshipRecord GetRelationship(long relId, bool inUse, int type)
 {
     if (!inUse)
     {
         type = -1;
     }
     return((new RelationshipRecord(relId)).initialize(inUse, NO_NEXT_PROPERTY.longValue(), 0, 0, type, NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), true, false));
 }
Esempio n. 13
0
        private NodeRecord GetNode(int nodeId, bool inUse)
        {
            NodeRecord nodeRecord = new NodeRecord(nodeId);

            nodeRecord = nodeRecord.Initialize(inUse, NO_NEXT_PROPERTY.longValue(), false, NO_NEXT_RELATIONSHIP.longValue(), NO_LABELS_FIELD.longValue());
            if (inUse)
            {
                InlineNodeLabels labelFieldWriter = new InlineNodeLabels(nodeRecord);
                labelFieldWriter.Put(new long[] { ENTITY_TOKEN }, null, null);
            }
            return(nodeRecord);
        }
Esempio n. 14
0
 public override void Clear()
 {
     Initialize(false, NO_NEXT_PROPERTY.intValue(), -1, -1, -1, 1, NO_NEXT_RELATIONSHIP.intValue(), 1, NO_NEXT_RELATIONSHIP.intValue(), true, true);
 }