private Document createTestNormsDocument(bool setNormsProp, bool normsPropVal, bool setBodyNormsProp, bool bodyNormsVal) { Dictionary <string, string> props = new Dictionary <string, string>(); // Indexing configuration. props["analyzer"] = typeof(WhitespaceAnalyzer).AssemblyQualifiedName; props["directory"] = "RAMDirectory"; if (setNormsProp) { props["doc.tokenized.norms"] = normsPropVal.ToString(); } if (setBodyNormsProp) { props["doc.body.tokenized.norms"] = bodyNormsVal.ToString(); } // Create PerfRunData Config config = new Config(props); DocMaker dm = new DocMaker(); dm.SetConfig(config, new OneDocSource()); return(dm.MakeDocument()); }
public void TestDocMakerLeak() { // DocMaker did not close its ContentSource if resetInputs was called twice, // leading to a file handle leak. FileInfo f = new FileInfo(Path.Combine(getWorkDir().FullName, "docMakerLeak.txt")); TextWriter ps = new StreamWriter(new FileStream(f.FullName, FileMode.Create, FileAccess.Write), Encoding.UTF8); ps.WriteLine("one title\t" + Time.CurrentTimeMilliseconds() + "\tsome content"); ps.Dispose(); Dictionary <string, string> props = new Dictionary <string, string>(); props["docs.file"] = f.FullName; props["content.source.forever"] = "false"; Config config = new Config(props); ContentSource source = new LineDocSource(); source.SetConfig(config); DocMaker dm = new DocMaker(); dm.SetConfig(config, source); dm.ResetInputs(); dm.ResetInputs(); dm.Dispose(); }
private EnwikiContentSource createContentSource(String docs, bool forever) { Dictionary <string, string> props = new Dictionary <string, string>(); props["print.props"] = "false"; props["content.source.forever"] = forever.ToString(); Config config = new Config(props); EnwikiContentSource source = new StringableEnwikiSource(docs); source.SetConfig(config); // doc-maker just for initiating content source inputs DocMaker docMaker = new DocMaker(); docMaker.SetConfig(config, source); docMaker.ResetInputs(); return(source); }