Esempio n. 1
0
        void Save(long id, Value [] row, bool checkNew)
        {
            DataFile.Position = (id - 1) * RowSize;

            if (row == null) // Delete record
            {
                for (int i = 0; i < RowSize; i += 1)
                {
                    RowBuffer[i] = 0;
                }
            }
            else
            {
                RowBuffer[0] = 1;
                int ix = 1;
                for (int i = 1; i < CI.Count; i += 1)
                {
                    DataType t = CI.Type[i];
                    long     x = row[i].L;
                    if (t <= DataType.String && x == 0)
                    {
                        x        = Database.Encode(row[i]._O, t);
                        row[i].L = x;
                    }
                    else if (t == DataType.Float)
                    {
                        x = (long)Conv.PackFloat(x);
                    }
                    int size = Size[i];
                    Util.Set(RowBuffer, ix, x, size);
                    ix += size;
                }
            }
            if (!DataFile.Write(RowBuffer, 0, RowSize, checkNew))
            {
                throw new System.Exception("Duplicate id");
            }
            Dirty = true;
        }
Esempio n. 2
0
        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;
            }
        }