// Values returns a copy of all values, deduped and sorted, for the given key. public ClockValues Values(ulong sid) { ClockValues e = null, snap = null; lock (lockthis) { if (store.ContainsKey(sid)) { e = store[sid]; } if (snapshot != null && snapshot.store.ContainsKey(sid)) { snap = snapshot.store[sid]; } } if (e == null && snap == null) { return(null); } else if (e == null) { return(new ClockValues(snap)); } else if (snap == null) { return(new ClockValues(e)); } else { ClockValues result = new ClockValues(e); result.AddRange(snap); return(result); } }
public Dictionary <ulong, ClockValues> Read(List <ulong> sids) { try { Interlocked.Increment(ref refs); Dictionary <ulong, ClockValues> result = new Dictionary <ulong, ClockValues>(); foreach (ulong sid in sids) { ClockValues sidvalues = null; lock (lockthis) { List <IndexEntry> blocks = index.Entries(sid); if (blocks == null || blocks.Count == 0) { continue; } List <TimeRange> tombstones = index.TombstoneRange(sid); bool hasTombstone = (tombstones != null && tombstones.Count > 0); foreach (IndexEntry block in blocks) { bool skip = false; if (hasTombstone) { foreach (TimeRange t in tombstones) { // Should we skip this block because it contains points that have been deleted if (t.Min <= block.MinTime && t.Max >= block.MaxTime) { skip = true; break; } } } if (skip) { continue; } //TODO: Validate checksum ClockValues temp = readBlock(block); if (hasTombstone) { foreach (TimeRange t in tombstones) { temp.Exclude(t.Min, t.Max); } } if (sidvalues == null) { sidvalues = temp; } else { sidvalues.AddRange(temp); } } } if (sidvalues != null && sidvalues.Count > 0) { result.Add(sid, sidvalues); } } return(result); } finally { Interlocked.Decrement(ref refs); } }