Ejemplo n.º 1
0
        public void buildDictionary()
        {
            buildLock = true;
            trie = new Trie();

            if (!sender.IsAlive)
            {
                sender.Start();
            }

            PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes");

            if (table.Exists())
            {
                TableQuery<IndexIdentity> query = new TableQuery<IndexIdentity>()
                   .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "indexingforsearch"));

                string title = "Done building dictionary";

                foreach (IndexIdentity e in table.ExecuteQuery(query))
                {
                    if (ramCounter.NextValue() >= 40)
                    {
                        string line = e.RowKey;
                        trie.Add(line);
                        trieSize++;
                        lastTitle = line;
                    }
                }

                HttpContext.Current.Response.Write(title);
            }

            buildLock = false;
        }
 public void buildTrie()
 {
     //performance counter to measure available memory
     PerformanceCounter cpu = new PerformanceCounter("Memory", "Available MBytes");
     trie = new Trie();
     int counter = 0;
     //reads the temporary file
     using (var fileStream = System.IO.File.OpenRead(filepath))
     {
         using (StreamReader reader = new StreamReader(fileStream))
         {
             while (!reader.EndOfStream)
             {
                 //checks memory every 500 iterations
                 if (counter % 500 == 0)
                 {
                     //if the amount of memory is less than defined amount, end
                     if (cpu.NextValue() < minMemory)
                     {
                         return;
                     }
                 }
                 counter++;
                 //adds to the trie
                 trie.add(reader.ReadLine().Replace("_", " "));
             }
         }
     }
 }
Ejemplo n.º 3
0
 public string RemoveTrie()
 {
     triehard = null;
     return("Trie Deleted...");
 }
Ejemplo n.º 4
0
 public string DownloadWiki()
 {
     // CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
     //ConfigurationManager.AppSettings["hmcd"]);
     trie = new Trie();
     var filename = System.IO.Path.GetTempFileName() + blob.Name;
     try
     {
         using (var fileStream = System.IO.File.OpenWrite(filename))
         {
             blob.DownloadToStream(fileStream);
             fileStream.Close();
             //BuildTrie(filename);
             filenameForBlob = filename;
             return filename;
         }
     }
     catch (Exception e)
     {
         return e.Message;
     }
     //return "no filename found";
 }
Ejemplo n.º 5
0
 public void removeTrie()
 {
     titleTrie = null;
 }