// 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); }
public override bool Get(long id, Value[] row, bool [] used) { if (id <= 0 || id > RowCount) { return(false); } DF.Position = (id - 1) * RowSize; int ix; byte [] RB = DF.FastRead(RowSize, out ix); if (RB[ix++] == 0) { return(false); // Row has been deleted } row[0].L = id; DataType [] types = Cols.Types; byte [] sizes = Cols.Sizes; for (int i = 1; i < types.Length; i += 1) { int size = sizes[i]; if (used == null || used [i]) // Column not skipped { DataType t = types[i]; long x = (long)Util.Get(RB, ix, size, t); row[i].L = x; if (t <= DataType.String) { row[i]._O = t == DataType.Binary ? (object)Db.DecodeBinary(x): (object)Db.DecodeString(x); } } ix += size; } return(true); }