Search in sources :

Example 1 with GeoWaveExtractNNJobRunner

use of org.locationtech.geowave.analytic.mapreduce.nn.GeoWaveExtractNNJobRunner in project geowave by locationtech.

the class NearestNeighborCommand method computeResults.

@Override
public Void computeResults(final OperationParams params) throws Exception {
    // Ensure we have all the required arguments
    if ((parameters.size() != 1) && (inputStoreOptions == null)) {
        throw new ParameterException("Requires arguments: <storename>");
    }
    final String inputStoreName = parameters.get(0);
    // Config file
    final File configFile = getGeoWaveConfigFile(params);
    if (commonOptions.getMapReduceHdfsHostPort() == null) {
        final Properties configProperties = ConfigOptions.loadProperties(configFile);
        final String hdfsFSUrl = ConfigHDFSCommand.getHdfsUrl(configProperties);
        commonOptions.setMapReduceHdfsHostPort(hdfsFSUrl);
    }
    // Attempt to load store.
    inputStoreOptions = CLIUtils.loadStore(inputStoreName, getGeoWaveConfigFile(params), params.getConsole());
    // Save a reference to the store in the property management.
    final PersistableStore persistedStore = new PersistableStore(inputStoreOptions);
    final PropertyManagement properties = new PropertyManagement();
    properties.store(StoreParameters.StoreParam.INPUT_STORE, persistedStore);
    // Convert properties from DBScanOptions and CommonOptions
    final PropertyManagementConverter converter = new PropertyManagementConverter(properties);
    converter.readProperties(commonOptions);
    converter.readProperties(nnOptions);
    properties.store(Extract.QUERY, commonOptions.buildQuery());
    final GeoWaveExtractNNJobRunner runner = new GeoWaveExtractNNJobRunner();
    final int status = runner.run(properties);
    if (status != 0) {
        throw new RuntimeException("Failed to execute: " + status);
    }
    return null;
}
Also used : PropertyManagementConverter(org.locationtech.geowave.analytic.mapreduce.operations.options.PropertyManagementConverter) GeoWaveExtractNNJobRunner(org.locationtech.geowave.analytic.mapreduce.nn.GeoWaveExtractNNJobRunner) PersistableStore(org.locationtech.geowave.analytic.store.PersistableStore) ParameterException(com.beust.jcommander.ParameterException) PropertyManagement(org.locationtech.geowave.analytic.PropertyManagement) Properties(java.util.Properties) File(java.io.File)

Aggregations

ParameterException (com.beust.jcommander.ParameterException)1 File (java.io.File)1 Properties (java.util.Properties)1 PropertyManagement (org.locationtech.geowave.analytic.PropertyManagement)1 GeoWaveExtractNNJobRunner (org.locationtech.geowave.analytic.mapreduce.nn.GeoWaveExtractNNJobRunner)1 PropertyManagementConverter (org.locationtech.geowave.analytic.mapreduce.operations.options.PropertyManagementConverter)1 PersistableStore (org.locationtech.geowave.analytic.store.PersistableStore)1