protected virtual void SetRecord(int x, ref IndexFileRecord r) { int off = NodeOverhead + NodeBase + x * NodeSize; for (int i = 0; i < ColStore; i += 1) { long v = r.Col[i].L; DataType t = Inf.Types[i]; if (t == DataType.String && v == 0) { r.Col[i].L = Database.EncodeString((string)r.Col[i]._O); } else if (t == DataType.Binary && v == 0) { r.Col[i].L = Database.EncodeBinary((byte[])r.Col[i]._O); } int size = DTI.Size(t); ulong p = (ulong)r.Col[i].L; if (t == DataType.Float) { p = Conv.PackFloat(p); } Set(off, p, size); off += size; } }
public int KeySize() { int result = 0; for ( int i = 0; i < KeyCount; i += 1 ) result += DTI.Size( Types[ i ] ); return result; }
// end Alter section int CalcRowSize(ColInfo c) { int result = 1; // Flag byte that indicates whether row is deleted. for (int i = 1; i < c.Count; i += 1) { result += DTI.Size(c.Type[i]); } return(result); }
public ColInfo(string [] names, DataType[] types) { Names = names; Types = types; Count = Types.Length; Sizes = new byte[Count]; for (int i = 0; i < Count; i += 1) { Sizes[i] = (byte)DTI.Size(Types[i]); } }
bool AlterRead(DataType [] types, long [] row) { int ix; byte [] RowBuffer = DataFile.FastRead(RowSize, out ix); if (RowBuffer[ix++] == 0) { return(false); // Row has been deleted } for (int i = 1; i < types.Length; i += 1) { DataType t = types[i]; int size = DTI.Size(t); long x = Util.Get(RowBuffer, ix, size, t); ix += size; row[i] = x; } return(true); }
void AlterWrite(DataType [] types, long [] row, int newRowSize) { RowBuffer[0] = 1; int ix = 1; for (int i = 1; i < types.Length; i += 1) { DataType t = types[i]; long x = row[i]; if (t == DataType.Float) { x = Conv.PackFloat(x); } int size = DTI.Size(t); Util.Set(RowBuffer, ix, x, size); ix += size; } DataFile.Write(RowBuffer, 0, newRowSize, false); }
protected virtual void GetRecord(int x, ref IndexFileRecord r) { if (r.Col == null) { r.Col = new Value[ColStore]; } int off = NodeOverhead + NodeBase + x * NodeSize; for (int i = 0; i < ColStore; i += 1) { DataType t = Inf.Types[i]; int size = DTI.Size(t); ulong u = Get(off, size); off += size; if (t == DataType.Float) { u = Conv.UnpackFloat((uint)u); } else if (t == DataType.Int) { u = (ulong)(long)(int)(uint)u; } else if (t == DataType.Smallint) { u = (ulong)(long)(short)(ushort)u; } else if (t == DataType.Tinyint) { u = (ulong)(long)(sbyte)(byte)u; } r.Col[i].L = (long)u; if (t == DataType.String) { r.Col[i]._O = Database.DecodeString((long)u); } else if (t == DataType.Binary) { r.Col[i]._O = Database.DecodeBinary((long)u); } } }
protected virtual void GetRecord(int x, ref IndexFileRecord r) { if (r.Col == null) { r.Col = new Value[ColStore]; } int off = NodeOverhead + NodeBase + x * NodeSize; for (int i = 0; i < ColStore; i += 1) { DataType t = Inf.Types[i]; int size = DTI.Size(t); long v = Util.Get(Data, off, size, t); off += size; r.Col[i].L = v; if (t <= DataType.String) { r.Col[i]._O = Database.Decode(v, t); } } }
void InitColumnInfo(ColInfo ci) { CI = ci; int count = ci.Count; AllCols = Util.OneToN(count - 1); Size = new byte[count]; Offset = new int[count]; int offset = -8; // -8 to allow for the Id column not being stored. for (int i = 0; i < count; i += 1) { Size[i] = (byte)DTI.Size(CI.Type[i]); Offset[i] = offset; offset += Size[i]; } RowSize = 1 + offset; // +1 is for byte that indicates whether row exists. RowCount = DataFile.Length / RowSize; RowBuffer = new byte[RowSize]; }
protected virtual void SetRecord(int x, ref IndexFileRecord r) { int off = NodeOverhead + NodeBase + x * NodeSize; for (int i = 0; i < ColStore; i += 1) { DataType t = Inf.Types[i]; if (t <= DataType.String && r.Col[i].L == 0) { r.Col[i].L = Database.Encode(r.Col[i]._O, t); } int size = DTI.Size(t); long p = r.Col[i].L; if (t == DataType.Float) { p = Conv.PackFloat(p); } Set(off, (ulong)p, size); off += size; } }