public FilterBubbleSearchIndex(FilterBubble filterBubble) { _filterBubble = filterBubble; var filesList = Directory.GetFiles(_filterBubble.IndexPath, "*.list"); var filesVec = Directory.GetFiles(_filterBubble.IndexPath, "*.vec"); var @lock = new object(); _contains = new Dictionary <string, HashSet <string> >(); Parallel.ForEach( filesList, file => { try { var content = Serializer.Deserialize <HashSet <string> >(file); lock (@lock) { _contains.Add(Path.GetFileNameWithoutExtension(file), content); } } catch { // ignore } }); _vector = new Dictionary <string, Dictionary <string, double> >(); Parallel.ForEach( filesVec, file => { try { var content = Serializer.Deserialize <KeyValuePair <string, double>[]>(file) .ToDictionary(x => x.Key, x => x.Value); lock (@lock) { _vector.Add(Path.GetFileNameWithoutExtension(file), content); } } catch { // ignore } }); }
public FilterBubbleIndexWatchdog(FilterBubble filterBubble) { _filterBubble = filterBubble; _watches = new List <FileSystemWatcher>(); foreach (var source in filterBubble.Sources) { var w = new FileSystemWatcher { Path = source, Filter = "*.*", IncludeSubdirectories = true }; w.Changed += WatcherOnChanged; w.Created += WatcherOnCreated; w.Deleted += WatcherOnDeleted; w.Renamed += WatcherOnRenamed; w.EnableRaisingEvents = true; } }
public FilterBubbleIndexBuilder(FilterBubble filterBubble) { _filterBubble = filterBubble; }