Beispiel #1
0
        internal Result <T> Query2 <T>(Expression <Predicate <T> > filter, int start, int count, string orderby)
        {
            DateTime dt = FastDateTime.Now;

            _log.Debug("query : " + _view.Name);

            WAHBitArray ba = new WAHBitArray();

            QueryVisitor qv = new QueryVisitor(QueryColumnExpression);

            qv.Visit(filter);
            var delbits = _deletedRows.GetBits();

            if (qv._bitmap.Count > 0)
            {
                WAHBitArray qbits = (WAHBitArray)qv._bitmap.Pop();
                ba = qbits.AndNot(delbits);
            }
            List <T> trows = null;

            if (_viewmanager.inTransaction())
            {
                // query from transactions own data
                tran_data data = null;
                if (_transactions.TryGetValue(Thread.CurrentThread.ManagedThreadId, out data))
                {
                    List <T> rrows = new List <T>();
                    foreach (var kv in data.rows)
                    {
                        foreach (var r in kv.Value)
                        {
                            object o = FastCreateObject(_view.Schema);
                            rrows.Add((T)_rowfiller(o, r));
                        }
                    }
                    trows = rrows.FindAll(filter.Compile());
                }
            }
            var order = SortBy(orderby);

            _log.Debug("query bitmap done (ms) : " + FastDateTime.Now.Subtract(dt).TotalMilliseconds);
            dt = FastDateTime.Now;
            // exec query return rows
            return(ReturnRows2 <T>(ba, trows, start, count, order));
        }