Search in sources :

Example 1 with OrderTsk

use of hex.OrderTsk in project h2o-2 by h2oai.

the class Order method serve.

@Override
protected Response serve() {
    if (// global order not supported
    n > 10000)
        throw H2O.unimpl();
    long[] espc = new long[] { 0, n };
    final Vec[] dst = new Vec(Vec.newKey(), espc).makeZeros(cols.length);
    H2OEmptyCompleter cmp = new H2OEmptyCompleter();
    cmp.setPendingCount(cols.length - 1);
    final int addOne = (add_one ? 1 : 0);
    for (int i = 0; i < cols.length; ++i) {
        final int fi = i;
        new OrderTsk(new H2OCallback<OrderTsk>(cmp) {

            @Override
            public void callback(OrderTsk ot) {
                Vec.Writer w = dst[fi].open();
                for (int j = 0; j < ot._ids.length; ++j) w.set(j, ot._ids[j] + addOne);
                w.close();
            }
        }, n, rev).asyncExec(source.vec(cols[i]));
    }
    cmp.join();
    Futures fs = new Futures();
    if (destination_key == null)
        destination_key = Key.make(source._key.toString() + ".order");
    DKV.put(destination_key, new Frame(destination_key, Utils.select(source.names(), cols), dst), fs);
    fs.blockForPending();
    return Inspect2.redirect(this, destination_key.toString());
}
Also used : OrderTsk(hex.OrderTsk) H2OCallback(water.H2O.H2OCallback) H2OEmptyCompleter(water.H2O.H2OEmptyCompleter)

Aggregations

OrderTsk (hex.OrderTsk)1 H2OCallback (water.H2O.H2OCallback)1 H2OEmptyCompleter (water.H2O.H2OEmptyCompleter)1