static public void ProcessBackend(string databaseFile) { var cxStr = new SQLiteConnectionStringBuilder { DataSource = databaseFile, FailIfMissing = true, SyncMode = SynchronizationModes.Off, JournalMode = SQLiteJournalModeEnum.Off, ReadOnly = false }; using (var backend = new SQLiteConnection(cxStr.ConnectionString)) { backend.Open(); var proxy = BridgeCompiler.CreateInstance <Data.IDbProxy>(backend); var domains = new Dictionary <int, string> (); using (var allDoms = proxy.GetDomains()) while (allDoms.MoveNext()) { domains.Add(allDoms.Current.ID, allDoms.Current.Name); } foreach (var domainID in domains.Keys) { log.InfoFormat("Process Domain {0} ({1})", domainID, domains[domainID]); using (new Utils.Timer("Optimize Domain " + domainID)) { ProcessDomain(backend, proxy, domains, domainID); } } using (new Utils.Timer("VACUUM !!!")) proxy.Vacuum(); } }
private Engine(string backend) { _backendPath = backend; log.DebugFormat("Opening back-end [{0}]", backend); var cxStr = new SQLiteConnectionStringBuilder { DataSource = _backendPath, FailIfMissing = true, ReadOnly = true, SyncMode = SynchronizationModes.Off, JournalMode = SQLiteJournalModeEnum.Off }; _backend = new SQLiteConnection(cxStr.ConnectionString); _backend.Open(); _proxy = BridgeCompiler.CreateInstance <Data.IBackendProxy>(_backend); _domainDict = new Dictionary <string, int>(StringComparer.InvariantCultureIgnoreCase); var domFlags = new Dictionary <int, int>(); using (var domains = _proxy.GetDomains()) { while (domains.MoveNext()) { log.DebugFormat("Domain [{0}] = {1}", domains.Current.Name, domains.Current.ID); domFlags.Add(domains.Current.ID, domains.Current.Flags); _domainDict.Add(domains.Current.Name, domains.Current.ID); } } _domains = new Dictionary <int, Domain>(_domainDict.Count); foreach (var domain in _domainDict) { _domains.Add(domain.Value, new Domain(domain.Value, domain.Key, domFlags[domain.Value], this, _proxy) ); } // Create domain link queries foreach (var domain in _domains.Values) { domain.CreateQueries(); } }
public Context(string backendFile, IEnumerable <DataSource> sources) { _sources = new Dictionary <string, DataSource>(StringComparer.InvariantCultureIgnoreCase); foreach (var source in sources) { _sources.Add(source.Name, source); } if (System.IO.File.Exists(backendFile)) { System.IO.File.Delete(backendFile); } var cxStr = new SQLiteConnectionStringBuilder { DataSource = backendFile, FailIfMissing = false, SyncMode = SynchronizationModes.Off, JournalMode = SQLiteJournalModeEnum.Off }; _backend = new SQLiteConnection(cxStr.ConnectionString); _backend.Open(); _proxy = BridgeCompiler.CreateInstance <IContextDbProxy>(_backend); RunSql(@" CREATE TABLE [main_Master] ( ItemId integer not null primary key, DomainId integer not null ); CREATE TABLE [main_Domain] ( DomainId integer not null primary key, DomainName TEXT not null, Flags integer not null); CREATE TABLE [main_DomainMetadata] ( DomainId integer not null, ValueName TEXT not null, Type TEXT not null, Infos TEXT); CREATE VIRTUAL TABLE [main_FullText] USING fts3( FullText TEXT ) ; CREATE TABLE [main_FullTextToMaster] ( FullTextId integer not null primary key, ItemId integer not null); "); }