public void AddDocuments(DateTime time, IEnumerable <V> valueList) { var writers = new Dictionary <string, AvroRandomAccessWriter <V> >(); try { foreach (V value in valueList) { string key = ValueDef.GetValueKey(value); string location = ValueLocationStrategy.GetLocation(time, key); AvroRandomAccessWriter <V> writer; if (!writers.TryGetValue(location, out writer)) { writer = GetWriter(location); writers.Add(location, writer); } writer.Write(value); lock (mMasterIndex) { mMasterIndex.Add(Guid.Parse(key), location); } } } finally { foreach (KeyValuePair <string, AvroRandomAccessWriter <V> > pair in writers) { pair.Value.Dispose(); } } }
public override void Write(V value) { Preconditions.CheckNotNullArgument(value); GenericRecord record = ValueDef.GetRecord(value); long position = mWriter.Sync(); mWriter.Append(record); Index.AddEntry(ValueDef.GetValueKey(value), position); }
public void AddValue(DateTime time, V value) { string key = ValueDef.GetValueKey(value); string location = ValueLocationStrategy.GetLocation(time, key); using (AvroRandomAccessWriter <V> writer = GetWriter(location)) { writer.Write(value); }; lock (mMasterIndex) { mMasterIndex.Add(Guid.Parse(key), location); } }