private Result <T> ReturnRows2 <T>(WAHBitArray ba, List <T> trows, int start, int count, List <int> orderby) { DateTime dt = FastDateTime.Now; List <T> rows = new List <T>(); Result <T> ret = new Result <T>(); int skip = start; int c = 0; ret.TotalCount = (int)ba.CountOnes(); if (count == -1) { count = ret.TotalCount; } if (count > 0) { foreach (int i in orderby) { if (ba.Get(i)) { if (skip > 0) { skip--; } else { bool b = OutputRow <T>(rows, i); if (b && count > 0) { c++; } } ba.Set(i, false); if (c == count) { break; } } } foreach (int i in ba.GetBitIndexes()) { if (c < count) { if (skip > 0) { skip--; } else { bool b = OutputRow <T>(rows, i); if (b && count > 0) { c++; } } if (c == count) { break; } } } } if (trows != null)// TODO : move to start and decrement in count { foreach (var o in trows) { rows.Add(o); } } _log.Debug("query rows fetched (ms) : " + FastDateTime.Now.Subtract(dt).TotalMilliseconds); _log.Debug("query rows count : " + rows.Count.ToString("#,0")); ret.OK = true; ret.Count = rows.Count; ret.Rows = rows; return(ret); }
internal Result <object> Query(int start, int count, string orderby) { // no filter query -> just show all the data DateTime dt = FastDateTime.Now; _log.Debug("query : " + _view.Name); int totalviewrows = _viewData.Count(); List <object> rows = new List <object>(); Result <object> ret = new Result <object>(); int skip = start; int cc = 0; WAHBitArray del = _deletedRows.GetBits(); ret.TotalCount = totalviewrows - (int)del.CountOnes(); var order = SortBy(orderby); if (order.Count == 0) { for (int i = 0; i < totalviewrows; i++) { order.Add(i); } } if (count == -1) { count = totalviewrows; } foreach (int i in order) { if (del.Get(i) == true) { continue; } if (skip > 0) { skip--; } else { bool b = OutputRow <object>(rows, i); if (b && count > 0) { cc++; } } if (cc == count) { break; } } _log.Debug("query rows fetched (ms) : " + FastDateTime.Now.Subtract(dt).TotalMilliseconds); _log.Debug("query rows count : " + rows.Count.ToString("#,0")); ret.OK = true; ret.Count = rows.Count; //ret.TotalCount = rows.Count; ret.Rows = rows; return(ret); }