예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void prepareBatchImportMigration(org.neo4j.io.layout.DatabaseLayout sourceDirectoryStructure, org.neo4j.io.layout.DatabaseLayout migrationStrcuture, org.neo4j.kernel.impl.store.format.RecordFormats oldFormat, org.neo4j.kernel.impl.store.format.RecordFormats newFormat) throws java.io.IOException
        private void PrepareBatchImportMigration(DatabaseLayout sourceDirectoryStructure, DatabaseLayout migrationStrcuture, RecordFormats oldFormat, RecordFormats newFormat)
        {
            CreateStore(migrationStrcuture, newFormat);

            // We use the batch importer for migrating the data, and we use it in a special way where we only
            // rewrite the stores that have actually changed format. We know that to be node and relationship
            // stores. Although since the batch importer also populates the counts store, all labels need to
            // be read, i.e. both inlined and those existing in dynamic records. That's why we need to copy
            // that dynamic record store over before doing the "batch import".
            //   Copying this file just as-is assumes that the format hasn't change. If that happens we're in
            // a different situation, where we first need to migrate this file.

            // The token stores also need to be migrated because we use those as-is and ask for their high ids
            // when using the importer in the store migration scenario.
            DatabaseFile[] storesFilesToMigrate = new DatabaseFile[] { DatabaseFile.LABEL_TOKEN_STORE, DatabaseFile.LABEL_TOKEN_NAMES_STORE, DatabaseFile.PROPERTY_KEY_TOKEN_STORE, DatabaseFile.PROPERTY_KEY_TOKEN_NAMES_STORE, DatabaseFile.RELATIONSHIP_TYPE_TOKEN_STORE, DatabaseFile.RELATIONSHIP_TYPE_TOKEN_NAMES_STORE, DatabaseFile.NODE_LABEL_STORE };
            if (newFormat.Dynamic().Equals(oldFormat.Dynamic()))
            {
                fileOperation(COPY, _fileSystem, sourceDirectoryStructure, migrationStrcuture, Arrays.asList(storesFilesToMigrate), true, ExistingTargetStrategy.FAIL);
            }
            else
            {
                // Migrate all token stores, schema store and dynamic node label ids, keeping their ids intact
                DirectRecordStoreMigrator migrator = new DirectRecordStoreMigrator(_pageCache, _fileSystem, _config);

                StoreType[] storesToMigrate = new StoreType[] { StoreType.LABEL_TOKEN, StoreType.LABEL_TOKEN_NAME, StoreType.PROPERTY_KEY_TOKEN, StoreType.PROPERTY_KEY_TOKEN_NAME, StoreType.RELATIONSHIP_TYPE_TOKEN, StoreType.RELATIONSHIP_TYPE_TOKEN_NAME, StoreType.NODE_LABEL, StoreType.SCHEMA };

                // Migrate these stores silently because they are usually very small
                ProgressReporter progressReporter = SilentProgressReporter.INSTANCE;

                migrator.Migrate(sourceDirectoryStructure, oldFormat, migrationStrcuture, newFormat, progressReporter, storesToMigrate, StoreType.NODE);
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void migrateWithBatchImporter(org.neo4j.io.layout.DatabaseLayout sourceDirectoryStructure, org.neo4j.io.layout.DatabaseLayout migrationDirectoryStructure, long lastTxId, long lastTxChecksum, long lastTxLogVersion, long lastTxLogByteOffset, org.neo4j.kernel.impl.util.monitoring.ProgressReporter progressReporter, org.neo4j.kernel.impl.store.format.RecordFormats oldFormat, org.neo4j.kernel.impl.store.format.RecordFormats newFormat) throws java.io.IOException
        private void MigrateWithBatchImporter(DatabaseLayout sourceDirectoryStructure, DatabaseLayout migrationDirectoryStructure, long lastTxId, long lastTxChecksum, long lastTxLogVersion, long lastTxLogByteOffset, ProgressReporter progressReporter, RecordFormats oldFormat, RecordFormats newFormat)
        {
            PrepareBatchImportMigration(sourceDirectoryStructure, migrationDirectoryStructure, oldFormat, newFormat);

            bool requiresDynamicStoreMigration = !newFormat.Dynamic().Equals(oldFormat.Dynamic());
            bool requiresPropertyMigration     = !newFormat.Property().Equals(oldFormat.Property()) || requiresDynamicStoreMigration;
            File badFile = sourceDirectoryStructure.File([email protected]_Fields.BAD_FILE_NAME);

            using (NeoStores legacyStore = InstantiateLegacyStore(oldFormat, sourceDirectoryStructure), Stream badOutput = new BufferedOutputStream(new FileStream(badFile, false)))
            {
                Configuration        importConfig         = new Configuration_OverriddenAnonymousInnerClass(this, _config, sourceDirectoryStructure);
                AdditionalInitialIds additionalInitialIds = ReadAdditionalIds(lastTxId, lastTxChecksum, lastTxLogVersion, lastTxLogByteOffset);

                // We have to make sure to keep the token ids if we're migrating properties/labels
                BatchImporter   importer          = BatchImporterFactory.withHighestPriority().instantiate(migrationDirectoryStructure, _fileSystem, _pageCache, importConfig, _logService, withDynamicProcessorAssignment(MigrationBatchImporterMonitor(legacyStore, progressReporter, importConfig), importConfig), additionalInitialIds, _config, newFormat, NO_MONITOR, _jobScheduler);
                InputIterable   nodes             = () => LegacyNodesAsInput(legacyStore, requiresPropertyMigration);
                InputIterable   relationships     = () => LegacyRelationshipsAsInput(legacyStore, requiresPropertyMigration);
                long            propertyStoreSize = StoreSize(legacyStore.PropertyStore) / 2 + StoreSize(legacyStore.PropertyStore.StringStore) / 2 + StoreSize(legacyStore.PropertyStore.ArrayStore) / 2;
                Input_Estimates estimates         = knownEstimates(legacyStore.NodeStore.NumberOfIdsInUse, legacyStore.RelationshipStore.NumberOfIdsInUse, legacyStore.PropertyStore.NumberOfIdsInUse, legacyStore.PropertyStore.NumberOfIdsInUse, propertyStoreSize / 2, propertyStoreSize / 2, 0);
                importer.DoImport(Inputs.input(nodes, relationships, IdMappers.actual(), Collectors.badCollector(badOutput, 0), estimates));

                // During migration the batch importer doesn't necessarily writes all entities, depending on
                // which stores needs migration. Node, relationship, relationship group stores are always written
                // anyways and cannot be avoided with the importer, but delete the store files that weren't written
                // (left empty) so that we don't overwrite those in the real store directory later.
                ICollection <DatabaseFile> storesToDeleteFromMigratedDirectory = new List <DatabaseFile>();
                storesToDeleteFromMigratedDirectory.Add(DatabaseFile.METADATA_STORE);
                if (!requiresPropertyMigration)
                {
                    // We didn't migrate properties, so the property stores in the migrated store are just empty/bogus
                    storesToDeleteFromMigratedDirectory.addAll(asList(DatabaseFile.PROPERTY_STORE, DatabaseFile.PROPERTY_STRING_STORE, DatabaseFile.PROPERTY_ARRAY_STORE));
                }
                if (!requiresDynamicStoreMigration)
                {
                    // We didn't migrate labels (dynamic node labels) or any other dynamic store
                    storesToDeleteFromMigratedDirectory.addAll(asList(DatabaseFile.NODE_LABEL_STORE, DatabaseFile.LABEL_TOKEN_STORE, DatabaseFile.LABEL_TOKEN_NAMES_STORE, DatabaseFile.RELATIONSHIP_TYPE_TOKEN_STORE, DatabaseFile.RELATIONSHIP_TYPE_TOKEN_NAMES_STORE, DatabaseFile.PROPERTY_KEY_TOKEN_STORE, DatabaseFile.PROPERTY_KEY_TOKEN_NAMES_STORE, DatabaseFile.SCHEMA_STORE));
                }
                fileOperation(DELETE, _fileSystem, migrationDirectoryStructure, migrationDirectoryStructure, storesToDeleteFromMigratedDirectory, true, null);
            }
        }
예제 #3
0
 public SchemaStore(File file, File idFile, Config conf, IdType idType, IdGeneratorFactory idGeneratorFactory, PageCache pageCache, LogProvider logProvider, RecordFormats recordFormats, params OpenOption[] openOptions) : base(file, idFile, conf, idType, idGeneratorFactory, pageCache, logProvider, TYPE_DESCRIPTOR, BLOCK_SIZE, recordFormats.Dynamic(), recordFormats.StoreVersion(), openOptions)
 {
 }
예제 #4
0
        public override bool Equals(object obj)
        {
            if (!(obj is RecordFormats))
            {
                return(false);
            }

            RecordFormats other = ( RecordFormats )obj;

            return(Node().Equals(other.Node()) && Relationship().Equals(other.Relationship()) && RelationshipGroup().Equals(other.RelationshipGroup()) && Property().Equals(other.Property()) && LabelToken().Equals(other.LabelToken()) && RelationshipTypeToken().Equals(other.RelationshipTypeToken()) && PropertyKeyToken().Equals(other.PropertyKeyToken()) && Dynamic().Equals(other.Dynamic()));
        }
예제 #5
0
 public DynamicArrayStore(File file, File idFile, Config configuration, IdType idType, IdGeneratorFactory idGeneratorFactory, PageCache pageCache, LogProvider logProvider, int dataSizeFromConfiguration, RecordFormats recordFormats, params OpenOption[] openOptions) : base(file, idFile, configuration, idType, idGeneratorFactory, pageCache, logProvider, TYPE_DESCRIPTOR, dataSizeFromConfiguration, recordFormats.Dynamic(), recordFormats.StoreVersion(), openOptions)
 {
     _allowStorePointsAndTemporal = recordFormats.HasCapability(Capability.POINT_PROPERTIES) && recordFormats.HasCapability(Capability.TEMPORAL_PROPERTIES);
 }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void makeSureIdCapacityCannotBeExceeded()
        public virtual void MakeSureIdCapacityCannotBeExceeded()
        {
            RecordFormats formats = Standard.LATEST_RECORD_FORMATS;
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.neo4j.kernel.impl.store.format.RecordFormat<? extends org.neo4j.kernel.impl.store.record.AbstractBaseRecord>> recordFormats = java.util.Arrays.asList(formats.node(), formats.dynamic(), formats.labelToken(), formats.property(), formats.propertyKeyToken(), formats.relationship(), formats.relationshipGroup(), formats.relationshipTypeToken());
            IList <RecordFormat <AbstractBaseRecord> > recordFormats = Arrays.asList(formats.Node(), formats.Dynamic(), formats.LabelToken(), formats.Property(), formats.PropertyKeyToken(), formats.Relationship(), formats.RelationshipGroup(), formats.RelationshipTypeToken());

            foreach (RecordFormat format in recordFormats)
            {
                MakeSureIdCapacityCannotBeExceeded(format);
            }
        }