Exemple #1
0
 public void DeleteRange(List <ulong> sids, long min, long max)
 {
     lock (lockthis)
     {
         foreach (ulong sid in sids)
         {
             if (!store.ContainsKey(sid))
             {
                 continue;
             }
             ClockValues e        = store[sid];
             long        origSize = e.Size;
             if (min == Constants.MinTime && max == Constants.MaxTime)
             {
                 selfsize -= origSize;
                 store.Remove(sid);
                 continue;
             }
             e.Exclude(min, max);
             if (e.Count() == 0)
             {
                 store.Remove(sid);
                 selfsize -= origSize;
             }
         }
         Interlocked.Add(ref stats.MemSizeBytes, Size);
     }
 }
Exemple #2
0
 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);
     }
 }