Exemplo n.º 1
0
 public DataFileBlockManager(int capacity, int scale, long lostSize)
 {
     this._lookup = new DoubleIntIndex(capacity, true);
     this._lookup.SetValuesSearchTarget();
     this._capacity          = capacity;
     this._scale             = scale;
     this._lostFreeBlockSize = lostSize;
     this._midSize           = 0x80;
 }
Exemplo n.º 2
0
        public int[] WriteTableToDataFile(Table table)
        {
            IPersistentStore    rowStore = this._database.GetSessionManager().GetSysSession().sessionData.GetRowStore(table);
            IRowOutputInterface output   = this._cache.RowOut.Duplicate();
            DoubleIntIndex      lookup   = new DoubleIntIndex(table.GetPrimaryIndex().SizeUnique(rowStore), false);

            int[] indexRootsArray = table.GetIndexRootsArray();
            long  num             = this._fileOffset;
            int   num2            = 0;

            lookup.SetKeysSearchTarget();
            Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_lookup_begins__ + this._stopw.ElapsedTime());
            IRowIterator rowIterator = table.GetRowIterator(rowStore);

            while (rowIterator.HasNext())
            {
                ICachedObject nextRow = rowIterator.GetNextRow();
                lookup.AddUnsorted(nextRow.GetPos(), (int)(num / ((long)this._scale)));
                if ((num2 % 0xc350) == 0)
                {
                    Error.PrintSystemOut(string.Concat(new object[] { FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_pointer_pair_for_row_, num2, FwNs.Core.LC.cResources.SR.Single_Space, nextRow.GetPos(), FwNs.Core.LC.cResources.SR.Single_Space, num }));
                }
                num += nextRow.GetStorageSize();
                num2++;
            }
            Error.PrintSystemOut(string.Concat(new object[] { FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_table__, table.GetName().Name, FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile__list_done__, this._stopw.ElapsedTime() }));
            num2        = 0;
            rowIterator = table.GetRowIterator(rowStore);
            while (rowIterator.HasNext())
            {
                ICachedObject nextRow = rowIterator.GetNextRow();
                output.Reset();
                nextRow.Write(output, lookup);
                this._fileStreamOut.Write(output.GetOutputStream().GetBuffer(), 0, output.Size());
                this._fileOffset += nextRow.GetStorageSize();
                if ((num2 % 0xc350) == 0)
                {
                    Error.PrintSystemOut(num2 + FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile__rows_ + this._stopw.ElapsedTime());
                }
                num2++;
            }
            for (int i = 0; i < table.GetIndexCount(); i++)
            {
                if (indexRootsArray[i] != -1)
                {
                    int num4 = lookup.FindFirstEqualKeyIndex(indexRootsArray[i]);
                    if (num4 == -1)
                    {
                        throw Error.GetError(0x1d2);
                    }
                    indexRootsArray[i] = lookup.GetValue(num4);
                }
            }
            this.SetTransactionRowLookups(lookup);
            Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_table__ + table.GetName().Name + FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile____table_converted);
            return(indexRootsArray);
        }
Exemplo n.º 3
0
 public virtual DoubleIntIndex GetTransactionIDList()
 {
     lock (this.Lock)
     {
         DoubleIntIndex index2 = new DoubleIntIndex(this.RowActionMap.Size(), false);
         index2.SetKeysSearchTarget();
         Iterator <int> iterator = this.RowActionMap.GetKeySet().GetIterator();
         while (iterator.HasNext())
         {
             index2.AddUnique(iterator.Next(), 0);
         }
         return(index2);
     }
 }
Exemplo n.º 4
0
        public void SetTransactionRowLookups(DoubleIntIndex pointerLookup)
        {
            int i    = 0;
            int num2 = this._transactionRowLookup.Size();

            while (i < num2)
            {
                int key  = this._transactionRowLookup.GetKey(i);
                int num4 = pointerLookup.FindFirstEqualKeyIndex(key);
                if (num4 != -1)
                {
                    this._transactionRowLookup.SetValue(i, pointerLookup.GetValue(num4));
                }
                i++;
            }
        }
Exemplo n.º 5
0
 public virtual void ConvertTransactionIDs(DoubleIntIndex lookup)
 {
     lock (this.Lock)
     {
         RowAction[]          actionArray = new RowAction[this.RowActionMap.Size()];
         Iterator <RowAction> iterator    = this.RowActionMap.GetValues().GetIterator();
         for (int i = 0; iterator.HasNext(); i++)
         {
             actionArray[i] = iterator.Next();
         }
         this.RowActionMap.Clear();
         for (int j = 0; j < actionArray.Length; j++)
         {
             int firstEqual = lookup.LookupFirstEqual(actionArray[j].GetPos());
             actionArray[j].SetPos(firstEqual);
             this.RowActionMap.Put(firstEqual, actionArray[j]);
         }
     }
 }
Exemplo n.º 6
0
 public override void ConvertTransactionIDs(DoubleIntIndex lookup)
 {
 }
Exemplo n.º 7
0
        public void Process()
        {
            bool flag = false;

            Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_Defrag_process_begins);
            this._transactionRowLookup = this._database.TxManager.GetTransactionIDList();
            Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_transaction_count__ + this._transactionRowLookup.Size());
            List <Table> allTables = this._database.schemaManager.GetAllTables();

            this._rootsList = new int[allTables.Count][];
            IScaledRAInterface interface2 = null;

            try
            {
                Stream stream = this._database.logger.GetFileAccess().OpenOutputStreamElement(this._dataFileName + ".new");
                this._fileStreamOut = new BufferedStream(stream, 0x1000);
                for (int i = 0; i < this._cache.InitialFreePos; i++)
                {
                    this._fileStreamOut.WriteByte(0);
                }
                this._fileOffset = this._cache.InitialFreePos;
                int index = 0;
                int count = allTables.Count;
                while (index < count)
                {
                    Table table = allTables[index];
                    if (table.GetTableType() == 5)
                    {
                        this._rootsList[index] = this.WriteTableToDataFile(table);
                    }
                    else
                    {
                        this._rootsList[index] = null;
                    }
                    Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_table__ + table.GetName().Name + FwNs.Core.LC.cResources.SR.DataFileDefrag_Process__complete);
                    index++;
                }
                this._fileStreamOut.Flush();
                this._fileStreamOut.Close();
                this._fileStreamOut = null;
                interface2          = ScaledRAFile.NewScaledRAFile(this._database, this._dataFileName + ".new", false, this._database.IsFilesInAssembly());
                interface2.Seek(12L);
                interface2.WriteLong(this._fileOffset);
                int map = 0;
                if (this._database.logger.PropIncrementBackup)
                {
                    map = BitMap.Set(map, 1);
                }
                map = BitMap.Set(BitMap.Set(map, 4), 2);
                interface2.Seek(0x1cL);
                interface2.WriteInt(map);
                int num4   = 0;
                int length = this._rootsList.Length;
                while (num4 < length)
                {
                    int[] s = this._rootsList[num4];
                    if (s != null)
                    {
                        Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_roots__ + StringUtil.GetList(s, ",", ""));
                    }
                    num4++;
                }
                flag = true;
            }
            catch (IOException exception)
            {
                throw Error.GetError(0x1c4, exception);
            }
            catch (OutOfMemoryException exception2)
            {
                throw Error.GetError(460, exception2);
            }
            catch (Exception exception3)
            {
                throw Error.GetError(0x1ca, exception3);
            }
            finally
            {
                try
                {
                    if (this._fileStreamOut != null)
                    {
                        this._fileStreamOut.Close();
                    }
                    if (interface2 != null)
                    {
                        interface2.Dispose();
                    }
                }
                catch (Exception exception4)
                {
                    this._database.logger.LogSevereEvent(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_backupFile_failed, exception4);
                }
                if (!flag)
                {
                    this._database.logger.GetFileAccess().RemoveElement(this._dataFileName + ".new");
                }
            }
            Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_Defrag_transfer_complete__ + this._stopw.ElapsedTime());
        }