use of org.locationtech.geowave.analytic.spark.kde.KDERunner in project geowave by locationtech.
the class KDESparkCommand method computeResults.
@Override
public Void computeResults(final OperationParams params) throws Exception {
final String inputStoreName = parameters.get(0);
final String outputStoreName = parameters.get(1);
// Config file
final File configFile = getGeoWaveConfigFile(params);
// Attempt to load input store.
inputDataStore = CLIUtils.loadStore(inputStoreName, configFile, params.getConsole());
// Attempt to load output store.
outputDataStore = CLIUtils.loadStore(outputStoreName, configFile, params.getConsole());
final KDERunner runner = new KDERunner();
runner.setAppName(kdeSparkOptions.getAppName());
runner.setMaster(kdeSparkOptions.getMaster());
runner.setHost(kdeSparkOptions.getHost());
runner.setSplits(kdeSparkOptions.getMinSplits(), kdeSparkOptions.getMaxSplits());
runner.setInputDataStore(inputDataStore);
runner.setTypeName(kdeSparkOptions.getTypeName());
runner.setOutputDataStore(outputDataStore);
runner.setCoverageName(kdeSparkOptions.getCoverageName());
runner.setIndexName(kdeSparkOptions.getIndexName());
runner.setMinLevel(kdeSparkOptions.getMinLevel());
runner.setMaxLevel(kdeSparkOptions.getMaxLevel());
runner.setTileSize((int) Math.sqrt(kdeSparkOptions.getTileSize()));
if ((kdeSparkOptions.getOutputIndex() != null) && !kdeSparkOptions.getOutputIndex().trim().isEmpty()) {
final String outputIndex = kdeSparkOptions.getOutputIndex();
// Load the Indices
final List<Index> outputIndices = DataStoreUtils.loadIndices(outputDataStore.createIndexStore(), outputIndex);
for (final Index primaryIndex : outputIndices) {
if (SpatialDimensionalityTypeProvider.isSpatial(primaryIndex)) {
runner.setOutputIndex(primaryIndex);
} else {
LOGGER.error("spatial temporal is not supported for output index. Only spatial index is supported.");
throw new IOException("spatial temporal is not supported for output index. Only spatial index is supported.");
}
}
}
if (kdeSparkOptions.getCqlFilter() != null) {
runner.setCqlFilter(kdeSparkOptions.getCqlFilter());
}
runner.setOutputDataStore(outputDataStore);
try {
runner.run();
} catch (final IOException e) {
throw new RuntimeException("Failed to execute: " + e.getMessage());
} finally {
runner.close();
}
return null;
}
Aggregations