Beispiel #1
0
        protected override string WriteIndexObjectToFile(HyperLogLog indexObject)
        {
            var outputFileName = Path.Combine(CommonKeys.TEMP_FOLDER_NAME, Guid.NewGuid().ToString());
            var outputStream   = FileCreator.OpenFileWriteAndCreatePath(outputFileName);

            indexObject.SerializeToStream(outputStream);
            return(outputFileName);
        }
Beispiel #2
0
 private static async Task WriteIndexRowsToFile(string outputFileName, IAsyncEnumerable <RootIndexRow> outputRows)
 {
     using var outputFile         = FileCreator.OpenFileWriteAndCreatePath(outputFileName);
     using var outputStreamWriter = new StreamWriter(outputFile);
     await foreach (var outputRow in outputRows)
     {
         await outputStreamWriter.WriteObjectToLineAsync(outputRow);
     }
 }
Beispiel #3
0
        private async Task <RootIndexRow> MergeIndexValuesToFile(IAsyncEnumerable <IndexValueModel> indexValues, string outputFilename)
        {
            using var outputFile         = FileCreator.OpenFileWriteAndCreatePath(outputFilename);
            using var outputStreamWriter = new StreamWriter(outputFile);
            var rowsMetadata = await WriteIndexValuesToFile(indexValues, outputStreamWriter);

            await outputStreamWriter.FlushAsync();

            var newMetadataOffset = outputFile.Position;
            var rootIndexRow      = await AddUpdatedMetadataToFile(rowsMetadata, outputStreamWriter);

            rootIndexRow.FileName = outputFilename;
            await outputStreamWriter.FlushAsync();

            var bloomOffset = outputFile.Position;

            await AddBloomFilterToIndex(rowsMetadata, outputFile);

            await outputFile.FlushAsync();

            outputFile.WriteBinaryLongsToStream(new[] { newMetadataOffset, bloomOffset });
            return(rootIndexRow);
        }