예제 #1
0
        public TextDeferredIndexer(DBreezeEngine engine)
        {
            this.DBreezeEngine = engine;
            LTrieSettings      = new TrieSettings()
            {
                InternalTable = true
            };
            Storage         = new StorageLayer(Path.Combine(engine.MainFolder, TableFileName), LTrieSettings, engine.Configuration);
            LTrie           = new LTrie(Storage);
            LTrie.TableName = "DBreeze.TextIndexer";

            if (LTrie.Storage.Length > 100000)  //Recreating file if its size more then 100KB and it is empty
            {
                if (LTrie.Count(true) == 0)
                {
                    LTrie.Storage.RecreateFiles();
                    LTrie.Dispose();

                    Storage         = new StorageLayer(Path.Combine(engine.MainFolder, TableFileName), LTrieSettings, engine.Configuration);
                    LTrie           = new LTrie(Storage);
                    LTrie.TableName = "DBreeze.TextIndexer";
                }
            }

            if (LTrie.Count(true) > 0)
            {
                this.StartDefferedIndexing();
            }
        }
예제 #2
0
파일: Scheme.cs 프로젝트: lanicon/DBreeze
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            _sync_openTablesHolder.EnterWriteLock();
            try
            {
                foreach (var row in _openTablesHolder)
                {
                    //Disposes all Ltrie, with storages and rollbacks
                    row.Value.Dispose();
                }

                //Clear self
                _openTablesHolder.Clear();

                //Disposing Schema trie
                if (LTrie != null)
                {
                    LTrie.Dispose();
                }
                //LTrieStorage.Dispose();
            }
            finally
            {
                _sync_openTablesHolder.ExitWriteLock();
            }
        }
예제 #3
0
 public void Dispose()
 {
     if (Trie != null)
     {
         Trie.Dispose();
     }
 }
예제 #4
0
 public void Dispose()
 {
     //Cascade trie disposing
     if (table != null)
     {
         table.Dispose();
     }
 }
예제 #5
0
        public void Dispose()
        {
            _sync_transactionsTables.EnterWriteLock();
            try
            {
                _transactionsTables.Clear();

                //Disposing self trie
                if (LTrie != null)
                {
                    //LTrieStorage.Dispose();
                    LTrie.Dispose();
                }
            }
            finally
            {
                _sync_transactionsTables.ExitWriteLock();
            }
        }
예제 #6
0
        /// <summary>
        /// Disposing
        /// </summary>
        public void Dispose()
        {
            if (System.Threading.Interlocked.CompareExchange(ref disposed, 1, 0) != 0)
            {
                return;
            }

            if (LTrie != null)
            {
                LTrie.Dispose();
            }
        }
예제 #7
0
        private void RestoreNotFinishedTransactions()
        {
            //TODO Trie settings from the table must be taken from schema (when they will differ)

            //STORE FILE NAME of rollback not table name
            try
            {
                byte[]        btCommittedTablesNames = null;
                List <string> committedTablesNames   = new List <string>();

                if (LTrie.Count(false) == 0)     //All ok
                {
                    LTrie.RemoveAll(true);
                    return;
                }

                string physicalPathToTheUserTable = String.Empty;

                //Settigns and storage for Committed tables !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   MUST BE TAKEN FROM SCHEMA, FOR NOW DEFAULT
                TrieSettings            ltrSet  = null;
                IStorage                storage = null;
                DBriize.LianaTrie.LTrie ltrie   = null;


                foreach (var row in LTrie.IterateForward(true, false))
                {
                    btCommittedTablesNames = row.GetFullValue(true);

                    committedTablesNames = System.Text.Encoding.UTF8.GetString(btCommittedTablesNames).DeserializeXml <List <string> >();

                    foreach (var fn in committedTablesNames)
                    {
                        //Trying to get path from the Schema, there is universal function for getting table physical TABLE FULL PATH /NAME

                        physicalPathToTheUserTable = Engine.DBriizeSchema.GetPhysicalPathToTheUserTable(fn);

                        //Returned path can be empty, if no more such table
                        if (physicalPathToTheUserTable == String.Empty)
                        {
                            continue;
                        }

                        //We don't restore in-memory tables
                        if (physicalPathToTheUserTable == "MEMORY")
                        {
                            continue;
                        }

                        //we open ltrie, and it automatically restores rollback
                        ltrSet = new TrieSettings();     //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   MUST BE TAKEN FROM SCHEMA, FOR NOW DEFAULT
                        //storage = new TrieDiskStorage(physicalPathToTheUserTable, ltrSet, Engine.Configuration);
                        storage = new StorageLayer(physicalPathToTheUserTable, ltrSet, Engine.Configuration);
                        ltrie   = new LTrie(storage);

                        //closing trie, that Schema could open it again
                        ltrie.Dispose();

                        ////Deleting rollback file for such table
                        //physicalPathToTheUserTable += ".rol";
                        //System.IO.File.Delete(physicalPathToTheUserTable);
                    }

                    committedTablesNames.Clear();
                }

                //If all ok, recreate file
                LTrie.RemoveAll(true);
            }
            catch (OperationCanceledException ex)
            {
                throw ex;
            }
            //catch (System.Threading.ThreadAbortException ex)
            //{
            //    //We don'T make DBisOperable = false;
            //    throw ex;
            //}
            catch (Exception)
            {
                //BRINGS TO DB NOT OPERATABLE
                this.Engine.DBisOperable       = false;
                this.Engine.DBisOperableReason = "TransactionsCoordinator.RestoreNotFinishedTransaction";
                //NOT CASCADE ADD EXCEPTION
                throw DBriizeException.Throw(DBriizeException.eDBriizeExceptions.CLEAN_ROLLBACK_FILES_FOR_FINISHED_TRANSACTIONS_FAILED);
            }
        }