Exemplo n.º 1
0
        public void Add(ISerie <TKey, TEntry> serie)
        {
            var newEntries = serie.GetEntries();

            ISerie <TKey, TEntry> existing;

            if (_series.TryGetValue(serie.GetKey(), out existing))
            {
                var existingEntries = existing.GetEntries();

                var list = existingEntries as List <TEntry>;
                if (list != null)
                {
                    list.AddRange(newEntries);
                }
                else
                {
                    foreach (var entry in newEntries)
                    {
                        existingEntries.Add(entry);
                    }
                }
            }
            else
            {
                _series.Add(serie.GetKey(), serie);
            }

            _count += newEntries.Count;
        }
Exemplo n.º 2
0
        public Task Write(ISerie <TKey, TEntry> serie)
        {
            lock ( _sync )
            {
                var key = serie.GetKey();
                if (!_queued.TryGetValue(key, out var existingBatchWrite))
                {
                    existingBatchWrite = new BatchWrite <TKey, TEntry>(serie);
                    _queued.Add(key, existingBatchWrite);
                    _keys.AddLast(key);
                }
                else
                {
                    existingBatchWrite.Add(serie);
                }

                _queuedCount += serie.GetEntries().Count;

                return(existingBatchWrite.Task);
            }
        }