/// <summary>
        /// Adds column to db file.
        /// </summary>
        /// <param name="column"></param>
        internal void AddColumn(LDB_DataColumn column)
        {
            if (column.ColumnSize < 1)
            {
                throw new Exception("Invalid column size '" + column.ColumnSize + "' for column '" + column.ColumnName + "' !");
            }

            // Find free column data area

            long currentColumnOffset = m_ColumnsStartOffset;
            long freeColumnPosition  = -1;

            // Loop all columns data areas, see it there any free left
            for (int i = 0; i < 100; i++)
            {
                byte[] columnInfo = new byte[102];
                if (ReadFromFile(currentColumnOffset, columnInfo, 0, columnInfo.Length) != columnInfo.Length)
                {
                    throw new Exception("Invalid columns data area length !");
                }

                // We found unused column data area
                if (columnInfo[0] == '\0')
                {
                    freeColumnPosition = currentColumnOffset - 102;
                    break;
                }

                currentColumnOffset += 102;
            }

            if (freeColumnPosition != -1)
            {
                // TODO: If there is data ???

                // Store column
                byte[] columnData = column.ToColumnInfo();
                WriteToFile(currentColumnOffset, columnData, 0, columnData.Length);
            }
            else
            {
                throw new Exception("Couldn't find free column space ! ");
            }
        }
Пример #2
0
        /// <summary>
        /// Adds column to db file.
        /// </summary>
        /// <param name="column"></param>
        internal void AddColumn(LDB_DataColumn column)
        {
            // Find free column data area

            // Set position over version, free data pages count and data page data area size
            m_pDbFile.Position = 68;

            long             freeColumnPosition = -1;
            StreamLineReader r = new StreamLineReader(m_pDbFile);

            // Loop all columns data areas, see it there any free left
            for (int i = 0; i < 100; i++)
            {
                byte[] columnInfo = r.ReadLine();
                if (columnInfo == null)
                {
                    throw new Exception("Invalid columns data area length !");
                }

                // We found unused column data area
                if (columnInfo[0] == '\0')
                {
                    freeColumnPosition = m_pDbFile.Position;
                    break;
                }
            }
            m_FilePosition = m_pDbFile.Position;

            if (freeColumnPosition != -1)
            {
                // TODO: If there is data ???

                // Move to row start
                SetFilePosition(GetFilePosition() - 102);

                // Store column
                byte[] columnData = column.ToColumnInfo();
                WriteToFile(columnData, 0, columnData.Length);
            }
            else
            {
                throw new Exception("Couldn't find free column space ! ");
            }
        }
        /// <summary>
        /// Adds column to db file.
        /// </summary>
        /// <param name="column"></param>
        internal void AddColumn(LDB_DataColumn column)
        {
            if(column.ColumnSize < 1){
                throw new Exception("Invalid column size '" + column.ColumnSize + "' for column '" + column.ColumnName + "' !");
            }

            // Find free column data area

            long currentColumnOffset = m_ColumnsStartOffset;
            long freeColumnPosition = -1;
            // Loop all columns data areas, see it there any free left
            for(int i=0;i<100;i++){
                byte[] columnInfo = new byte[102];
                if(ReadFromFile(currentColumnOffset,columnInfo,0,columnInfo.Length) != columnInfo.Length){
                    throw new Exception("Invalid columns data area length !");
                }

                // We found unused column data area
                if(columnInfo[0] == '\0'){
                    freeColumnPosition = currentColumnOffset - 102;
                    break;
                }

                currentColumnOffset += 102;
            }

            if(freeColumnPosition != -1){
                // TODO: If there is data ???

                // Store column
                byte[] columnData = column.ToColumnInfo();
                WriteToFile(currentColumnOffset,columnData,0,columnData.Length);
            }
            else{
                throw new Exception("Couldn't find free column space ! ");
            }
        }
Пример #4
0
        /// <summary>
        /// Adds column to db file.
        /// </summary>
        /// <param name="column"></param>
        internal void AddColumn(LDB_DataColumn column)
        {
            // Find free column data area

            // Set position over version, free data pages count and data page data area size
            m_pDbFile.Position = 68;

            long freeColumnPosition = -1;
            StreamLineReader r = new StreamLineReader(m_pDbFile);
            // Loop all columns data areas, see it there any free left
            for(int i=0;i<100;i++){
                byte[] columnInfo = r.ReadLine();
                if(columnInfo == null){
                    throw new Exception("Invalid columns data area length !");
                }

                // We found unused column data area
                if(columnInfo[0] == '\0'){
                    freeColumnPosition = m_pDbFile.Position;
                    break;
                }
            }
            m_FilePosition = m_pDbFile.Position;

            if(freeColumnPosition != -1){
                // TODO: If there is data ???

                // Move to row start
                SetFilePosition(GetFilePosition() - 102);

                // Store column
                byte[] columnData = column.ToColumnInfo();
                WriteToFile(columnData,0,columnData.Length);
            }
            else{
                throw new Exception("Couldn't find free column space ! ");
            }
        }