Exemplo n.º 1
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);
        }
Exemplo n.º 2
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");
        }
        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));
        }
Exemplo 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);
        }
Exemplo 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()));
            }
        }
Exemplo 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);
                }
            }
        }
Exemplo 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));
 }
Exemplo n.º 12
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);
 }