コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
 private void buildAverageDiffs()
 {
     log.info("Building average diffs...");
     try
     {
         buildAverageDiffsLock.EnterWriteLock();
         averageDiffs.clear();
         long averageCount = 0L;
         var  it           = dataModel.getUserIDs();
         while (it.MoveNext())
         {
             averageCount = processOneUser(averageCount, it.Current);
         }
         pruneInconsequentialDiffs();
         updateAllRecommendableItems();
     }
     finally
     {
         buildAverageDiffsLock.ExitWriteLock();
     }
 }