Example #1
0
 private void ReportNodeLabelNotInIndex(REPORT report, NodeRecord nodeRecord, long storeLabel)
 {
     if (_checkStoreToIndex)
     {
         report.nodeLabelNotInIndex(nodeRecord, storeLabel);
     }
 }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rebuildReplicatedIdGeneratorsOnRecovery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RebuildReplicatedIdGeneratorsOnRecovery()
        {
            DefaultFileSystemAbstraction fileSystem = FileSystemRule.get();
            File stickyGenerator      = new File(TestDirectory.databaseDir(), "stickyGenerator");
            File nodeStoreIdGenerator = TestDirectory.databaseLayout().idNodeStore();

            StoreFactory storeFactory = new StoreFactory(TestDirectory.databaseLayout(), Config.defaults(), GetIdGenerationFactory(fileSystem), PageCacheRule.getPageCache(fileSystem), fileSystem, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            using (NeoStores neoStores = storeFactory.OpenAllNeoStores(true))
            {
                NodeStore nodeStore = neoStores.NodeStore;
                for (int i = 0; i < 50; i++)
                {
                    NodeRecord nodeRecord = nodeStore.NewRecord();
                    nodeRecord.InUse = true;
                    nodeRecord.Id    = nodeStore.NextId();
                    if (i == 47)
                    {
                        FileUtils.copyFile(nodeStoreIdGenerator, stickyGenerator);
                    }
                    nodeStore.UpdateRecord(nodeRecord);
                }
            }

            FileUtils.copyFile(stickyGenerator, nodeStoreIdGenerator);
            using (NeoStores reopenedStores = storeFactory.OpenAllNeoStores())
            {
                reopenedStores.MakeStoreOk();
                assertEquals(51L, reopenedStores.NodeStore.nextId());
            }
        }
Example #3
0
        protected internal override void Process(RelationshipGroupRecord[] batch, BatchSender sender)
        {
            foreach (RelationshipGroupRecord group in batch)
            {
                if (!group.InUse())
                {
                    continue;
                }

                long nodeId = group.OwningNode;
                if (_cache.getByte(nodeId, 0) == 0)
                {
                    _cache.setByte(nodeId, 0, ( sbyte )1);
                    NodeRecord nodeRecord = _nodeStore.newRecord();
                    _nodeStore.getRecordByCursor(nodeId, nodeRecord, NORMAL, _nodeCursor);
                    nodeRecord.NextRel = group.Id;
                    nodeRecord.Dense   = true;

                    _current[_cursor++] = nodeRecord;
                    if (_cursor == _batchSize)
                    {
                        sender.Send(_current);
                        NewBatch();
                    }
                }
            }
            control.recycle(batch);
        }
Example #4
0
 public override void CheckReference(RECORD record, NodeRecord nodeRecord, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
 {
     if (nodeRecord.InUse())
     {
         NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(nodeRecord);
         if (nodeLabels is DynamicNodeLabels)
         {
             DynamicNodeLabels dynamicNodeLabels = ( DynamicNodeLabels )nodeLabels;
             long firstRecordId = dynamicNodeLabels.FirstDynamicRecordId;
             RecordReference <DynamicRecord>   firstRecordReference      = records.NodeLabels(firstRecordId);
             ExpectedNodeLabelsChecker         expectedNodeLabelsChecker = new ExpectedNodeLabelsChecker(this, nodeRecord);
             LabelChainWalker <RECORD, REPORT> checker = new LabelChainWalker <RECORD, REPORT>(expectedNodeLabelsChecker);
             engine.ComparativeCheck(firstRecordReference, checker);
             nodeRecord.DynamicLabelRecords;                              // I think this is empty in production
         }
         else
         {
             long[] storeLabels = nodeLabels.Get(null);
             REPORT report      = engine.Report();
             ValidateLabelIds(nodeRecord, storeLabels, report);
         }
     }
     else if (_indexLabels.Length != 0)
     {
         engine.Report().nodeNotInUse(nodeRecord);
     }
 }
Example #5
0
        private static NodeRecord Node(long nextId)
        {
            NodeRecord node = new NodeRecord(nextId);

            node.InUse = true;
            return(node);
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void scanForHighIdOnlyOnceWhenProcessCache()
        internal virtual void ScanForHighIdOnlyOnceWhenProcessCache()
        {
            NeoStores      neoStores      = mock(typeof(NeoStores), Mockito.RETURNS_MOCKS);
            NodeStore      nodeStore      = mock(typeof(NodeStore));
            NodeRecord     nodeRecord     = mock(typeof(NodeRecord));
            StoreProcessor storeProcessor = mock(typeof(StoreProcessor));

            when(neoStores.NodeStore).thenReturn(nodeStore);
            when(nodeStore.HighId).thenReturn(10L);
            when(nodeStore.GetRecord(anyLong(), any(typeof(NodeRecord)), any(typeof(RecordLoad)))).thenReturn(nodeRecord);
            when(nodeStore.NewRecord()).thenReturn(nodeRecord);

            StoreAccess storeAccess = new StoreAccess(neoStores);

            storeAccess.Initialize();

            DefaultCacheAccess cacheAccess = new DefaultCacheAccess(Counts.NONE, 1);

            CacheTask.CheckNextRel cacheTask = new CacheTask.CheckNextRel(Org.Neo4j.Consistency.checking.full.Stage_Fields.SequentialForward, cacheAccess, storeAccess, storeProcessor);

            cacheAccess.CacheSlotSizes = CheckStage.Stage5_Check_NextRel.CacheSlotSizes;
            cacheTask.ProcessCache();

            verify(nodeStore, times(1)).HighId;
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTrackSecondaryUnitIdsAsWell() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldTrackSecondaryUnitIdsAsWell()
        {
            // GIVEN
            NeoStores neoStores = NeoStoresRule.builder().build();
            HighIdTransactionApplier tracker = new HighIdTransactionApplier(neoStores);

            NodeRecord node = (new NodeRecord(5)).initialize(true, 123, true, 456, 0);

            node.SecondaryUnitId       = 6;
            node.RequiresSecondaryUnit = true;

            RelationshipRecord relationship = (new RelationshipRecord(10)).initialize(true, 1, 2, 3, 4, 5, 6, 7, 8, true, true);

            relationship.SecondaryUnitId       = 12;
            relationship.RequiresSecondaryUnit = true;

            RelationshipGroupRecord relationshipGroup = (new RelationshipGroupRecord(8)).initialize(true, 0, 1, 2, 3, 4, 5);

            relationshipGroup.SecondaryUnitId       = 20;
            relationshipGroup.RequiresSecondaryUnit = true;

            // WHEN
            tracker.VisitNodeCommand(new NodeCommand(new NodeRecord(node.Id), node));
            tracker.VisitRelationshipCommand(new RelationshipCommand(new RelationshipRecord(relationship.Id), relationship));
            tracker.VisitRelationshipGroupCommand(new RelationshipGroupCommand(new RelationshipGroupRecord(relationshipGroup.Id), relationshipGroup));
            tracker.Close();

            // THEN
            assertEquals(node.SecondaryUnitId + 1, neoStores.NodeStore.HighId);
            assertEquals(relationship.SecondaryUnitId + 1, neoStores.RelationshipStore.HighId);
            assertEquals(relationshipGroup.SecondaryUnitId + 1, neoStores.RelationshipGroupStore.HighId);
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void recordWithReservedIdIsSkipped()
        public virtual void RecordWithReservedIdIsSkipped()
        {
            RecordStore <NodeRecord>       store        = mock(typeof(NodeStore));
            StageControl                   stageControl = mock(typeof(StageControl));
            UpdateRecordsStep <NodeRecord> step         = new UpdateRecordsStep <NodeRecord>(stageControl, Configuration.DEFAULT, store, new StorePrepareIdSequence());

            NodeRecord node1 = new NodeRecord(1);

            node1.InUse = true;
            NodeRecord node2 = new NodeRecord(2);

            node2.InUse = true;
            NodeRecord nodeWithReservedId = new NodeRecord(IdGeneratorImpl.INTEGER_MINUS_ONE);

            NodeRecord[] batch = new NodeRecord[] { node1, node2, nodeWithReservedId };

            step.Process(batch, mock(typeof(BatchSender)));

            verify(store).prepareForCommit(eq(node1), any(typeof(IdSequence)));
            verify(store).updateRecord(node1);
            verify(store).prepareForCommit(eq(node2), any(typeof(IdSequence)));
            verify(store).updateRecord(node2);
            verify(store, never()).prepareForCommit(eq(nodeWithReservedId), any(typeof(IdSequence)));
            verify(store, never()).updateRecord(nodeWithReservedId);
        }
Example #9
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.NodeRecord source, org.neo4j.kernel.impl.store.record.NodeRecord target, int recordSize) throws java.io.IOException
        private void WriteReadRecord(NodeRecord source, NodeRecord target, int recordSize)
        {
            _recordFormat.prepare(source, recordSize, _idSequence);
            _recordFormat.write(source, _pageCursor, recordSize);
            _pageCursor.Offset = 0;
            _recordFormat.read(target, _pageCursor, RecordLoad.NORMAL, recordSize);
        }
Example #10
0
            public override void Run(StoreAccess store, PrintStream @out)
            {
                RecordStore <NodeRecord> nodeStore = store.NodeStore;
                NodeRecord node = nodeStore.GetRecord(Id, nodeStore.NewRecord(), NORMAL);

                if (node.Dense)
                {
                    RecordStore <RelationshipGroupRecord> relationshipGroupStore = store.RelationshipGroupStore;
                    RelationshipGroupRecord group = relationshipGroupStore.NewRecord();
                    relationshipGroupStore.GetRecord(node.NextRel, group, NORMAL);
                    do
                    {
                        @out.println("group " + group);
                        @out.println("out:");
                        PrintRelChain(store, @out, group.FirstOut);
                        @out.println("in:");
                        PrintRelChain(store, @out, group.FirstIn);
                        @out.println("loop:");
                        PrintRelChain(store, @out, group.FirstLoop);
                        group = group.Next != -1 ? relationshipGroupStore.GetRecord(group.Next, group, NORMAL) : null;
                    } while (group != null);
                }
                else
                {
                    PrintRelChain(store, @out, node.NextRel);
                }
            }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void nodeCommandWithFixedReferenceFormat302() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void NodeCommandWithFixedReferenceFormat302()
        {
            // Given
            InMemoryClosableChannel channel = new InMemoryClosableChannel();
            NodeRecord before = new NodeRecord(42, true, false, 33, 99, 66);
            NodeRecord after  = new NodeRecord(42, true, false, 33, 99, 66);

            before.UseFixedReferences = true;
            after.UseFixedReferences  = true;

            (new Command.NodeCommand(before, after)).Serialize(channel);

            // When
            PhysicalLogCommandReaderV3_0_2 reader = new PhysicalLogCommandReaderV3_0_2();
            Command command = reader.Read(channel);

            assertTrue(command is Command.NodeCommand);

            Command.NodeCommand nodeCommand = (Command.NodeCommand)command;

            // Then
            assertEquals(before, nodeCommand.Before);
            assertEquals(after, nodeCommand.After);
            assertTrue(nodeCommand.Before.UseFixedReferences);
            assertTrue(nodeCommand.After.UseFixedReferences);
        }
Example #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeRecordWithOldFormat(org.neo4j.kernel.impl.store.record.NodeRecord oldFormatRecord) throws java.io.IOException
        private void WriteRecordWithOldFormat(NodeRecord oldFormatRecord)
        {
            int oldRecordSize = NodeRecordFormatV3_0_0.RECORD_SIZE;
            NodeRecordFormatV3_0_0 recordFormatV30 = new NodeRecordFormatV3_0_0();

            recordFormatV30.Prepare(oldFormatRecord, oldRecordSize, _idSequence);
            recordFormatV30.Write(oldFormatRecord, _pageCursor, oldRecordSize);
            _pageCursor.Offset = 0;
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useVariableLengthFormatWhenPropertyReferenceTooBig() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UseVariableLengthFormatWhenPropertyReferenceTooBig()
        {
            NodeRecord source = new NodeRecord(1);
            NodeRecord target = new NodeRecord(1);

            source.Initialize(true, RandomFixedReference(), true, 1L << 37, 0L);

            WriteReadRecord(source, target);

            assertFalse("Record should use variable length reference format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
Example #14
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()
        {
            NodeRecord source = new NodeRecord(1);
            NodeRecord target = new NodeRecord(1);

            source.Initialize(true, RandomFixedReference(), true, RandomFixedReference(), 0L);

            WriteReadRecord(source, target, NodeRecordFormat.FixedFormatRecordSize);

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

            source.Initialize(true, Record.NULL_REFERENCE.intValue(), true, RandomFixedReference(), 0L);

            WriteReadRecord(source, target);

            assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
Example #16
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()
        {
            NodeRecord source = new NodeRecord(1);
            NodeRecord target = new NodeRecord(1);

            source.Initialize(true, RandomFixedReference(), true, RandomFixedReference(), 0L);

            WriteReadRecord(source, target);

            assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
Example #17
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()
        {
            NodeRecord source = new NodeRecord(1);
            NodeRecord target = new NodeRecord(1);

            source.Initialize(true, RandomFixedReference(), true, RandomFixedReference(), 0L);

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

            assertFalse("Record should use variable length reference if format record is too small.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void inUseRecordEquality()
        public virtual void InUseRecordEquality()
        {
            NodeRecord record1 = new NodeRecord(1);

            record1.Initialize(true, 1, false, 2, 3);
            record1.SecondaryUnitId = 42;

            NodeRecord record2 = record1.Clone();

            NodeCheckType check = new NodeCheckType();

            assertTrue(check.Equal(record1, record2));
        }
Example #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readDoubleUnitRecordStoredNotInFixedReferenceFormat() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReadDoubleUnitRecordStoredNotInFixedReferenceFormat()
        {
            NodeRecord oldFormatRecord = new NodeRecord(1);
            NodeRecord newFormatRecord = new NodeRecord(1);

            oldFormatRecord.Initialize(true, BigReference(), true, BigReference(), 1L);

            WriteRecordWithOldFormat(oldFormatRecord);

            assertTrue("This should be double unit record.", oldFormatRecord.HasSecondaryUnitId());
            assertFalse("Old format is not aware about fixed references.", oldFormatRecord.UseFixedReferences);

            _recordFormat.read(newFormatRecord, _pageCursor, RecordLoad.NORMAL, NodeRecordFormat.RECORD_SIZE);
            VerifySameReferences(oldFormatRecord, newFormatRecord);
        }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void notInUseRecordEquality()
        public virtual void NotInUseRecordEquality()
        {
            NodeRecord record1 = new NodeRecord(1);

            record1.Initialize(false, 1, true, 2, 3);
            record1.SecondaryUnitId = 42;

            NodeRecord record2 = new NodeRecord(1);

            record2.Initialize(false, 11, true, 22, 33);
            record2.SecondaryUnitId = 24;

            NodeCheckType check = new NodeCheckType();

            assertTrue(check.Equal(record1, record2));
        }
Example #21
0
            protected internal override void ProcessCache()
            {
                RecordStore <NodeRecord> nodeStore = StoreAccess.NodeStore;
                CacheAccess_Client       client    = CacheAccess.client();
                long highId = nodeStore.HighId;

                for (long nodeId = 0; nodeId < highId; nodeId++)
                {
                    if (client.GetFromCache(nodeId, CacheSlots_NextRelationship_Fields.SLOT_FIRST_IN_TARGET) == 0)
                    {
                        NodeRecord node = nodeStore.GetRecord(nodeId, nodeStore.NewRecord(), FORCE);
                        if (node.InUse() && !node.Dense)
                        {
                            StoreProcessor.processNode(nodeStore, node);
                        }
                    }
                }
            }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions()
        public virtual void ShouldGrowAFileWhileContinuingToMemoryMapNewRegions()
        {
            // don't run on windows because memory mapping doesn't work properly there
            assumeTrue(!SystemUtils.IS_OS_WINDOWS);

            // given
            const int numberOfRecords = 1000000;

            Config config = Config.defaults(pagecache_memory, MmapSize(numberOfRecords, NodeRecordFormat.RECORD_SIZE));
            FileSystemAbstraction     fileSystemAbstraction = _fileSystemRule.get();
            DefaultIdGeneratorFactory idGeneratorFactory    = new DefaultIdGeneratorFactory(fileSystemAbstraction);
            PageCache    pageCache    = _pageCacheRule.getPageCache(fileSystemAbstraction, config);
            StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), config, idGeneratorFactory, pageCache, fileSystemAbstraction, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            NeoStores neoStores = storeFactory.OpenAllNeoStores(true);
            NodeStore nodeStore = neoStores.NodeStore;

            // when
            int  iterations = 2 * numberOfRecords;
            long startingId = nodeStore.NextId();
            long nodeId     = startingId;

            for (int i = 0; i < iterations; i++)
            {
                NodeRecord record = new NodeRecord(nodeId, false, i, 0);
                record.InUse = true;
                nodeStore.UpdateRecord(record);
                nodeId = nodeStore.NextId();
            }

            // then
            NodeRecord record = new NodeRecord(0, false, 0, 0);

            for (int i = 0; i < iterations; i++)
            {
                record.Id = startingId + i;
                nodeStore.GetRecord(i, record, NORMAL);
                assertTrue("record[" + i + "] should be in use", record.InUse());
                assertThat("record[" + i + "] should have nextRelId of " + i, record.NextRel, @is(( long )i));
            }

            neoStores.Close();
        }
Example #23
0
            protected internal override void ProcessCache()
            {
                CacheAccess.clearCache();
                long[]             fields = new long[] { -1, 1, 0 };
                CacheAccess_Client client = CacheAccess.client();

                using (ResourceIterator <NodeRecord> nodeRecords = Nodes.GetEnumerator())
                {
                    while (nodeRecords.MoveNext())
                    {
                        NodeRecord node = nodeRecords.Current;
                        if (node.InUse())
                        {
                            fields[CacheSlots_NextRelationship_Fields.SLOT_RELATIONSHIP_ID] = node.NextRel;
                            client.PutToCache(node.Id, fields);
                        }
                    }
                }
            }
Example #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void toStringShouldPlaceEachRecordOnItsOwnLine()
        internal virtual void ToStringShouldPlaceEachRecordOnItsOwnLine()
        {
            // given
            NodeRecord             record1 = new NodeRecord(1, false, 1, 1);
            NodeRecord             record2 = new NodeRecord(2, false, 2, 2);
            RecordSet <NodeRecord> set     = new RecordSet <NodeRecord>();

            set.Add(record1);
            set.Add(record2);

            // when
            string @string = set.ToString();

            // then
            string[] lines = @string.Split("\n", true);
            assertEquals(4, lines.Length);
            assertEquals("[", lines[0]);
            assertEquals(record1.ToString() + ",", lines[1]);
            assertEquals(record2.ToString() + ",", lines[2]);
            assertEquals("]", lines[3]);
        }
Example #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportDuplicatePropertyIndexesInPropertyRecordForNode()
        internal virtual void ShouldReportDuplicatePropertyIndexesInPropertyRecordForNode()
        {
            // given
            ChainCheck check = new ChainCheck();

            RecordAccessStub records = new RecordAccessStub();

            NodeRecord master = records.Add(inUse(new NodeRecord(1, false, -1, 1)));

            PropertyRecord propertyRecord = inUse(new PropertyRecord(1));
            PropertyBlock  firstBlock     = new PropertyBlock();

            firstBlock.SingleBlock = 1;
            firstBlock.KeyIndexId  = 1;

            PropertyBlock secondBlock = new PropertyBlock();

            secondBlock.SingleBlock = 1;
            secondBlock.KeyIndexId  = 2;

            PropertyBlock thirdBlock = new PropertyBlock();

            thirdBlock.SingleBlock = 1;
            thirdBlock.KeyIndexId  = 1;

            propertyRecord.AddPropertyBlock(firstBlock);
            propertyRecord.AddPropertyBlock(secondBlock);
            propertyRecord.AddPropertyBlock(thirdBlock);

            records.Add(propertyRecord);

            // when
            Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport report = mock(typeof(Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport));
            CheckerEngine <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> checkEngine = records.Engine(master, report);

            check.checkReference(master, propertyRecord, checkEngine, records);

            // then
            verify(report).propertyKeyNotUniqueInChain();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParserCommandsUsingAGivenFactory() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParserCommandsUsingAGivenFactory()
        {
            // given
            // The record, it will be used as before and after
            NodeRecord theRecord = new NodeRecord(1);

            Command.NodeCommand nodeCommand = new Command.NodeCommand(theRecord, theRecord);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
            LogEntryCommand command = new LogEntryCommand(_version, nodeCommand);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.Put(Org.Neo4j.Kernel.impl.transaction.command.NeoCommandType_Fields.NodeCommand);
            channel.PutLong(theRecord.Id);

            // record image before
            channel.Put(( sbyte )0);           // not in use
            channel.PutInt(0);                 // number of dynamic records in use
            // record image after
            channel.Put(( sbyte )0);           // not in use
            channel.PutInt(0);                 // number of dynamic records in use

            channel.GetCurrentPosition(_marker);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryParser parser = version.entryParser(LogEntryByteCodes.COMMAND);
            LogEntryParser parser = _version.entryParser(LogEntryByteCodes.Command);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
            LogEntry logEntry = parser.parse(_version, channel, _marker, _commandReader);

            // then
            assertEquals(command, logEntry);
            assertFalse(parser.skip());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAbortLoadingGroupChainIfComeTooFar()
        public virtual void ShouldAbortLoadingGroupChainIfComeTooFar()
        {
            // GIVEN a node with relationship group chain 2-->4-->10-->23
            LogProvider  logProvider  = NullLogProvider.Instance;
            StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(_fs.get()), _pageCache.getPageCache(_fs.get()), _fs.get(), logProvider, EmptyVersionContextSupplier.EMPTY);

            using (NeoStores stores = storeFactory.OpenNeoStores(true, StoreType.RELATIONSHIP_GROUP))
            {
                RecordStore <RelationshipGroupRecord> store = spy(stores.RelationshipGroupStore);

                RelationshipGroupRecord group2  = Group(0, 2);
                RelationshipGroupRecord group4  = Group(1, 4);
                RelationshipGroupRecord group10 = Group(2, 10);
                RelationshipGroupRecord group23 = Group(3, 23);
                Link(group2, group4, group10, group23);
                store.UpdateRecord(group2);
                store.UpdateRecord(group4);
                store.UpdateRecord(group10);
                store.UpdateRecord(group23);
                RelationshipGroupGetter groupGetter = new RelationshipGroupGetter(store);
                NodeRecord node = new NodeRecord(0, true, group2.Id, -1);

                // WHEN trying to find relationship group 7
                RecordAccess <RelationshipGroupRecord, int>       access = new DirectRecordAccess <RelationshipGroupRecord, int>(store, Loaders.relationshipGroupLoader(store));
                RelationshipGroupGetter.RelationshipGroupPosition result = groupGetter.GetRelationshipGroup(node, 7, access);

                // THEN only groups 2, 4 and 10 should have been loaded
                InOrder verification = inOrder(store);
                verification.verify(store).getRecord(eq(group2.Id), any(typeof(RelationshipGroupRecord)), any(typeof(RecordLoad)));
                verification.verify(store).getRecord(eq(group4.Id), any(typeof(RelationshipGroupRecord)), any(typeof(RecordLoad)));
                verification.verify(store).getRecord(eq(group10.Id), any(typeof(RelationshipGroupRecord)), any(typeof(RecordLoad)));
                verification.verify(store, never()).getRecord(eq(group23.Id), any(typeof(RelationshipGroupRecord)), any(typeof(RecordLoad)));

                // it should also be reported as not found
                assertNull(result.Group());
                // with group 4 as closes previous one
                assertEquals(group4, result.ClosestPrevious().forReadingData());
            }
        }
Example #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void ioThroughputStatDoesNotOverflow()
        public virtual void IoThroughputStatDoesNotOverflow()
        {
            // store with huge record size to force overflow and not create huge batch of records
            RecordStore <NodeRecord> store = mock(typeof(RecordStore));

            when(store.RecordSize).thenReturn(int.MaxValue / 2);

            Configuration configuration         = mock(typeof(Configuration));
            StageControl  stageControl          = mock(typeof(StageControl));
            UpdateRecordsStep <NodeRecord> step = new UpdateRecordsStep <NodeRecord>(stageControl, configuration, store, new StorePrepareIdSequence());

            NodeRecord record = new NodeRecord(1);

            record.InUse = true;
            NodeRecord[] batch = new NodeRecord[11];
            Arrays.fill(batch, record);

            step.Process(batch, mock(typeof(BatchSender)));

            Stat stat = step.Stat(Keys.io_throughput);

            assertThat(stat.AsLong(), greaterThan(0L));
        }
Example #29
0
 private void NodeAdvance(NodeRecord record, PageCursor pageCursor)
 {
     _read.nextRecordByCursor(record, RecordLoad.CHECK, pageCursor);
 }
Example #30
0
 private void Node(NodeRecord record, long reference, PageCursor pageCursor)
 {
     _read.getRecordByCursor(reference, record, RecordLoad.CHECK, pageCursor);
 }