public override G.IEnumerable <long> All(EvalEnv ee)
 {
     for (int i = 0; i < List.Length; i += 1)
     {
         yield return(List[i].Eval(ee).L);
     }
 }
 public IdCopy(IdSet x, EvalEnv ee)
 {
     foreach (long id in x.All(ee))
     {
         Copy.Add(id);
     }
 }
Exemplo n.º 3
0
        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 override G.IEnumerable <long> All(EvalEnv ee)
 {
     foreach (long id in Copy)
     {
         yield return(id);
     }
 }
Exemplo n.º 5
0
        // Higher level functions.

        public long Insert(TableExpression te, int[] colIx, int idCol, EvalEnv ee)
        {
            var ins = new Inserter(this, colIx, idCol, te);

            te.FetchTo(ins, ee);
            return(ins.LastIdInserted);
        }
        public override G.IEnumerable <long> All(EvalEnv ee)
        {
            V    = K.Eval(ee);
            Type = K.Type;
            foreach (IndexFileRecord r in F.From(Compare, Op <= Token.LessEqual /* Op == Token.Less || Op == Token.LessEqual */))
            {
                if (Op == Token.Equal)
                {
                    switch (K.Type)
                    {
                    case DataType.Bigint: if (r.Col[0].L != V.L)
                        {
                            yield break;
                        }
                        break;

                    case DataType.Binary: if (Util.Compare((byte[])r.Col[0]._O, (byte[])V._O) != 0)
                        {
                            yield break;
                        }
                        break;

                    case DataType.String: if (((string)r.Col[0]._O) != (string)V._O)
                        {
                            yield break;
                        }
                        break;

                    default: throw new System.Exception("Type error");
                    }
                }
                yield return(r.Col[F.Inf.KeyCount - 1].L);
            }
        }
 public override G.IEnumerable <long> All(EvalEnv ee)
 {
     for (int i = 1; i <= N; i += 1)
     {
         yield return(i);
     }
 }
Exemplo n.º 8
0
 public override G.IEnumerable <long> All(EvalEnv ee)
 {
     Value [] row = new Value[1];
     foreach (bool b in TE.GetAll(row, new int[] { 0 }, ee))
     {
         yield return(row[0].L);
     }
 }
Exemplo n.º 9
0
 public override G.IEnumerable <long> All(EvalEnv ee)
 {
     G.SortedSet <long> copy = new G.SortedSet <long>();
     foreach (long id in X.All(ee))
     {
         copy.Add(id);
     }
     foreach (long id in copy)
     {
         yield return(id);
     }
 }
Exemplo n.º 10
0
 public override G.IEnumerable <long> All(EvalEnv ee)
 {
     V = K(ee);
     foreach (IndexFileRecord r in F.From(Compare, Op <= Token.LessEqual))
     {
         if (Op == Token.Equal && !Util.Equals(r.Col[0], V, Type))
         {
             yield break;
         }
         yield return(r.Col[F.Inf.KeyCount - 1].L);
     }
 }
        public override G.IEnumerable <long> All(EvalEnv ee)
        {
            StoredTable t = S.Table;

            G.List <Value[]> rows = t.Rows;

            for (int i = 0; i < rows.Count; i += 1)
            {
                Value[] row = rows[i];
                yield return(row[0].L);
            }
        }
Exemplo n.º 12
0
        public override G.IEnumerable <bool> GetAll(Value[] row, int [] cols, EvalEnv ee)
        {
            long n = RowCount;

            for (long id = 1; id <= n; id += 1)
            {
                if (Get(id, row, cols))
                {
                    yield return(true);
                }
            }
        }
Exemplo n.º 13
0
        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 override G.IEnumerable <long> All(EvalEnv ee)
 {
     foreach (Value v in Values)
     {
         DataType t     = Ix.Inf.Types[0];
         int      idCol = Ix.Inf.KeyCount - 1;
         var      start = new ValueStart(v, t);
         foreach (IndexFileRecord r in Ix.From(start.Compare, false))
         {
             if (Util.Compare(v, r.Col[0], t) == 0)
             {
                 yield return(r.Col[idCol].L);
             }
             else
             {
                 break;
             }
         }
     }
 }
Exemplo n.º 15
0
        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 override G.IEnumerable <long> All(EvalEnv ee)
        {
            Value v = X.Eval(ee);

            yield return(v.L);
        }
Exemplo n.º 17
0
        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);
                    }
                }
            }
        }
Exemplo n.º 18
0
 public override G.IEnumerable <long> All(EvalEnv ee)
 {
     yield return(X(ee));
 }
 public TableExpressionIdSet(TableExpression te, EvalEnv ee)
 {
     te.FetchTo(S, ee);
 }
 public ExpListIdSet(Exp[] list, EvalEnv e)
 {
     List = list;
 }
 public abstract G.IEnumerable <long> All(EvalEnv ee);