Ejemplo n.º 1
0
 private void AssertNoContentInNativeLabelScanStore(DatabaseLayout databaseLayout)
 {
     using (Lifespan lifespan = new Lifespan())
     {
         NativeLabelScanStore nativeLabelScanStore = GetNativeLabelScanStore(databaseLayout, true);
         lifespan.Add(nativeLabelScanStore);
         using (LabelScanReader labelScanReader = nativeLabelScanStore.NewReader())
         {
             int count = PrimitiveLongCollections.count(labelScanReader.NodesWithLabel(1));
             assertEquals(0, count);
         }
     }
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void initializeNativeLabelScanStoreWithContent(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException
        private void InitializeNativeLabelScanStoreWithContent(DatabaseLayout databaseLayout)
        {
            using (Lifespan lifespan = new Lifespan())
            {
                NativeLabelScanStore nativeLabelScanStore = GetNativeLabelScanStore(databaseLayout, false);
                lifespan.Add(nativeLabelScanStore);
                using (LabelScanWriter labelScanWriter = nativeLabelScanStore.NewWriter())
                {
                    labelScanWriter.Write(NodeLabelUpdate.labelChanges(1, new long[0], new long[] { 1 }));
                }
                nativeLabelScanStore.Force(Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited);
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void deleteNativeIndexFile(org.neo4j.io.layout.DatabaseLayout directoryStructure) throws java.io.IOException
        private void DeleteNativeIndexFile(DatabaseLayout directoryStructure)
        {
            Optional <FileHandle> indexFile = _fileSystem.streamFilesRecursive(NativeLabelScanStore.getLabelScanStoreFile(directoryStructure)).findFirst();

            if (indexFile.Present)
            {
                try
                {
                    indexFile.get().delete();
                }
                catch (NoSuchFileException)
                {
                    // Already deleted, ignore
                }
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void migrate(org.neo4j.io.layout.DatabaseLayout directoryLayout, org.neo4j.io.layout.DatabaseLayout migrationLayout, org.neo4j.kernel.impl.util.monitoring.ProgressReporter progressReporter, String versionToMigrateFrom, String versionToMigrateTo) throws java.io.IOException
        public override void Migrate(DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressReporter, string versionToMigrateFrom, string versionToMigrateTo)
        {
            if (IsNativeLabelScanStoreMigrationRequired(directoryLayout))
            {
                StoreFactory storeFactory = GetStoreFactory(directoryLayout, versionToMigrateFrom);
                using (NeoStores neoStores = storeFactory.OpenAllNeoStores(), Lifespan lifespan = new Lifespan())
                {
                    neoStores.VerifyStoreOk();
                    // Remove any existing file to ensure we always do migration
                    DeleteNativeIndexFile(migrationLayout);

                    progressReporter.Start(neoStores.NodeStore.NumberOfIdsInUse);
                    NativeLabelScanStore nativeLabelScanStore = GetNativeLabelScanStore(migrationLayout, progressReporter, neoStores);
                    lifespan.Add(nativeLabelScanStore);
                }
                _nativeLabelScanStoreMigrated = true;
            }
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void populateNativeLabelScanIndexDuringMigration() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PopulateNativeLabelScanIndexDuringMigration()
        {
            Prepare34DatabaseWithNodes();
            _indexMigrator.migrate(_databaseLayout, _migrationLayout, _progressReporter, StandardV3_4.STORE_VERSION, StandardV3_4.STORE_VERSION);
            _indexMigrator.moveMigratedFiles(_migrationLayout, _databaseLayout, StandardV2_3.STORE_VERSION, StandardV3_2.STORE_VERSION);

            using (Lifespan lifespan = new Lifespan())
            {
                NativeLabelScanStore labelScanStore = GetNativeLabelScanStore(_databaseLayout, true);
                lifespan.Add(labelScanStore);
                for (int labelId = 0; labelId < 10; labelId++)
                {
                    using (LabelScanReader labelScanReader = labelScanStore.NewReader())
                    {
                        int nodeCount = PrimitiveLongCollections.count(labelScanReader.NodesWithLabel(labelId));
                        assertEquals(format("Expected to see only one node for label %d but was %d.", labelId, nodeCount), 1, nodeCount);
                    }
                }
            }
        }