Set limit spec

@see http://druid.io/docs/0.6.120/LimitSpec.html
@param {string|object} [type=default] Type of LimitSpec or LimitSpec object
@param {number} [limit] Limit of records
@param {object[]} [orderByColumns] Sorting columns
returns {object}
16877
function limitSpec(type, limit, orderByColumns) {
  if (utils.isObject(type)) {
    return type
  }

  if (typeof limit !== 'number') {
    limit = parseInt(limit, 10)
  }

  if (type !== 'default') {
    throw new FieldError('Currently only DefaultLimitSpec is supported')
  }
  else if (isNaN(limit)) {
    throw new FieldTypeError('limitSpec.limit', 'number')
  }
  else if (!Array.isArray(orderByColumns)) {
    throw new FieldTypeError('limitSpec.columns', 'array')
  }

  return {
    type:    type,
    limit:   parseInt(limit, 10),
    columns: orderByColumns
  }
}
973088
function _processOrderByOffsetLimit(orderByInfo,offsetInfo,limitInfo){
    // save the OFFSET AND LIMIT nodes with the ORDER BY node
    orderByInfo.node.msSQLOffsetNode=offsetInfo.node;
    if (limitInfo) orderByInfo.node.msSQLLimitNode=limitInfo.node;
    // remove the OFFSET and LIMIT nodes from the filters so they don't get processed later.
    filters.splice(offsetInfo.index,1);
    if (limitInfo) filters.splice(limitInfo.index,1);
  }
1009135
function _processLimit(limitInfo){
    var selectInfo=Mssql.super_.prototype.findNode.call(this, actions, "SELECT"); // jshint ignore:line
    assert(selectInfo!==undefined,"MS SQL Server requires a SELECT clause when using LIMIT");
    // save the LIMIT node with the SELECT node
    selectInfo.node.msSQLLimitNode=limitInfo.node;
    // remove the LIMIT node from the filters so it doesn't get processed later.
    filters.splice(limitInfo.index,1);
  }
387578
public static LimitOrder adaptOrder(
      BigDecimal originalAmount,
      BigDecimal price,
      String tradedCurrency,
      String transactionCurrency,
      String orderTypeString,
      String id,
      Date timestamp) {

    // place a limit order
    OrderType orderType = adaptSide(orderTypeString);
    CurrencyPair currencyPair = adaptCurrencyPair(tradedCurrency, transactionCurrency);

    LimitOrder limitOrder =
        new LimitOrder(orderType, originalAmount, currencyPair, id, timestamp, price);

    return limitOrder;
  }
1064197
@Deprecated
    protected int handleGetLimit(int field, int limitType) {
        if (isAmeteAlemEra() && field == ERA) {
            return 0; // Only one era in this mode, era is always 0
        }
        return super.handleGetLimit(field, limitType);
    }
1185375
@SuppressWarnings("fallthrough")
    protected int handleGetLimit(int field, int limitType) {
        switch (field) {
        case ERA:
            if (limitType == MINIMUM || limitType == GREATEST_MINIMUM) {
                return 0;
            }
            return CURRENT_ERA;
        case YEAR:
        {
            switch (limitType) {
            case MINIMUM:
            case GREATEST_MINIMUM:
                return 1;
            case LEAST_MAXIMUM:
                return 1;
            case MAXIMUM:
                return super.handleGetLimit(field, MAXIMUM) - ERAS[CURRENT_ERA*3];
            }
            //Fall through to the default if not handled above
        }
        default:
            return super.handleGetLimit(field, limitType);
        }
    }
148591
public static LimitOrder createOrder(
      CurrencyPair currencyPair,
      BitcoindeOrder bitcoindeOrder,
      Order.OrderType orderType,
      String orderId,
      Date timeStamp) {

    return new LimitOrder(
        orderType,
        bitcoindeOrder.getAmount(),
        currencyPair,
        orderId,
        timeStamp,
        bitcoindeOrder.getPrice());
  }
406065
private function configureWindow(SelectQuery $query, array $orderBy, int $limit = 0)
    {
        if (!empty($orderBy)) {
            $decorator = new AliasDecorator($query, 'where', $this->getAlias());
            $decorator->orderBy($orderBy);
        }

        if ($limit !== 0) {
            $query->limit($limit);
        }
    }
563408
function getRange(start, limit, raw, store) {
      // Monitor values
      start = start || start === 0 ? parseInt(start) : null;
      limit = limit || limit === 0 ? parseInt(limit) : null;

      var data = raw == false ? store.data.asObject() : Object.assign({}, store.rootData.asObject());
      var rangeData = {};
      var isArray = store.data.__sorted && !raw;
      
      if (isArray) {
        data = raw == false ? store.data.asArray() : Object.assign({}, store.rootData.asObject());
        rangeData = [];
      }
      
      var size = Object.keys(data).length;

      if (
        start &&
        typeof start == "number" &&
        (limit || typeof limit == "number")
      ) {
        var index = 1;

        function rangeLoop(item) {
          // Check start item key
          if (index >= start && index <= limit) {
            if (isArray) {
              rangeData.push(data[item]);
            } else {
              rangeData[item] = data[item];
            }
          }
          index++;
        }
        // Loop through data object items
        if (isArray) {
          for (var i = 0; i < data.length; i++) {
            rangeLoop(i);
            if (index > limit) {
              break;
            }
          }
        } else {
          for (var key in data) {
            rangeLoop(key);
            if (index > limit) {
              break;
            }
          }
        }
      } else {
        vcomet.error.log("store", "Incorrect range values format");
      }
      // Update store data object
      store.rangeData = new Result(rangeData, store, store.data.__sorted);
      store.size = size;

    }
132323
public void update(LimitOrder limitOrder) {

    update(getOrders(limitOrder.getType()), limitOrder);
    updateDate(limitOrder.getTimestamp());
  }
198711
def column_options
      { limit: column.limit, default: column.default, null: column.null }
    end
899541
protected function set_limit($query, $limit = 0, $offset = 0)
    {
        $limit  = intval($limit);
        $offset = intval($offset);
        $end    = $offset + $limit;

        // query without OFFSET
        if (!$offset) {
            $query = preg_replace('/^SELECT\s/i', "SELECT TOP $limit ", $query);
            return $query;
        }

        $orderby = stristr($query, 'ORDER BY');
        $offset += 1;

        if ($orderby !== false) {
            $query = trim(substr($query, 0, -1 * strlen($orderby)));
        }
        else {
            // it shouldn't happen, paging without sorting has not much sense
            // @FIXME: I don't know how to build paging query without ORDER BY
            $orderby = "ORDER BY 1";
        }

        $query = preg_replace('/^SELECT\s/i', '', $query);
        $query = "WITH paging AS (SELECT ROW_NUMBER() OVER ($orderby) AS [RowNumber], $query)"
            . " SELECT * FROM paging WHERE [RowNumber] BETWEEN $offset AND $end ORDER BY [RowNumber]";

        return $query;
    }
272229
public static void limit (Collection<?> col, int limit)
    {
        int size = col.size();
        if (size > limit) {
            if (col instanceof List<?>) {
                ((List<?>) col).subList(limit, size).clear();

            } else {
                Iterator<?> itr = col.iterator();
                for (int ii = 0; ii < limit; ii++) {
                    itr.next();
                }
                while (itr.hasNext()) {
                    itr.next();
                    itr.remove();
                }
            }
        }
    }
460489
def limit(num)
      relation = __new_relation__(all.take(num))
      relation.send(:set_from_limit)
      relation
    end
301177
function limitBy (arr, n, offset) {
  offset = offset ? parseInt(offset, 10) : 0
  n = util.toNumber(n)
  return typeof n === 'number'
    ? arr.slice(offset, offset + n)
    : arr
}
1204469
@Nonnull
  public TypeaheadDataset setLimit (@Nonnegative final int nLimit)
  {
    ValueEnforcer.isGT0 (nLimit, "Limit");
    m_nLimit = nLimit;
    return this;
  }
337025
private void setupQuery(Query query, Object[] paramValues, Type[] paramTypes, Integer offset, Integer limit){
    	if (paramValues != null && paramTypes != null){
        	query.setParameters(paramValues, paramTypes);
    	}
    	if (offset != null){
        	query.setFirstResult(offset);
    	}
    	if (limit != null){
        	query.setMaxResults(limit);
    	}
    }