public IdCopy(IdSet x, EvalEnv ee) { foreach (long id in x.All(ee)) { Copy.Add(id); } }
public void ExecDelete(Exp where, bool[] used, EvalEnv ee) { Value [] tr = new Value[Cols.Count]; ee.Row = tr; IdSet IdSet = where == null ? null : where.GetIdSet(this, ee); if (IdSet == null) { IdSet = new UpTo(RowCount); } else { IdSet = new IdCopy(IdSet, ee); // Need to take a copy of the id values, as indexes may be updated. } foreach (long id in IdSet.All(ee)) { if (Get(id, tr, null)) { if (where == null || (where.Eval(ee).B)) { Delete(id, tr); } } } }
public void ExecUpdate(Assign[] a, Exp where, bool [] used, int idCol, EvalEnv ee) { Value [] tr = new Value[Cols.Count]; Value [] nr = new Value[Cols.Count]; // The new row. ee.Row = tr; IdSet IdSet = where == null ? null : where.GetIdSet(this, ee); if (IdSet == null) { IdSet = new UpTo(RowCount); } else { IdSet = new IdCopy(IdSet, ee); // Need to take a copy of the id values if an index is used. } foreach (long id in IdSet.All(ee)) { if (Get(id, tr, null)) { for (int i = 0; i < nr.Length; i += 1) { nr[i] = tr[i]; } if (where == null || (where.Eval(ee).B)) { for (int i = 0; i < a.Length; i += 1) { int ix = a[i].Lhs.ColIx; nr[ix] = a[i].Rhs.Eval(ee); } if (idCol >= 0 && nr[idCol].L != id) { Delete(id, tr); Insert(nr, idCol); } else { Update(id, tr, nr); } } } } }
public void Update(int [] cols, Exp.DV [] dvs, Exp.DB where, int idCol, IdSet ids, EvalEnv ee) { Value [] tr = new Value[CI.Count]; // The old row. Value [] nr = new Value[CI.Count]; // The new row. ee.Row = tr; if (ids == null) { ids = new UpTo(RowCount); } else { ids = new IdCopy(ids); // Need to take a copy of the id values if an index is used. } foreach (long id in ids.All(ee)) { if (Get(id, tr, AllCols) && where (ee)) { // Initialise new row as copy of old row. for (int i = 0; i < nr.Length; i += 1) { nr[i] = tr[i]; } // Update the new row. for (int i = 0; i < cols.Length; i += 1) { nr[cols [i]] = dvs[i](ee); } if (idCol >= 0 && nr[idCol].L != id) // Row Id is changing. { Delete(id, tr); Insert(nr, idCol); } else { Update(id, tr, nr); } } } }
public void Delete(Exp.DB where, IdSet ids, EvalEnv ee) { Value [] tr = new Value[CI.Count]; ee.Row = tr; if (ids == null) { ids = new UpTo(RowCount); } else { ids = new IdCopy(ids); } foreach (long id in ids.All(ee)) { if (Get(id, tr, AllCols) && where (ee)) { Delete(id, tr); } } }
public IdCopy(IdSet x) { X = x; }