Пример #1
0
        // Adds //
        /// <summary>
        /// Adds a column to the schema; will throw an exception if a column name passed already exists in the schema
        /// </summary>
        /// <param name="Alias">The column name</param>
        /// <param name="Affinity">The column affinity</param>
        /// <param name="Nullable">A boolean, true means the column can be nulls, false means the column cannot be null</param>
        /// <param name="PageSize">The size in bytes; this will be ignored if the affinity is not variable (not string or blob)</param>
        public void Add(string Name, CellAffinity Affinity, int Size, bool Nullable)
        {
            // Check the name size //
            if (Name.Length > MAX_COLUMN_NAME_LEN)
            {
                Name = Name.Substring(0, MAX_COLUMN_NAME_LEN);
            }

            // Check the size //
            if (CellAffinityHelper.IsVariableLength(Affinity) && Size == 0)
            {
                throw new Exception("Variable length types must have a size greater than zero");
            }

            // Check if exists //
            if (this.Contains(Name))
            {
                throw new Exception("Column already exists: " + Name);
            }

            // Check for capacity //
            if (this.Count >= MAX_COLUMNS)
            {
                throw new Exception("Schema cannot accept any more columns");
            }

            // Get the size //
            int v = CellSerializer.FixLength(Affinity, Size);

            // Build record //
            Record r = Record.Stitch(new Cell(Name), new Cell((byte)Affinity), new Cell(Nullable), new Cell(v));

            // Accumulate record //
            this._Cache.Allocate(Name, r);

            // Hash code //
            this._HashCode += r.GetHashCode(new Key(1, 2)) * this.Count;
        }
Пример #2
0
 public int GetHashCode(Record A)
 {
     return(A.GetHashCode(this._RightKey));
 }