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 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());
            }
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
 internal NodeSetFirstGroupStep(StageControl control, Configuration config, NodeStore nodeStore, ByteArray cache) : base(control, "FIRST", config, 1)
 {
     this._cache      = cache;
     this._batchSize  = config.BatchSize();
     this._nodeStore  = nodeStore;
     this._nodeCursor = nodeStore.OpenPageCursorForReading(0);
     NewBatch();
 }
Exemplo n.º 4
0
 internal NodeCountsProcessor(NodeStore nodeStore, NodeLabelsCache cache, int highLabelId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater counts, ProgressReporter progressReporter)
 {
     this._nodeStore = nodeStore;
     this._cache     = cache;
     this._anyLabel  = highLabelId;
     this._counts    = counts;
     // Instantiate with high id + 1 since we need that extra slot for the ANY count
     this._labelCounts      = new long[highLabelId + 1];
     this._progressReporter = progressReporter;
 }
Exemplo n.º 5
0
        public NodeCountsStage(Configuration config, NodeLabelsCache cache, NodeStore nodeStore, int highLabelId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, ProgressReporter progressReporter, params StatsProvider[] additionalStatsProviders) : base(NAME, null, config, RECYCLE_BATCHES)
        {
            Add(new BatchFeedStep(Control(), config, allIn(nodeStore, config), nodeStore.RecordSize));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: add(new org.neo4j.unsafe.impl.batchimport.staging.ReadRecordsStep<>(control(), config, false, nodeStore));
            Add(new ReadRecordsStep <object>(Control(), config, false, nodeStore));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: add(new RecordProcessorStep<>(control(), "COUNT", config, new NodeCountsProcessor(nodeStore, cache, highLabelId, countsUpdater, progressReporter), true, additionalStatsProviders));
            Add(new RecordProcessorStep <object>(Control(), "COUNT", config, new NodeCountsProcessor(nodeStore, cache, highLabelId, countsUpdater, progressReporter), true, additionalStatsProviders));
        }
        public SparseNodeFirstRelationshipStage(Configuration config, NodeStore nodeStore, NodeRelationshipCache cache) : base(NAME, null, config, ORDER_SEND_DOWNSTREAM | RECYCLE_BATCHES)
        {
            Add(new ReadNodeIdsByCacheStep(Control(), config, cache, NodeType.NODE_TYPE_SPARSE));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: add(new org.neo4j.unsafe.impl.batchimport.staging.ReadRecordsStep<>(control(), config, true, nodeStore));
            Add(new ReadRecordsStep <object>(Control(), config, true, nodeStore));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: add(new RecordProcessorStep<>(control(), "LINK", config, new SparseNodeFirstRelationshipProcessor(cache), false));
            Add(new RecordProcessorStep <object>(Control(), "LINK", config, new SparseNodeFirstRelationshipProcessor(cache), false));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: add(new UpdateRecordsStep<>(control(), config, nodeStore, new org.neo4j.unsafe.impl.batchimport.store.StorePrepareIdSequence()));
            Add(new UpdateRecordsStep <object>(Control(), config, nodeStore, new StorePrepareIdSequence()));
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void nodeCursorShouldClosePageCursor()
        internal virtual void NodeCursorShouldClosePageCursor()
        {
            NodeStore  store      = mock(typeof(NodeStore));
            PageCursor pageCursor = mock(typeof(PageCursor));

            when(store.OpenPageCursorForReading(anyLong())).thenReturn(pageCursor);

            using (RecordNodeCursor cursor = new RecordNodeCursor(store))
            {
                cursor.Single(0);
            }
            verify(pageCursor).close();
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldClearStateOnClose()
        public virtual void ShouldClearStateOnClose()
        {
            // GIVEN
            NeoStores mockStore = mock(typeof(NeoStores));
            NodeStore store     = mock(typeof(NodeStore));

            when(mockStore.NodeStore).thenReturn(store);
            RelationshipStore relationshipStore = mock(typeof(RelationshipStore));

            when(mockStore.RelationshipStore).thenReturn(relationshipStore);
            PropertyStore propertyStore = mock(typeof(PropertyStore));

            when(mockStore.PropertyStore).thenReturn(propertyStore);
            SchemaStore schemaStore = mock(typeof(SchemaStore));

            when(mockStore.SchemaStore).thenReturn(schemaStore);
            RelationshipGroupStore groupStore = mock(typeof(RelationshipGroupStore));

            when(mockStore.RelationshipGroupStore).thenReturn(groupStore);

            RecordChangeSet changeSet = new RecordChangeSet(new Loaders(mockStore));

            // WHEN

            /*
             * We need to make sure some stuff is stored in the sets being managed. That is why forChangingLinkage() is
             * called - otherwise, no changes will be stored and changeSize() would return 0 anyway.
             */
            changeSet.NodeRecords.create(1L, null).forChangingLinkage();
            changeSet.PropertyRecords.create(1L, null).forChangingLinkage();
            changeSet.RelRecords.create(1L, null).forChangingLinkage();
            changeSet.SchemaRuleChanges.create(1L, null).forChangingLinkage();
            changeSet.RelGroupRecords.create(1L, 1).forChangingLinkage();

            changeSet.Close();

            // THEN
            assertEquals(0, changeSet.NodeRecords.changeSize());
            assertEquals(0, changeSet.PropertyRecords.changeSize());
            assertEquals(0, changeSet.RelRecords.changeSize());
            assertEquals(0, changeSet.SchemaRuleChanges.changeSize());
            assertEquals(0, changeSet.RelGroupRecords.changeSize());
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void singlePassShouldOnlyProcessTheStoreOnce()
        internal virtual void SinglePassShouldOnlyProcessTheStoreOnce()
        {
            // given
            StoreProcessor singlePassProcessor = mock(typeof(StoreProcessor));

            when(singlePassProcessor.Stage).thenReturn(Stage_Fields.SequentialForward);

            NodeStore store = mock(typeof(NodeStore));

            when(store.StorageFile).thenReturn(new File("node-store"));

            StoreProcessorTask <NodeRecord> task = new StoreProcessorTask <NodeRecord>("nodes", Statistics.NONE, 1, store, null, "nodes", ProgressMonitorFactory.NONE.multipleParts("check"), CacheAccess.EMPTY, singlePassProcessor, QueueDistribution.ROUND_ROBIN);

            // when
            task.Run();

            // then
            verify(singlePassProcessor).applyFiltered(same(store), any(typeof(ProgressListener)));
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings({"unchecked", "rawtypes"}) public static org.neo4j.kernel.impl.store.NeoStores basicMockedNeoStores()
        public static NeoStores BasicMockedNeoStores()
        {
            NeoStores neoStores = mock(typeof(NeoStores));

            // NodeStore - DynamicLabelStore
            NodeStore nodeStore = mock(typeof(NodeStore));

            when(neoStores.NodeStore).thenReturn(nodeStore);

            // NodeStore - DynamicLabelStore
            DynamicArrayStore dynamicLabelStore = mock(typeof(DynamicArrayStore));

            when(nodeStore.DynamicLabelStore).thenReturn(dynamicLabelStore);

            // RelationshipStore
            RelationshipStore relationshipStore = mock(typeof(RelationshipStore));

            when(neoStores.RelationshipStore).thenReturn(relationshipStore);

            // RelationshipGroupStore
            RelationshipGroupStore relationshipGroupStore = mock(typeof(RelationshipGroupStore));

            when(neoStores.RelationshipGroupStore).thenReturn(relationshipGroupStore);

            // PropertyStore
            PropertyStore propertyStore = mock(typeof(PropertyStore));

            when(neoStores.PropertyStore).thenReturn(propertyStore);

            // PropertyStore -- DynamicStringStore
            DynamicStringStore propertyStringStore = mock(typeof(DynamicStringStore));

            when(propertyStore.StringStore).thenReturn(propertyStringStore);

            // PropertyStore -- DynamicArrayStore
            DynamicArrayStore propertyArrayStore = mock(typeof(DynamicArrayStore));

            when(propertyStore.ArrayStore).thenReturn(propertyArrayStore);

            return(neoStores);
        }
Exemplo n.º 11
0
 internal RecordNodeCursor(NodeStore read) : base(NO_ID)
 {
     this._read = read;
 }
Exemplo n.º 12
0
 public LabelIndexWriterStep(StageControl control, Configuration config, LabelScanStore store, NodeStore nodeStore) : base(control, "LABEL INDEX", config, 1)
 {
     this._writer    = store.NewWriter();
     this._nodeStore = nodeStore;
 }