Example #1
0
        // Basic read/write functions ( indexes not updated ).

        // Get fetchs the row identified by id from the file buffer into the Value array.
        // cols specifies a subset of the columns to be fetched ( as an optimisation ). If not important, use AllCols.
        public override bool Get(long id, Value[] row, int [] cols)
        {
            if (id <= 0 || id > RowCount)
            {
                return(false);
            }

            DataFile.Position = (id - 1) * RowSize;
            int ix; byte [] RowBuffer = DataFile.FastRead(RowSize, out ix);

            if (RowBuffer[ix++] == 0)
            {
                return(false);                // Row has been deleted
            }
            row[0].L = id;
            for (int c = 0; c < cols.Length; c += 1)
            {
                int      col = cols[c];
                DataType t   = CI.Type[col];
                long     x   = Util.Get(RowBuffer, ix + Offset[col], Size[col], t);
                row[col].L = x;
                if (t <= DataType.String)
                {
                    row[col]._O = Database.Decode(x, t);
                }
            }
            return(true);
        }
Example #2
0
        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);
                }
            }
        }