public override RowSet RowSet(STransaction tr, SQuery top, SDict <long, SFunction> ags, Context cx)
        {
            for (var b = order.First(); b != null; b = b.Next())
            {
                ags = b.Value.col.Aggregates(ags, cx);
            }
            var ags1 = ags;

            for (var b = cpos.First(); b != null; b = b.Next())
            {
                ags1 = b.Value.Item2.Aggregates(ags1, cx);
            }
            RowSet r = new SelectRowSet(qry.RowSet(tr, this, ags1, cx), this, ags, cx);

            // perform another pass on the selectlist just in case
            if (!(qry is SGroupQuery))
            {
                for (var b = cpos.First(); b != null; b = b.Next())
                {
                    ags = b.Value.Item2.Aggregates(ags, cx);
                }
                if (ags.Length != 0)
                {
                    r = new EvalRowSet(((SelectRowSet)r)._source, this, ags, cx);
                }
            }
            if (distinct)
            {
                r = new DistinctRowSet(r);
            }
            if (order.Length != 0)
            {
                r = new OrderedRowSet(r, this, cx);
            }
            return(r);
        }
 internal static OrderedBookmark?New(OrderedRowSet ors)
 {
     return((ors._tree.First() is MTreeBookmark <Serialisable> rb) ?
            new OrderedBookmark(ors, rb, 0) : null);
 }
 OrderedBookmark(OrderedRowSet ors, MTreeBookmark <Serialisable> bmk, int pos)
     : base(ors, ors._rows[(int)bmk.Value.Item2], pos)
 {
     _ors = ors; _bmk = bmk;
 }