Пример #1
0
        protected internal virtual S InitialiseStore(NeoStores neoStores)
        {
            S store = GetStore(neoStores);

            store.updateRecord(CreateExistingRecord(false));
            return(store);
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testClose()
        public virtual void TestClose()
        {
            DynamicArrayStore           store   = CreateDynamicArrayStore();
            ICollection <DynamicRecord> records = new List <DynamicRecord>();

            store.AllocateRecordsFromBytes(records, new sbyte[10]);
            long blockId = Iterables.first(records).Id;

            foreach (DynamicRecord record in records)
            {
                store.UpdateRecord(record);
            }
            _neoStores.close();
            _neoStores = null;
            try
            {
                store.GetArrayFor(store.GetRecords(blockId, NORMAL));
                fail("Closed store should throw exception");
            }
            catch (Exception)
            {               // good
            }
            try
            {
                store.GetRecords(0, NORMAL);
                fail("Closed store should throw exception");
            }
            catch (Exception)
            {               // good
            }
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = StoreNotFoundException.class) public void shouldThrowWhenOpeningNonExistingNeoStores()
        public virtual void ShouldThrowWhenOpeningNonExistingNeoStores()
        {
            using (NeoStores neoStores = StoreFactory(Config.defaults()).openAllNeoStores())
            {
                neoStores.MetaDataStore;
            }
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void firstRecordOtherThanZeroIfNotFirst()
        public virtual void FirstRecordOtherThanZeroIfNotFirst()
        {
            File             storeDir = TestDirectory.databaseDir();
            GraphDatabaseAPI db       = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir);
            Transaction      tx       = Db.beginTx();
            Node             node     = Db.createNode();

            node.SetProperty("name", "Yo");
            tx.Success();
            tx.Close();
            Db.shutdown();

            db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir);
            tx = Db.beginTx();
            Properties(db).setProperty("test", "something");
            tx.Success();
            tx.Close();
            Db.shutdown();

            Config       config       = Config.defaults();
            StoreFactory storeFactory = new StoreFactory(TestDirectory.databaseLayout(), config, new DefaultIdGeneratorFactory(Fs.get()), PageCacheRule.getPageCache(Fs.get()), Fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            NeoStores    neoStores    = storeFactory.OpenAllNeoStores();
            long         prop         = neoStores.MetaDataStore.GraphNextProp;

            assertTrue(prop != 0);
            neoStores.Close();
        }
Пример #5
0
        private void ShiftHighId(GraphDatabaseAPI db)
        {
            RecordStorageEngine storageEngine = Db.DependencyResolver.resolveDependency(typeof(RecordStorageEngine));
            NeoStores           neoStores     = storageEngine.TestAccessNeoStores();

            neoStores.RelationshipTypeTokenStore.HighId = short.MaxValue - RELATIONSHIP_COUNT / 2;
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = InvalidRecordException.class) public void readingNonExistingRecordMustThrow()
        public virtual void ReadingNonExistingRecordMustThrow()
        {
            using (NeoStores neoStores = StoreFixture())
            {
                S store = GetStore(neoStores);
                GetHeavy(store, ID + 1);
            }
        }
Пример #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private NodeStore newNodeStore(org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pageCache) throws java.io.IOException
        private NodeStore NewNodeStore(FileSystemAbstraction fs, PageCache pageCache)
        {
            _idGeneratorFactory = spy(new DefaultIdGeneratorFactoryAnonymousInnerClass(this, fs));
            StoreFactory factory = new StoreFactory(_testDirectory.databaseLayout("new"), Config.defaults(), _idGeneratorFactory, pageCache, fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            _neoStores = factory.OpenAllNeoStores(true);
            _nodeStore = _neoStores.NodeStore;
            return(_nodeStore);
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            _config = Config.defaults();
            DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(_fs.get());

            _storeFactory = new StoreFactory(_testDirectory.databaseLayout(), _config, idGeneratorFactory, PageCacheRule.getPageCache(_fs.get()), _fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            _neoStores    = _storeFactory.openAllNeoStores(true);
            _store        = _neoStores.SchemaStore;
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveSameCreationTimeAndUpgradeTimeOnStartup()
        public virtual void ShouldHaveSameCreationTimeAndUpgradeTimeOnStartup()
        {
            // When
            _neoStores = StoreFactory(Config.defaults()).openAllNeoStores(true);
            MetaDataStore metaDataStore = _neoStores.MetaDataStore;

            // Then
            assertThat(metaDataStore.UpgradeTime, equalTo(metaDataStore.CreationTime));
        }
Пример #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReadExistingLightRecord()
        public virtual void MustReadExistingLightRecord()
        {
            using (NeoStores neoStores = StoreFixture())
            {
                S store  = GetStore(neoStores);
                R record = GetLight(ID, store);
                AssertRecordsEqual(record, CreateExistingRecord(true));
            }
        }
Пример #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveSameCommittedTransactionAndUpgradeTransactionOnStartup()
        public virtual void ShouldHaveSameCommittedTransactionAndUpgradeTransactionOnStartup()
        {
            // When
            _neoStores = StoreFactory(Config.defaults()).openAllNeoStores(true);
            MetaDataStore metaDataStore = _neoStores.MetaDataStore;

            // Then
            assertEquals(metaDataStore.UpgradeTransaction, metaDataStore.LastCommittedTransaction);
        }
Пример #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustForceReadExistingRecord()
        public virtual void MustForceReadExistingRecord()
        {
            using (NeoStores neoStores = StoreFixture())
            {
                S store  = GetStore(neoStores);
                R record = GetForce(store, ID);
                AssertRecordsEqual(record, CreateExistingRecord(true));
            }
        }
Пример #13
0
 public NeoStoreTransactionApplier(CommandVersion version, NeoStores neoStores, CacheAccessBackDoor cacheAccess, LockService lockService, long transactionId, LockGroup lockGroup)
 {
     this._version       = version;
     this._lockGroup     = lockGroup;
     this._transactionId = transactionId;
     this._lockService   = lockService;
     this._neoStores     = neoStores;
     this._cacheAccess   = cacheAccess;
 }
Пример #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void forceReadingNonExistingRecordMustReturnEmptyRecordWithThatId()
        public virtual void ForceReadingNonExistingRecordMustReturnEmptyRecordWithThatId()
        {
            using (NeoStores neoStores = StoreFixture())
            {
                S store      = GetStore(neoStores);
                R record     = GetForce(store, ID + 1);
                R nullRecord = CreateNullRecord(ID + 1);
                AssertRecordsEqual(record, nullRecord);
            }
        }
Пример #15
0
        public static void RecomputeCounts(NeoStores stores, PageCache pageCache, DatabaseLayout databaseLayout)
        {
            MetaDataStore metaDataStore = stores.MetaDataStore;
            CountsTracker counts        = stores.Counts;

            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = Counts.reset(metaDataStore.LastCommittedTransactionId))
            {
                (new CountsComputer(stores, pageCache, databaseLayout)).Initialize(updater);
            }
        }
Пример #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            FileSystemAbstraction     fs = FileSystemRule.get();
            DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
            PageCache    pageCache = PageCacheRule.getPageCache(fs);
            StoreFactory factory   = new StoreFactory(TestDirectory.databaseLayout(), Config.defaults(), idGeneratorFactory, pageCache, fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            _neoStores  = factory.OpenAllNeoStores(true);
            _arrayStore = _neoStores.PropertyStore.ArrayStore;
        }
Пример #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustRetryInconsistentForcedReads()
        public virtual void MustRetryInconsistentForcedReads()
        {
            using (NeoStores neoStores = StoreFixture())
            {
                S store = GetStore(neoStores);
                _nextReadIsInconsistent.set(true);
                R record = GetForce(store, ID);
                AssertRecordsEqual(record, CreateExistingRecord(true));
            }
        }
Пример #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveSpecificCountsTrackerForReadOnlyDatabase() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHaveSpecificCountsTrackerForReadOnlyDatabase()
        {
            // when
            StoreFactory readOnlyStoreFactory = StoreFactory(Config.defaults(GraphDatabaseSettings.read_only, Settings.TRUE));

            _neoStores = readOnlyStoreFactory.OpenAllNeoStores(true);
            long lastClosedTransactionId = _neoStores.MetaDataStore.LastClosedTransactionId;

            // then
            assertEquals(-1, _neoStores.Counts.rotate(lastClosedTransactionId));
        }
Пример #19
0
 private void FlushIdFiles(NeoStores neoStores, StoreType[] storeTypes)
 {
     foreach (StoreType type in storeTypes)
     {
         if (type.RecordStore)
         {
             RecordStore <AbstractBaseRecord> recordStore = neoStores.GetRecordStore(type);
             Optional <File> idFile = _databaseLayout.idFile(type.DatabaseFile);
             idFile.ifPresent(f => _idGeneratorFactory.create(f, recordStore.HighId, false));
         }
     }
 }
Пример #20
0
        private NeoStores StoreFixture()
        {
            PageCache    pageCache = PageCacheRule.getPageCache(_fs, config().withInconsistentReads(_nextReadIsInconsistent));
            StoreFactory factory   = new StoreFactory(TestDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(_fs), pageCache, _fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            NeoStores    neoStores = factory.OpenAllNeoStores(true);
            S            store     = InitialiseStore(neoStores);

            CommonAbstractStore commonAbstractStore = ( CommonAbstractStore )store;

            commonAbstractStore.rebuildIdGenerator();
            return(neoStores);
        }
Пример #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void verifyDynamicSizedStoresCanRebuildIdGeneratorSlowly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void VerifyDynamicSizedStoresCanRebuildIdGeneratorSlowly()
        {
            // Given we have a store ...
            Config config = Config.defaults(GraphDatabaseSettings.rebuild_idgenerators_fast, "false");

            StoreFactory       storeFactory = new StoreFactory(_testDirectory.databaseLayout(), config, new DefaultIdGeneratorFactory(_fs), PageCacheRule.getPageCache(_fs), _fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            NeoStores          neoStores    = storeFactory.OpenAllNeoStores(true);
            DynamicStringStore store        = neoStores.PropertyStore.StringStore;

            // ... that contain a number of records ...
            DynamicRecord record = new DynamicRecord(1);

            record.SetInUse(true, PropertyType.String.intValue());
            int highestId = 50;

            for (int i = 1; i <= highestId; i++)                 // id '0' is the dynamic store header
            {
                assertThat(store.NextId(), @is((long)i));
                record.Id = i;
                StringBuilder sb = new StringBuilder(i);
                for (int j = 0; j < i; j++)
                {
                    sb.Append('a');
                }
                record.Data = sb.ToString().GetBytes(StandardCharsets.UTF_16);
                store.UpdateRecord(record);
            }
            store.HighestPossibleIdInUse = highestId;

            // ... and some have been deleted
            long?[] idsToFree = new long?[] { 2L, 3L, 5L, 7L };
            record.InUse = false;
            foreach (long toDelete in idsToFree)
            {
                record.Id = toDelete;
                store.UpdateRecord(record);
            }

            // Then when we rebuild the id generator
            store.RebuildIdGenerator();

            // We should observe that the ids above got freed
            IList <long> nextIds = new List <long>();

            nextIds.Add(store.NextId());                 // 2
            nextIds.Add(store.NextId());                 // 3
            nextIds.Add(store.NextId());                 // 5
            nextIds.Add(store.NextId());                 // 7
            nextIds.Add(store.NextId());                 // 51
            assertThat(nextIds, contains(2L, 3L, 5L, 7L, 51L));
            neoStores.Close();
        }
Пример #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDelegateDeletionOptionToStores()
        public virtual void ShouldDelegateDeletionOptionToStores()
        {
            // GIVEN
            StoreFactory storeFactory = storeFactory(Config.defaults(), DELETE_ON_CLOSE);

            // WHEN
            _neoStores = storeFactory.OpenAllNeoStores(true);
            assertTrue(_fsRule.get().listFiles(_testDirectory.databaseDir()).length >= StoreType.values().length);

            // THEN
            _neoStores.close();
            assertEquals(0, _fsRule.get().listFiles(_testDirectory.databaseDir()).length);
        }
Пример #23
0
            protected internal override LabelTokenStore InitialiseStore(NeoStores neoStores)
            {
                LabelTokenStore  store      = GetStore(neoStores);
                LabelTokenRecord record     = CreateExistingRecord(false);
                DynamicRecord    nameRecord = new DynamicRecord(NAME_RECORD_ID);

                record.NameRecords.Clear();
                nameRecord.Data  = NameRecordData;
                nameRecord.InUse = true;
                record.AddNameRecord(nameRecord);
                store.UpdateRecord(record);
                return(store);
            }
 private void PerformTest(File idFile)
 {
     // emulate the need for rebuilding id generators by deleting it
     _fs.deleteFile(idFile);
     try
     {
         using (NeoStores neoStores = _factory.openAllNeoStores())
         {
             // emulate a failure during rebuild:
         }
     }
     catch (UnderlyingStorageException expected)
     {
         assertThat(expected.Message, startsWith("Id capacity exceeded"));
     }
 }
Пример #25
0
        internal virtual CountsTracker CreateCountStore()
        {
            bool          readOnly  = _config.get(GraphDatabaseSettings.read_only);
            CountsTracker counts    = readOnly ? CreateReadOnlyCountsTracker(_layout) : CreateWritableCountsTracker(_layout);
            NeoStores     neoStores = this;

            Counts.Initializer = new DataInitializerAnonymousInnerClass(this, neoStores);

            try
            {
                Counts.init();                         // TODO: move this to LifeCycle
            }
            catch (IOException e)
            {
                throw new UnderlyingStorageException("Failed to initialize counts store", e);
            }
            return(counts);
        }
//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();
        }
Пример #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompletelyRebuildIdGeneratorsAfterCrash()
        public virtual void ShouldCompletelyRebuildIdGeneratorsAfterCrash()
        {
            // GIVEN
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            StoreFactory   storeFactory   = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(_fileSystemRule.get()), _pageCacheRule.getPageCache(_fileSystemRule.get()), _fileSystemRule.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            long           highId;

            using (NeoStores stores = storeFactory.OpenAllNeoStores(true))
            {
                // a node store with a "high" node
                NodeStore nodeStore = stores.NodeStore;
                nodeStore.HighId = 20;
                nodeStore.UpdateRecord(Node(nodeStore.NextId()));
                highId = nodeStore.HighId;
            }

            // populating its .id file with a bunch of ids
            File nodeIdFile = databaseLayout.IdNodeStore();

            using (IdGeneratorImpl idGenerator = new IdGeneratorImpl(_fileSystemRule.get(), nodeIdFile, 10, 10_000, false, IdType.NODE, () => highId))
            {
                for (long id = 0; id < 15; id++)
                {
                    idGenerator.FreeId(id);
                }

                // WHEN
                using (NeoStores stores = storeFactory.OpenAllNeoStores(true))
                {
                    NodeStore nodeStore = stores.NodeStore;
                    assertFalse(nodeStore.StoreOk);

                    // simulating what recovery does
                    nodeStore.DeleteIdGenerator();
                    // recovery happens here...
                    nodeStore.MakeStoreOk();

                    // THEN
                    assertEquals(highId, nodeStore.NextId());
                }
            }
        }
Пример #28
0
        private void InstantiateStores()
        {
            _neoStores                  = NewStoreFactory(_databaseLayout).openAllNeoStores(true);
            _propertyKeyRepository      = new BatchingPropertyKeyTokenRepository(_neoStores.PropertyKeyTokenStore);
            _labelRepository            = new BatchingLabelTokenRepository(_neoStores.LabelTokenStore);
            _relationshipTypeRepository = new BatchingRelationshipTypeTokenRepository(_neoStores.RelationshipTypeTokenStore);
            _temporaryNeoStores         = InstantiateTempStores();
            InstantiateKernelExtensions();

            // Delete the id generators because makeStoreOk isn't atomic in the sense that there's a possibility of an unlucky timing such
            // that if the process is killed at the right time some store may end up with a .id file that looks to be CLEAN and has highId=0,
            // i.e. effectively making the store look empty on the next start. Normal recovery of a db is sort of protected by this recovery
            // recognizing that the db needs recovery when it looks at the tx log and also calling deleteIdGenerators. In the import case
            // there are no tx logs at all, and therefore we do this manually right here.
            _neoStores.deleteIdGenerators();
            _temporaryNeoStores.deleteIdGenerators();

            _neoStores.makeStoreOk();
            _temporaryNeoStores.makeStoreOk();
        }
Пример #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustCloseAllStoresIfNeoStoresFailToOpen()
        public virtual void MustCloseAllStoresIfNeoStoresFailToOpen()
        {
            PageCache              pageCache      = Rules.pageCache();
            DatabaseLayout         databaseLayout = Rules.directory().databaseLayout();
            Config                 config         = Config.defaults();
            FileSystemAbstraction  fs             = Rules.fileSystem();
            IdGeneratorFactory     idGenFactory   = new DefaultIdGeneratorFactory(fs);
            LogProvider            logProvider    = NullLogProvider.Instance;
            VersionContextSupplier versions       = EmptyVersionContextSupplier.EMPTY;
            RecordFormats          formats        = Standard.LATEST_RECORD_FORMATS;

            (new RecordFormatPropertyConfigurator(formats, config)).configure();
            bool create = true;

            StoreType[]  storeTypes  = StoreType.values();
            OpenOption[] openOptions = new OpenOption[0];
            NeoStores    neoStores   = new NeoStores(databaseLayout, config, idGenFactory, pageCache, logProvider, fs, versions, formats, create, storeTypes, openOptions);
            File         schemaStore = neoStores.SchemaStore.StorageFile;

            neoStores.Close();

            // Make the schema store inaccessible, to sabotage the next initialisation we'll do.
            assumeTrue(schemaStore.setReadable(false));
            assumeTrue(schemaStore.setWritable(false));

            try
            {
                // This should fail due to the permissions we changed above.
                // And when it fails, the already-opened stores should be closed.
                new NeoStores(databaseLayout, config, idGenFactory, pageCache, logProvider, fs, versions, formats, create, storeTypes, openOptions);
                fail("Opening NeoStores should have thrown.");
            }
            catch (Exception)
            {
            }

            // We verify that the successfully opened stores were closed again by the failed NeoStores open,
            // by closing the page cache, which will throw if not all files have been unmapped.
            pageCache.Close();
        }
Пример #30
0
//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());
            }
        }