private void updateAllRecommendableItems() { FastIDSet ids = new FastIDSet(dataModel.getNumItems()); foreach (var entry in averageDiffs.entrySet()) { ids.add(entry.Key); var it = entry.Value.Keys; foreach (var item in it) { ids.add(item); } } allRecommendableItemIDs.clear(); allRecommendableItemIDs.addAll(ids); allRecommendableItemIDs.rehash(); }
private void buildDiffs() { if (buildAverageDiffsLock.TryEnterWriteLock(-1)) { try { averageDiffs.clear(); allRecommendableItemIDs.clear(); //FileLineIterator iterator = new FileLineIterator(dataFile, false); //String firstLine = iterator.peek(); //while (string.IsNullOrEmpty(firstLine) || firstLine[0] == COMMENT_CHAR) //{ // iterator.next(); // firstLine = iterator.peek(); //} StreamReader reader = new StreamReader(dataFile); string firstLine = reader.ReadLine(); while ((firstLine == string.Empty) || (firstLine[0] == COMMENT_CHAR)) { firstLine = reader.ReadLine(); } long averageCount = 0L; while (!reader.EndOfStream) { averageCount = processLine(reader.ReadLine(), averageCount); } reader.Close(); pruneInconsequentialDiffs(); updateAllRecommendableItems(); } catch (IOException ioe) { log.warn("Exception while reloading", ioe); } finally { buildAverageDiffsLock.ExitWriteLock(); } } }