Fetch all items.

            :param limit: How many rows to fetch.
            :param order_by: column on which to order the results. \
            To change the sort, prepend with < or >.
353440
def all(self, order_by=None, limit=0):
        
        with rconnect() as conn:
            try:
                query = self._base()
                if order_by is not None:
                    query = self._order_by(query, order_by)
                if limit > 0:
                    query = self._limit(query, limit)

                log.debug(query)
                rv = query.run(conn)
            except Exception as e:
                log.warn(e)
                raise
            else:
                data = [self._model(_) for _ in rv]
                return data
663912
private function fetchRangeIds($limit, $start)
    {
        $qb = $this->createFilterAndSortQueryBuilder();
        $qb->select(['t.id', 'e.latest_version']);

        if (null !== $limit) {
            $qb->setFirstResult($start);
            $qb->setMaxResults($limit);
        }

        $rows = $this->connection->fetchAll($qb->getSQL());

        $ids = [];
        foreach ($rows as $row) {
            $ids[$row['id']] = $row['latest_version'];
        }

        return $ids;
    }
762400
def _get_formatted_query(self, fields, limit, order_by, offset):
        

        if not isinstance(order_by, list):
            raise InvalidUsage("Argument order_by should be a `list` of fields")

        if not isinstance(fields, list):
            raise InvalidUsage("Argument fields should be a `list` of fields")

        if isinstance(self.query, QueryBuilder):
            sysparm_query = str(self.query)
        elif isinstance(self.query, dict):  # Dict-type query
            sysparm_query = '^'.join(['%s=%s' % (k, v) for k, v in six.iteritems(self.query)])
        elif isinstance(self.query, six.string_types):  # String-type query
            sysparm_query = self.query
        else:
            raise InvalidUsage("Query must be instance of %s, %s or %s" % (QueryBuilder, str, dict))

        for field in order_by:
            if field[0] == '-':
                sysparm_query += "^ORDERBYDESC%s" % field[1:]
            else:
                sysparm_query += "^ORDERBY%s" % field

        params = {'sysparm_query': sysparm_query}
        params.update(self.request_params)

        if limit is not None:
            params.update({'sysparm_limit': limit, 'sysparm_suppress_pagination_header': True})

        if offset is not None:
            params.update({'sysparm_offset': offset})

        if len(fields) > 0:
            params.update({'sysparm_fields': ",".join(fields)})

        return params
935940
def items(self, limit=10000):
        
        _limit = 500
        if 'ids' in self.kwargs:
            col = self.kwargs.get('query', {}).get('collection', {}).get('eq', None)
            if col is None:
                raise SatSearchError('Collection required when searching by id')
            return self.items_by_id(self.kwargs['ids'], col)

        items = []
        found = self.found()
        if found > limit:
            logger.warning('There are more items found (%s) than the limit (%s) provided.' % (found, limit))
        maxitems = min(found, limit)
        kwargs = {
            'page': 1,
            'limit': min(_limit, maxitems)
        }
        kwargs.update(self.kwargs)
        while len(items) < maxitems:
            items += [Item(i) for i in self.query(**kwargs)['features']]
            kwargs['page'] += 1

        # retrieve collections
        collections = []
        for c in set([item.properties['collection'] for item in items if 'collection' in item.properties]):
            collections.append(self.collection(c))
            #del collections[c]['links']

        # merge collections into items
        #_items = []
        #for item in items:
        #    import pdb; pdb.set_trace()
        #    if 'collection' in item['properties']:
        #        item = dict_merge(item, collections[item['properties']['collection']])
        #    _items.append(Item(item))

        return Items(items, collections=collections, search=self.kwargs)
600108
def get_all(self, fields=list(), limit=None, order_by=list(), offset=None):
        """"""
        warnings.warn("get_all() is deprecated, please use get_multiple() instead", DeprecationWarning)
        return self.get_multiple(fields, limit, order_by, offset)
236284
public List<T> limit(int limit) {
        return ifReturn(Anima.of().isUseSQLLimit(),
                () -> {
                    isSQLLimit = true;
                    paramValues.add(limit);
                    return all();
                },
                () -> {
                    List<T> all = all();
                    return ifReturn(all.size() > limit,
                            all.stream().limit(limit).collect(toList()),
                            all);
                });
    }
1059195
def limit(self, value):
        
        self._query = self._query.limit(value)

        return self
772948
def find_all(self, table, limit=10):
        '''
        
        '''
        sql = "select * from {} limit 0,{}".format(table, limit)
        res = self.query(sql)
        return res
310827
def query_all(**kwargs):
        '''
        
        '''
        kind = kwargs.get('kind', '1')
        limit = kwargs.get('limit', 10)

        return TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.valid == 1)
        ).order_by(
            TabPost.time_update.desc()
        ).limit(limit)
147794
def _prefetch_items(self,change):
        
        if self.is_initialized:
            view = self.item_view
            
            upper_limit = view.iterable_index+view.iterable_fetch_size-view.iterable_prefetch
            lower_limit = max(0,view.iterable_index+view.iterable_prefetch)
            offset = int(view.iterable_fetch_size/2.0)
            upper_visible_row = view.visible_rect[2]
            lower_visible_row = view.visible_rect[0]
            print("Visible rect = %s"%view.visible_rect)
            
            if upper_visible_row >= upper_limit:
                next_index = max(0,upper_visible_row-offset) # Center on current row
                # Going up works... 
                if next_index>view.iterable_index:
                    print("Auto prefetch upper limit %s!"%upper_limit)
                    view.iterable_index = next_index
                    #view.model().reset()
                    
            # But doewn doesnt?
            elif view.iterable_index>0 and lower_visible_row < lower_limit:
                next_index = max(0,lower_visible_row-offset) # Center on current row
                # Going down works
                if next_index<view.iterable_index:
                    print("Auto prefetch lower limit=%s, iterable=%s, setting next=%s!"%(lower_limit,view.iterable_index,next_index))
                    view.iterable_index = next_index
1081511
def fetch(self, limit, offset=0):
        """"""
        self.limit = limit
        self.offset = offset
        return self
236473
public List<T> fetchList(int limit) throws SQLException, InstantiationException, IllegalAccessException {
        ArrayList<T> result = new ArrayList<T>();
        if (primitive) {
            for (int i = 0; i < limit; i++) {
                if (!finished) {
                    result.add(fetchSingleInternal());
                    next();
                } else {
                    break;
                }
            }
        } else {
            for (int i = 0; i < limit; i++) {
                if (!finished) {
                    result.add(fetchSingleInternal());
                    next();
                } else {
                    break;
                }
            }
        }

        return result;
    }
665969
def fetch_in_batch(query, batch_size = 1000, &block)
      raise "No block given for the batch fetch request!" unless block_given?
      
      # Execute the query and check the result
      exec_result = execute(query)
      raise_error_if_failed!(exec_result)

      # Get search operation handle to fetch the results
      op_handle = exec_result.operationHandle

      # Prepare fetch results request
      fetch_req = prepare_fetch_results(op_handle, :next, batch_size)

      # Now let's iterate over the results
      loop do
        rows = fetch_rows(op_handle, :next, batch_size)
        break if rows.empty?
        yield rows
      end
    end
1311126
def fetch(query, max_rows = 100)
      # Execute the query and check the result
      exec_result = execute(query)
      raise_error_if_failed!(exec_result)

      # Get search operation handle to fetch the results
      op_handle = exec_result.operationHandle
      
      # Fetch the rows
      fetch_rows(op_handle, :first, max_rows)
    end
288762
def async_fetch(handles, max_rows = 100)
      # Can't get data from an unfinished query
      unless async_is_complete?(handles)
        raise "Can't perform fetch on a query in state: #{async_state(handles)}"
      end
      
      # Fetch and
      fetch_rows(prepare_operation_handle(handles), :first, max_rows)
    end
399955
def get_sort_limit():
    
    limit = _.convert(get("sort_limit"), _.to_int)
    if (limit < 1):
        limit = None  # catalog raises IndexError if limit < 1
    return limit
972146
def _get_query(self, order=None, filters=None):
        
        order = self._get_order(order)
        return self.posts.all().order_by(order)