private SortedList <CSPrice> LoadDayPrices(int day) { SortedList <CSPrice> ret = new SortedList <CSPrice>(Comp_CSPrice); ret.AddRange(StorageLoader.LoadStorage(DateToDay.ToDate(day), CurrencyPair)); return(ret); }
public static void Main(string[] args) { var folder = args.Length > 0 ? args[0] : null; var loader = new StorageLoader(Storage.Instance); loader.Load(folder == null ? "/tmp/data/" : @"C:\Old\MyProjects\core\hlcup2018\" + folder + @"\data"); GetHostBuilder().Build().Run(); }
public ConfigurationStorage(DocumentDatabase db) { var path = db.Configuration.Core.DataDirectory.Combine("Configuration"); string tempPath = null; if (db.Configuration.Storage.TempPath != null) { tempPath = db.Configuration.Storage.TempPath.Combine("Configuration").ToFullPath(); } var options = db.Configuration.Core.RunInMemory ? StorageEnvironmentOptions.CreateMemoryOnly(path.FullPath, tempPath, db.IoChanges, db.CatastrophicFailureNotification) : StorageEnvironmentOptions.ForPath(path.FullPath, tempPath, null, db.IoChanges, db.CatastrophicFailureNotification); options.OnNonDurableFileSystemError += db.HandleNonDurableFileSystemError; options.OnRecoverableFailure += db.HandleRecoverableFailure; options.OnRecoveryError += db.HandleOnConfigurationRecoveryError; options.OnIntegrityErrorOfAlreadySyncedData += db.HandleOnConfigurationIntegrityErrorOfAlreadySyncedData; options.CompressTxAboveSizeInBytes = db.Configuration.Storage.CompressTxAboveSize.GetValue(SizeUnit.Bytes); options.SchemaVersion = SchemaUpgrader.CurrentVersion.ConfigurationVersion; options.SchemaUpgrader = SchemaUpgrader.Upgrader(SchemaUpgrader.StorageType.Configuration, this, null, null); options.ForceUsing32BitsPager = db.Configuration.Storage.ForceUsing32BitsPager; options.EnablePrefetching = db.Configuration.Storage.EnablePrefetching; options.DiscardVirtualMemory = db.Configuration.Storage.DiscardVirtualMemory; options.TimeToSyncAfterFlushInSec = (int)db.Configuration.Storage.TimeToSyncAfterFlush.AsTimeSpan.TotalSeconds; options.NumOfConcurrentSyncsPerPhysDrive = db.Configuration.Storage.NumberOfConcurrentSyncsPerPhysicalDrive; options.Encryption.MasterKey = db.MasterKey?.ToArray(); options.DoNotConsiderMemoryLockFailureAsCatastrophicError = db.Configuration.Security.DoNotConsiderMemoryLockFailureAsCatastrophicError; if (db.Configuration.Storage.MaxScratchBufferSize.HasValue) { options.MaxScratchBufferSize = db.Configuration.Storage.MaxScratchBufferSize.Value.GetValue(SizeUnit.Bytes); } options.PrefetchSegmentSize = db.Configuration.Storage.PrefetchBatchSize.GetValue(SizeUnit.Bytes); options.PrefetchResetThreshold = db.Configuration.Storage.PrefetchResetThreshold.GetValue(SizeUnit.Bytes); options.SyncJournalsCountThreshold = db.Configuration.Storage.SyncJournalsCountThreshold; options.IgnoreInvalidJournalErrors = db.Configuration.Storage.IgnoreInvalidJournalErrors; options.SkipChecksumValidationOnDatabaseLoading = db.Configuration.Storage.SkipChecksumValidationOnDatabaseLoading; options.IgnoreDataIntegrityErrorsOfAlreadySyncedTransactions = db.Configuration.Storage.IgnoreDataIntegrityErrorsOfAlreadySyncedTransactions; options.MaxNumberOfRecyclableJournals = db.Configuration.Storage.MaxNumberOfRecyclableJournals; DirectoryExecUtils.SubscribeToOnDirectoryInitializeExec(options, db.Configuration.Storage, db.Name, DirectoryExecUtils.EnvironmentType.Configuration, Logger); NotificationsStorage = new NotificationsStorage(db.Name); OperationsStorage = new OperationsStorage(); Environment = StorageLoader.OpenEnvironment(options, StorageEnvironmentWithType.StorageEnvironmentType.Configuration); ContextPool = new TransactionContextPool(Environment, db.Configuration.Memory.MaxContextSizeToKeep); }
public async Task FindSamples(string transcriptId, LongRunningRecognizeResponse recognizeResponse, string sourceUri, string originUri) { var result = recognizeResponse.Results.Last(); if (result == null) { throw new ArgumentException("Empty recognition response. Cannot find samples."); } var words = result.Alternatives.Last().Words; int currentSpeakerTag = -1; List <WordInfo> currentSampleWords = new List <WordInfo>(); List <Sample> samples = new List <Sample>(); foreach (WordInfo wordInfo in words) { if (currentSpeakerTag == -1) { currentSpeakerTag = wordInfo.SpeakerTag; currentSampleWords.Add(wordInfo); } else { if (currentSpeakerTag != wordInfo.SpeakerTag) // save new sample { await AddSample(); //switch speaker currentSampleWords.Clear(); currentSpeakerTag = wordInfo.SpeakerTag; } else { currentSampleWords.Add(wordInfo); } } } //last sample await AddSample(); var samplesToSave = new SamplesCollection() { samples = samples, transcriptId = transcriptId, VideoUri = originUri }; var connectionString = Environment.GetEnvironmentVariable("MONGO_CONNECT_STR"); var database = CosmosUtils.ConnectToDatabase(connectionString, "Samples"); var collection = database.GetCollection <SamplesCollection>("Samples"); await CosmosUtils.AddDocumentAsync(collection, samplesToSave); foreach (var invoiceEntity in await CosmosUtils.GetAllAsync(collection)) { Console.WriteLine(invoiceEntity.transcriptId); } async Task AddSample() { var orderedWords = currentSampleWords.OrderBy(w => w.StartTime.Nanos); var firstWord = orderedWords.First(); var lastWord = orderedWords.Last(); Duration duration = orderedWords.Last().EndTime - orderedWords.First().StartTime; string trimmedFile = AudioTrimmer.SaveTrimmed( (int)(firstWord.StartTime.Seconds * 1000) + firstWord.StartTime.Nanos / 1000_000, (int)(lastWord.EndTime.Seconds * 1000) + lastWord.EndTime.Nanos / 1000_000, sourceUri); string blobName = await StorageLoader.PutIntoBlob(trimmedFile); samples.Add(new Sample() { duration = (int)(duration.Seconds * 1000) + duration.Nanos / 1000_000, wordCount = orderedWords.Count(), speakerId = currentSpeakerTag, startTime = firstWord.StartTime.ToTimeSpan().ToString("g"), endTime = lastWord.EndTime.ToTimeSpan().ToString("g"), storageUri = $"{StorageLoader.BlobServiceClient.Uri}{StorageLoader.BlobName}/{blobName}", text = string.Join(' ', currentSampleWords.Select(w => w.Word)) }); }