Search in sources :

Example 1 with Projection

use of org.locationtech.geowave.analytic.Projection in project geowave by locationtech.

the class ConvexHullJobRunnerTest method init.

@Before
public void init() {
    final SimpleFeatureType ftype = AnalyticFeature.createGeometryFeatureAdapter("centroidtest", new String[] { "extra1" }, BasicFeatureTypes.DEFAULT_NAMESPACE, ClusteringUtils.CLUSTERING_CRS).getFeatureType();
    hullRunner.setMapReduceIntegrater(new MapReduceIntegration() {

        @Override
        public int submit(final Configuration configuration, final PropertyManagement runTimeProperties, final GeoWaveAnalyticJobRunner tool) throws Exception {
            tool.setConf(configuration);
            ((ParameterHelper<Object>) StoreParam.INPUT_STORE.getHelper()).setValue(configuration, ConvexHullMapReduce.class, StoreParam.INPUT_STORE.getHelper().getValue(runTimeProperties));
            return tool.run(new String[] {});
        }

        @Override
        public Counters waitForCompletion(final Job job) throws ClassNotFoundException, IOException, InterruptedException {
            Assert.assertEquals(SequenceFileInputFormat.class, job.getInputFormatClass());
            Assert.assertEquals(10, job.getNumReduceTasks());
            final ScopedJobConfiguration configWrapper = new ScopedJobConfiguration(job.getConfiguration(), ConvexHullMapReduce.class);
            Assert.assertEquals("file://foo/bin", job.getConfiguration().get("mapred.input.dir"));
            final PersistableStore persistableStore = (PersistableStore) StoreParam.INPUT_STORE.getHelper().getValue(job, ConvexHullMapReduce.class, null);
            final IndexStore indexStore = persistableStore.getDataStoreOptions().createIndexStore();
            try {
                Assert.assertTrue(indexStore.indexExists("spatial"));
                final PersistableStore persistableAdapterStore = (PersistableStore) StoreParam.INPUT_STORE.getHelper().getValue(job, ConvexHullMapReduce.class, null);
                final PersistentAdapterStore adapterStore = persistableAdapterStore.getDataStoreOptions().createAdapterStore();
                Assert.assertTrue(adapterStore.adapterExists(persistableAdapterStore.getDataStoreOptions().createInternalAdapterStore().getAdapterId("centroidtest")));
                final Projection<?> projection = configWrapper.getInstance(HullParameters.Hull.PROJECTION_CLASS, Projection.class, SimpleFeatureProjection.class);
                Assert.assertEquals(SimpleFeatureProjection.class, projection.getClass());
            } catch (final InstantiationException e) {
                throw new IOException("Unable to configure system", e);
            } catch (final IllegalAccessException e) {
                throw new IOException("Unable to configure system", e);
            }
            Assert.assertEquals(10, job.getNumReduceTasks());
            Assert.assertEquals(2, configWrapper.getInt(CentroidParameters.Centroid.ZOOM_LEVEL, -1));
            return new Counters();
        }

        @Override
        public Job getJob(final Tool tool) throws IOException {
            return new Job(tool.getConf());
        }

        @Override
        public Configuration getConfiguration(final PropertyManagement runTimeProperties) throws IOException {
            return new Configuration();
        }
    });
    hullRunner.setInputFormatConfiguration(new SequenceFileInputFormatConfiguration());
    runTimeProperties.store(MRConfig.HDFS_BASE_DIR, "/");
    runTimeProperties.store(InputParameters.Input.HDFS_INPUT_PATH, new Path("file://foo/bin"));
    runTimeProperties.store(GlobalParameters.Global.BATCH_ID, "b1234");
    runTimeProperties.store(HullParameters.Hull.DATA_TYPE_ID, "hullType");
    runTimeProperties.store(HullParameters.Hull.REDUCER_COUNT, 10);
    runTimeProperties.store(HullParameters.Hull.INDEX_NAME, "spatial");
    final DataStorePluginOptions pluginOptions = new DataStorePluginOptions();
    GeoWaveStoreFinder.getRegisteredStoreFactoryFamilies().put("memory", new MemoryStoreFactoryFamily());
    pluginOptions.selectPlugin("memory");
    final MemoryRequiredOptions opts = (MemoryRequiredOptions) pluginOptions.getFactoryOptions();
    final String namespace = "test_" + getClass().getName() + "_" + name.getMethodName();
    opts.setGeoWaveNamespace(namespace);
    final PersistableStore store = new PersistableStore(pluginOptions);
    runTimeProperties.store(StoreParam.INPUT_STORE, store);
    final FeatureDataAdapter adapter = new FeatureDataAdapter(ftype);
    pluginOptions.createAdapterStore().addAdapter(adapter.asInternalAdapter(pluginOptions.createInternalAdapterStore().addTypeName(adapter.getTypeName())));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) SequenceFileInputFormatConfiguration(org.locationtech.geowave.analytic.mapreduce.SequenceFileInputFormatConfiguration) SimpleFeatureProjection(org.locationtech.geowave.analytic.SimpleFeatureProjection) Projection(org.locationtech.geowave.analytic.Projection) MemoryStoreFactoryFamily(org.locationtech.geowave.core.store.memory.MemoryStoreFactoryFamily) DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) Job(org.apache.hadoop.mapreduce.Job) MapReduceIntegration(org.locationtech.geowave.analytic.mapreduce.MapReduceIntegration) SequenceFileInputFormatConfiguration(org.locationtech.geowave.analytic.mapreduce.SequenceFileInputFormatConfiguration) MemoryRequiredOptions(org.locationtech.geowave.core.store.memory.MemoryRequiredOptions) Tool(org.apache.hadoop.util.Tool) ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) Path(org.apache.hadoop.fs.Path) ConvexHullMapReduce(org.locationtech.geowave.analytic.mapreduce.clustering.ConvexHullMapReduce) SequenceFileInputFormat(org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat) PropertyManagement(org.locationtech.geowave.analytic.PropertyManagement) IOException(java.io.IOException) IOException(java.io.IOException) GeoWaveAnalyticJobRunner(org.locationtech.geowave.analytic.mapreduce.GeoWaveAnalyticJobRunner) PersistentAdapterStore(org.locationtech.geowave.core.store.adapter.PersistentAdapterStore) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) PersistableStore(org.locationtech.geowave.analytic.store.PersistableStore) Counters(org.apache.hadoop.mapreduce.Counters) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) IndexStore(org.locationtech.geowave.core.store.index.IndexStore) SimpleFeatureProjection(org.locationtech.geowave.analytic.SimpleFeatureProjection) Before(org.junit.Before)

Aggregations

IOException (java.io.IOException)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 Counters (org.apache.hadoop.mapreduce.Counters)1 Job (org.apache.hadoop.mapreduce.Job)1 SequenceFileInputFormat (org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat)1 Tool (org.apache.hadoop.util.Tool)1 Before (org.junit.Before)1 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)1 Projection (org.locationtech.geowave.analytic.Projection)1 PropertyManagement (org.locationtech.geowave.analytic.PropertyManagement)1 ScopedJobConfiguration (org.locationtech.geowave.analytic.ScopedJobConfiguration)1 SimpleFeatureProjection (org.locationtech.geowave.analytic.SimpleFeatureProjection)1 GeoWaveAnalyticJobRunner (org.locationtech.geowave.analytic.mapreduce.GeoWaveAnalyticJobRunner)1 MapReduceIntegration (org.locationtech.geowave.analytic.mapreduce.MapReduceIntegration)1 SequenceFileInputFormatConfiguration (org.locationtech.geowave.analytic.mapreduce.SequenceFileInputFormatConfiguration)1 ConvexHullMapReduce (org.locationtech.geowave.analytic.mapreduce.clustering.ConvexHullMapReduce)1 PersistableStore (org.locationtech.geowave.analytic.store.PersistableStore)1 PersistentAdapterStore (org.locationtech.geowave.core.store.adapter.PersistentAdapterStore)1 DataStorePluginOptions (org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions)1