All Downloads are FREE. Search and download functionalities are using the official Maven repository.

water.api.GridsHandler Maven / Gradle / Ivy

There is a newer version: 3.8.2.9
Show newest version
package water.api;

import hex.grid.Grid;
import hex.schemas.GridSchemaV99;
import water.Key;
import water.KeySnapshot;
import water.Value;

/**
 * /Grids/ end-point handler.
 */
public class GridsHandler extends Handler {

  /**
   * Return all the grids.
   */
  @SuppressWarnings("unused") // called through reflection by RequestServer
  public GridsV99 list(int version, GridsV99 s) {
    final Key[] gridKeys = KeySnapshot.globalSnapshot().filter(new KeySnapshot.KVFilter() {
      @Override
      public boolean filter(KeySnapshot.KeyInfo k) {
        return Value.isSubclassOf(k._type, Grid.class);
      }
    }).keys();

    s.grids = new GridSchemaV99[gridKeys.length];
    for (int i = 0; i < gridKeys.length; i++) {
      s.grids[i] = new GridSchemaV99();
      s.grids[i].fillFromImpl(getFromDKV("(none)", gridKeys[i], Grid.class));
    }

    return s;
  }

  /**
   * Return a specified grid.
   */
  @SuppressWarnings("unused") // called through reflection by RequestServer
  public GridSchemaV99 fetch(int version, GridSchemaV99 s) {
    return s.fillFromImpl(getFromDKV("grid_id", s.grid_id.key(), Grid.class));
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy