Search in sources :

Example 6 with ForEachQueryIterator

use of lucee.runtime.type.it.ForEachQueryIterator in project Lucee by lucee.

the class Map method invoke.

private static Query invoke(PageContext pc, Query qry, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures, Query rtn) throws PageException {
    Key[] colNames = qry.getColumnNames();
    if (rtn == null) {
        rtn = new QueryImpl(colNames, 0, qry.getName());
    } else {
        // check if we have the necessary columns
        for (Key colName : colNames) {
            if (rtn.getColumn(colName, null) == null) {
                rtn.addColumn(colName, new ArrayImpl());
            }
        }
    }
    final int pid = pc.getId();
    ForEachQueryIterator it = new ForEachQueryIterator(qry, pid);
    int rowNbr;
    Object row, res;
    boolean async = es != null;
    while (it.hasNext()) {
        row = it.next();
        rowNbr = qry.getCurrentrow(pid);
        res = _inv(pc, udf, new Object[] { row, rowNbr, qry }, rowNbr, es, futures);
        if (!async) {
            addRow(Caster.toStruct(res), rtn);
        }
    }
    return rtn;
}
Also used : ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator) QueryImpl(lucee.runtime.type.QueryImpl) ArrayImpl(lucee.runtime.type.ArrayImpl) Key(lucee.runtime.type.Collection.Key) ArgumentIntKey(lucee.runtime.type.scope.ArgumentIntKey)

Example 7 with ForEachQueryIterator

use of lucee.runtime.type.it.ForEachQueryIterator in project Lucee by lucee.

the class Some method invoke.

private static boolean invoke(PageContext pc, Query qry, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures) throws CasterException, PageException {
    final int pid = pc.getId();
    ForEachQueryIterator it = new ForEachQueryIterator(qry, pid);
    boolean async = es != null;
    double r;
    Object res, row;
    try {
        while (it.hasNext()) {
            row = it.next();
            r = Caster.toDoubleValue(qry.getCurrentrow(pid));
            res = _inv(pc, udf, new Object[] { row, r, qry }, r, row, es, futures);
            if (!async && Caster.toBooleanValue(res)) {
                return true;
            }
        }
    } finally {
        it.reset();
    }
    return false;
}
Also used : ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator)

Aggregations

ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)7 ArrayImpl (lucee.runtime.type.ArrayImpl)2 Key (lucee.runtime.type.Collection.Key)2 QueryImpl (lucee.runtime.type.QueryImpl)2 ArgumentIntKey (lucee.runtime.type.scope.ArgumentIntKey)2 ConverterException (lucee.runtime.converter.ConverterException)1 JSONConverter (lucee.runtime.converter.JSONConverter)1 FunctionException (lucee.runtime.exp.FunctionException)1 Array (lucee.runtime.type.Array)1 Query (lucee.runtime.type.Query)1