public override Cell Evaluate(SpoolSpace Memory) { this.CheckParameters(); Cell x = this._Children[0].Evaluate(Memory); return(new Cell(CellSerializer.DiskSize(x))); }
/// <summary> /// /// </summary> /// <param name="Buffer"></param> /// <param name="Location"></param> /// <param name="Element"></param> public static void Write2(byte[] Buffer, long Location, Page Element) { // Write the header data // Array.Copy(BitConverter.GetBytes(HASH_KEY), 0, Buffer, Location + OFFSET_HASH_KEY, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.PageID), 0, Buffer, Location + OFFSET_PAGE_ID, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.LastPageID), 0, Buffer, Location + OFFSET_LAST_ID, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.NextPageID), 0, Buffer, Location + OFFSET_NEXT_ID, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.PageSize), 0, Buffer, Location + OFFSET_SIZE, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.FieldCount), 0, Buffer, Location + OFFSET_FCOUNT, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.Count), 0, Buffer, Location + OFFSET_RCOUNT, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.CheckSum), 0, Buffer, Location + OFFSET_CHECKSUM, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.PageType), 0, Buffer, Location + OFFSET_TYPE, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element.UsedSpace), 0, Buffer, Location + OFFSET_USED_SPACE, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element._X0), 0, Buffer, Location + OFFSET_X0, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element._X1), 0, Buffer, Location + OFFSET_X1, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element._X2), 0, Buffer, Location + OFFSET_X2, SIZE_ELEMENT); Array.Copy(BitConverter.GetBytes(Element._X3), 0, Buffer, Location + OFFSET_X3, SIZE_ELEMENT); Buffer[Location + OFFSET_B0] = Element._B0; Buffer[Location + OFFSET_B1] = Element._B1; Buffer[Location + OFFSET_B2] = Element._B2; Buffer[Location + OFFSET_B3] = Element._B3; Array.Copy(BitConverter.GetBytes(Element._ParentPageID), 0, Buffer, Location + OFFSET_PARENT_PAGE_ID, SIZE_ELEMENT); Location += HEADER_SIZE; // Start writting the record data // foreach (Record R in Element._Elements) { Location = CellSerializer.Write(Buffer, R, (int)Location); } }
public override int SizeOf() { if (this._Host.Spools.Exists(this._sName) && this._Host.Spools[this._sName].Exists(this._vName)) { return(CellSerializer.DiskSize(this._Host.Spools[this._sName].Get(this._vName))); } return(base.SizeOf()); }
/// <summary> /// /// </summary> /// <param name="Buffer"></param> /// <param name="Location"></param> /// <returns></returns> public static Page Read2(byte[] Buffer, long Location) { // Check the hash key // int HashKey = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_HASH_KEY); if (HashKey != Page.HASH_KEY) { throw new Exception("Hash key is invalid, cannot de-serialize"); } // Read Header Elements // int PageID = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_PAGE_ID); int LastPageID = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_LAST_ID); int NextPageID = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_NEXT_ID); int Size = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_SIZE); int FieldCount = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_FCOUNT); int Count = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_RCOUNT); int CheckSum = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_CHECKSUM); int PageType = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_TYPE); int UsedSpace = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_USED_SPACE); Page element = new Page(Size, PageID, LastPageID, NextPageID, FieldCount, UsedSpace); element._CheckSum = CheckSum; element._Type = PageType; element._X0 = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_X0); element._X1 = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_X1); element._X2 = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_X2); element._X3 = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_X3); element._B0 = Buffer[(int)Location + OFFSET_B0]; element._B1 = Buffer[(int)Location + OFFSET_B1]; element._B2 = Buffer[(int)Location + OFFSET_B2]; element._B3 = Buffer[(int)Location + OFFSET_B3]; element._ParentPageID = BitConverter.ToInt32(Buffer, (int)Location + OFFSET_PARENT_PAGE_ID); Location += HEADER_SIZE; // Read in records // for (int k = 0; k < Count; k++) { Record r = null; Location = CellSerializer.Read(Buffer, (int)Location, FieldCount, out r); element._Elements.Add(r); } return(element); }
// 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; }
public override int SizeOf() { return(CellSerializer.DefaultLength(CellAffinity.TREF)); }
public override int SizeOf() { return(CellSerializer.DiskSize(this._value)); }