/// <summary> /// Creates a filter from the list of points provided. /// </summary> /// <param name="listOfPointIDs">contains the list of pointIDs to include in the filter. List must support multiple enumerations</param> /// <returns></returns> public static MatchFilterBase <TKey, TValue> CreateFromList <TKey, TValue>(IEnumerable <ulong> listOfPointIDs) where TKey : TimestampPointIDBase <TKey>, new() { MatchFilterBase <TKey, TValue> filter; ulong maxValue = 0; if (listOfPointIDs.Any()) { maxValue = listOfPointIDs.Max(); } if (maxValue < 8 * 1024 * 64) //64KB of space, 524288 { filter = new BitArrayFilter <TKey, TValue>(listOfPointIDs, maxValue); } else if (maxValue <= uint.MaxValue) { filter = new UIntHashSet <TKey, TValue>(listOfPointIDs, maxValue); } else { filter = new ULongHashSet <TKey, TValue>(listOfPointIDs, maxValue); } return(filter); }
private static MatchFilterBase <TKey, TValue> CreateFromStream <TKey, TValue>(BinaryStreamBase stream) where TKey : TimestampPointIDBase <TKey>, new() { MatchFilterBase <TKey, TValue> filter; byte version = stream.ReadUInt8(); ulong maxValue; int count; switch (version) { case 0: return(null); case 1: maxValue = stream.ReadUInt64(); count = stream.ReadInt32(); if (maxValue < 8 * 1024 * 64) //64KB of space, 524288 { filter = new BitArrayFilter <TKey, TValue>(stream, count, maxValue); } else { filter = new UIntHashSet <TKey, TValue>(stream, count, maxValue); } break; case 2: maxValue = stream.ReadUInt64(); count = stream.ReadInt32(); filter = new ULongHashSet <TKey, TValue>(stream, count, maxValue); break; default: throw new VersionNotFoundException("Unknown Version"); } return(filter); }