private static void Warmup(string dir, Uri uri, string collectionName, int skip, int take) { using (var sessionFactory = new SessionFactory(dir, new LatinTokenizer(), new IniConfiguration("sir.ini"))) { using (var documentStreamSession = sessionFactory.CreateDocumentStreamSession(collectionName, collectionName.ToHash())) { using (var session = sessionFactory.CreateWarmupSession(collectionName, collectionName.ToHash(), uri.ToString())) { session.Warmup(documentStreamSession.ReadDocs(skip, take), 0, 1, 2, 3, 6); } } } }
private static void Warmup(string dir, Uri uri, string collectionName, int skip, int take, IStringModel model) { using (var sessionFactory = new SessionFactory(new IniConfiguration("sir.ini"), model)) { using (var documentStreamSession = sessionFactory.CreateDocumentStreamSession(collectionName, collectionName.ToHash())) { using (var session = sessionFactory.CreateWarmupSession(collectionName, collectionName.ToHash(), uri.ToString())) { session.Warmup(documentStreamSession.ReadDocs(skip, take), 0); } } } }
private static void Validate(string dir, string collectionName, int skip, int take) { var files = Directory.GetFiles(dir, "*.docs"); var time = Stopwatch.StartNew(); using (var sessionFactory = new SessionFactory(dir, new LatinTokenizer(), new IniConfiguration("sir.ini"))) { using (var documentStreamSession = sessionFactory.CreateDocumentStreamSession(collectionName, collectionName.ToHash())) using (var validateSession = sessionFactory.CreateValidateSession(collectionName, collectionName.ToHash())) { validateSession.Validate(documentStreamSession.ReadDocs(skip, take), 0, 1, 2, 3, 6); } } Logging.Log(null, string.Format("{0} validate operation took {1}", collectionName, time.Elapsed)); }
private static void Index(string dir, string collectionName, int skip, int take, int batchSize) { var files = Directory.GetFiles(dir, "*.docs"); var fullTime = Stopwatch.StartNew(); var batchCount = 0; using (var sessionFactory = new SessionFactory(dir, new LatinTokenizer(), new IniConfiguration("sir.ini"))) { foreach (var docFileName in files) { var name = Path.GetFileNameWithoutExtension(docFileName) .Split(".", StringSplitOptions.RemoveEmptyEntries); var collectionId = ulong.Parse(name[0]); if (collectionId == collectionName.ToHash()) { using (var readSession = sessionFactory.CreateDocumentStreamSession(name[0], collectionId)) { var docs = readSession.ReadDocs(skip, take); foreach (var batch in docs.Batch(batchSize)) { var timer = Stopwatch.StartNew(); using (var indexSession = sessionFactory.CreateIndexSession(collectionName, collectionId)) { foreach (var doc in batch) { indexSession.EmbedTerms(doc); } } Logging.Log(null, string.Format("indexed batch #{0} in {1}", batchCount++, timer.Elapsed)); } } break; } } } Logging.Log(null, string.Format("indexed {0} batches in {1}", batchCount, fullTime.Elapsed)); }