Exemplo n.º 1
0
        /// <summary>
        /// Select explicitly configured record format (via given {@code config}) or format from the store. If store does
        /// not exist or has old format (<seealso cref="RecordFormats.generation()"/>) than this method returns
        /// <seealso cref="DEFAULT_FORMAT"/>.
        /// </summary>
        /// <param name="config"> configuration parameters </param>
        /// <param name="databaseLayout"> database directory structure </param>
        /// <param name="fs"> file system used to access store files </param>
        /// <param name="pageCache"> page cache to read store files </param>
        /// <returns> record format from the store (if it can be read) or configured record format or <seealso cref="DEFAULT_FORMAT"/> </returns>
        /// <seealso cref= RecordFormats#generation() </seealso>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Nonnull public static RecordFormats selectNewestFormat(org.neo4j.kernel.configuration.Config config, org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pageCache, org.neo4j.logging.LogProvider logProvider)
        public static RecordFormats SelectNewestFormat(Config config, DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider)
        {
            bool formatConfigured = StringUtils.isNotEmpty(ConfiguredRecordFormat(config));

            if (formatConfigured)
            {
                // format was explicitly configured so select it
                return(SelectForConfig(config, logProvider));
            }
            else
            {
                RecordFormats result = SelectForStore(databaseLayout, fs, pageCache, logProvider);
                if (result == null)
                {
                    // format was not explicitly configured and store does not exist, select default format
                    Info(logProvider, "Selected format '" + _defaultFormat + "' for the new store");
                    result = _defaultFormat;
                }
                else if (FormatFamily.IsHigherFamilyFormat(_defaultFormat, result) || (FormatFamily.IsSameFamily(result, _defaultFormat) && (result.Generation() < _defaultFormat.generation())))
                {
                    // format was not explicitly configured and store has lower format
                    // select default format, upgrade is intended
                    Info(logProvider, "Selected format '" + _defaultFormat + "' for existing store with format '" + result + "'");
                    result = _defaultFormat;
                }
                return(result);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds which format, if any, succeeded the specified format. Only formats in the same family are considered.
        /// </summary>
        /// <param name="format"> to find successor to. </param>
        /// <returns> the format with the lowest generation > format.generation, or None if no such format is known. </returns>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Nonnull public static java.util.Optional<RecordFormats> findSuccessor(@Nonnull final RecordFormats format)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public static Optional <RecordFormats> FindSuccessor(RecordFormats format)
        {
            return(StreamSupport.stream(RecordFormatSelector.AllFormats().spliterator(), false).filter(candidate => FormatFamily.IsSameFamily(format, candidate)).filter(candidate => candidate.generation() > format.Generation()).reduce((a, b) => a.generation() < b.generation() ? a : b));
        }