public void BuildMasterIndex() { lock (mMasterIndex) { mMasterIndex.Clear(); foreach (string location in Directory.EnumerateFiles(RootDirectory, "*.avro", SearchOption.AllDirectories)) { DateTime time; string key; if (ValueLocationStrategy.TryGetKey(location, out time, out key)) { try { foreach (string k in GetIndex(location).Get().Keys) { Guid guid = Guid.Parse(k); string value = ValueLocationStrategy.GetLocation(time, k); mMasterIndex.Add(guid, value); } } catch { } } } } }
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 V GetValue(DateTime time, string key) { AvroRandomAccessReader <V> reader = GetReader(ValueLocationStrategy.GetLocation(time, key)); if (reader == null) { throw new Exception(string.Format("Document could not be located: {0} - {1}", time, key)); } return(reader.Get(key)); }
public bool TryGetDocument(DateTime time, string key, out V value) { AvroRandomAccessReader <V> reader = GetReader(ValueLocationStrategy.GetLocation(time, key)); if (reader != null) { value = reader.Get(key); return(true); } value = default(V); return(false); }
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); } }