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;
            }
        }
Exemple #2
0
        void Save(long id, Value [] row, bool checkNew)
        {
            DF.Position = (id - 1) * RowSize;

            if (row == null) // Delete record
            {
                for (int i = 0; i < RowSize; i += 1)
                {
                    RB[i] = 0;
                }
            }
            else
            {
                DataType [] types = Cols.Types;
                byte []     sizes = Cols.Sizes;
                RB[0] = 1;
                int ix = 1;
                for (int i = 1; i < types.Length; i += 1)
                {
                    DataType t = types[i];
                    ulong    x = (ulong)row[i].L;
                    if (t <= DataType.String && x == 0)
                    {
                        object o = row[i]._O;
                        x        = (t == DataType.Binary ? (ulong)Db.EncodeBinary((byte[])o) : (ulong)Db.EncodeString((string)o));
                        row[i].L = (long)x;
                    }
                    else if (t == DataType.Float)
                    {
                        x = Conv.PackFloat(x);
                    }
                    int size = sizes[i];
                    Util.Set(RB, ix, x, size);
                    ix += size;
                }
            }
            if (!DF.Write(RB, 0, RowSize, checkNew))
            {
                throw new System.Exception("Duplicate id, id=" + id + " Table=" + Schema + "." + Name);
            }
            Dirty = true;
        }