Пример #1
0
        /// <summary>
        /// Opens an existing conversation table persisted in the specified folder.
        /// </summary>
        /// <param name="folder">The folder containing conversation table files.</param>
        /// <returns>New instance of the conversation table.</returns>
        public static FasterConversationTable Open(string folder)
        {
            if (!Directory.Exists(folder))
            {
                throw new DirectoryNotFoundException($"Specified folder '{folder}' not found.");
            }
            var config = new Configuration(Path.Combine(folder, "settings.json")).Load();
            var table  = new FasterConversationTable(folder, config);

            table._conversationsStore.InitAndRecover();
            table._framesStore.InitAndRecover();
            return(table);
        }
Пример #2
0
        /// <summary>
        /// Creates a new conversation table.
        /// </summary>
        /// <param name="folder">The destination folder to persist conversation table.</param>
        /// <param name="framesCapacity">The expected frame capacity of the table. The conversation table offerst bets performance and space
        /// if the actual frame number is around this value.</param>
        /// <param name="flowFrameRatio">The expected ratio between flows and frames. It can be computed as "1 / average frames per flow".</param>
        /// <returns>New instance of the conversation table.</returns>
        public static FasterConversationTable Create(string folder, long framesCapacity, double flowFrameRatio = DefaultFlowsFrameRatio)
        {
            // ensure that root folder does exist:
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            var config = new Configuration(Path.Combine(folder, "settings.json"))
            {
                FramesCapacity        = framesCapacity,
                ConversationsCapacity = (long)(framesCapacity * flowFrameRatio)
            };

            config.Save();  // need to save as we create a new configuration
            var table = new FasterConversationTable(folder, config);

            table._conversationsStore.InitAndRecover();
            table._framesStore.InitAndRecover();
            return(table);
        }