Пример #1
0
        async Task WriteMultipleLogs(List <WriteEntry> entries, CancellationToken cancellationToken)
        {
            if (entries.Count == 0)
            {
                return;
            }
            var entriesPerLog = (int)options.MaxWriteLogSize / WriteEntry.RowBytes();

            var enumerable = entries.AsEnumerable();

            while (enumerable.Any())
            {
                var batch = enumerable.Take(entriesPerLog);
                enumerable = enumerable.Skip(entriesPerLog);

                var bytes = new List <byte>(batch.Count());
                foreach (var entry in batch)
                {
                    entry.SerializeTo(bytes);
                }

                await store.WriteBytes(shardId, GetNewLogName(), bytes.ToArray(), cancellationToken);
            }
        }