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 virtual void Write(V value) { Preconditions.CheckNotNullArgument(value); GenericRecord record = ValueDef.GetRecord(value); mWriter.Append(record); mWriter.Sync(); }
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); } }
public bool TryGet(string key, out V value) { Preconditions.CheckNotNullArgument(key); long position; if (Index.TryGetEntry(key, out position)) { if (position == 0) { mReader.Sync(position); } // lib issue workaround else { mReader.Seek(position); } value = ValueDef.GetValue(mReader.Next()); return(true); } value = default(V); return(false); }
public bool MoveNext() { Current = ValueDef.GetValue(mReader.Next()); return(mReader.HasNext()); }