Search in sources :

Example 1 with MapReduceDataStore

use of org.locationtech.geowave.mapreduce.MapReduceDataStore in project geowave by locationtech.

the class GeoWaveInputFormat method getSplits.

@Override
public List<InputSplit> getSplits(final JobContext context) throws IOException, InterruptedException {
    final Map<String, String> configOptions = getStoreOptionsMap(context);
    final DataStore dataStore = GeoWaveStoreFinder.createDataStore(configOptions);
    if ((dataStore != null) && (dataStore instanceof MapReduceDataStore)) {
        return ((MapReduceDataStore) dataStore).getSplits(getCommonQueryOptions(context), getDataTypeQueryOptions(context), getIndexQueryOptions(context), getQueryConstraints(context), getJobContextAdapterStore(context), getJobContextAdapterIndexMappingStore(context), getJobContextDataStatisticsStore(context), getJobContextInternalAdapterStore(context), getJobContextIndexStore(context), context, getMinimumSplitCount(context), getMaximumSplitCount(context));
    }
    LOGGER.error("Data Store does not support map reduce");
    throw new IOException("Data Store does not support map reduce");
}
Also used : DataStore(org.locationtech.geowave.core.store.api.DataStore) MapReduceDataStore(org.locationtech.geowave.mapreduce.MapReduceDataStore) MapReduceDataStore(org.locationtech.geowave.mapreduce.MapReduceDataStore) IOException(java.io.IOException)

Example 2 with MapReduceDataStore

use of org.locationtech.geowave.mapreduce.MapReduceDataStore in project geowave by locationtech.

the class GeoWaveInputFormat method createRecordReader.

@Override
public RecordReader<GeoWaveInputKey, T> createRecordReader(final InputSplit split, final TaskAttemptContext context) throws IOException, InterruptedException {
    final Map<String, String> configOptions = getStoreOptionsMap(context);
    final DataStore dataStore = GeoWaveStoreFinder.createDataStore(configOptions);
    if ((dataStore != null) && (dataStore instanceof MapReduceDataStore)) {
        return (RecordReader<GeoWaveInputKey, T>) ((MapReduceDataStore) dataStore).createRecordReader(getCommonQueryOptions(context), getDataTypeQueryOptions(context), getIndexQueryOptions(context), getQueryConstraints(context), getJobContextAdapterStore(context), getJobContextInternalAdapterStore(context), getJobContextAdapterIndexMappingStore(context), getJobContextDataStatisticsStore(context), getJobContextIndexStore(context), isOutputWritable(context).booleanValue(), split);
    }
    LOGGER.error("Data Store does not support map reduce");
    throw new IOException("Data Store does not support map reduce");
}
Also used : DataStore(org.locationtech.geowave.core.store.api.DataStore) MapReduceDataStore(org.locationtech.geowave.mapreduce.MapReduceDataStore) MapReduceDataStore(org.locationtech.geowave.mapreduce.MapReduceDataStore) RecordReader(org.apache.hadoop.mapreduce.RecordReader) IOException(java.io.IOException)

Example 3 with MapReduceDataStore

use of org.locationtech.geowave.mapreduce.MapReduceDataStore in project geowave by locationtech.

the class GeoWaveOutputFormat method setStoreOptions.

public static void setStoreOptions(final Configuration config, final DataStorePluginOptions storeOptions) {
    if (storeOptions != null) {
        GeoWaveConfiguratorBase.setStoreOptionsMap(CLASS, config, storeOptions.getOptionsAsMap());
        final DataStore dataStore = storeOptions.createDataStore();
        if ((dataStore != null) && (dataStore instanceof MapReduceDataStore)) {
            ((MapReduceDataStore) dataStore).prepareRecordWriter(config);
        }
    } else {
        GeoWaveConfiguratorBase.setStoreOptionsMap(CLASS, config, null);
    }
}
Also used : DataStore(org.locationtech.geowave.core.store.api.DataStore) MapReduceDataStore(org.locationtech.geowave.mapreduce.MapReduceDataStore) MapReduceDataStore(org.locationtech.geowave.mapreduce.MapReduceDataStore)

Example 4 with MapReduceDataStore

use of org.locationtech.geowave.mapreduce.MapReduceDataStore in project geowave by locationtech.

the class SplitsProviderIT method getSplitsMSE.

private double getSplitsMSE(final QueryConstraints query, final int minSplits, final int maxSplits) {
    // get splits and create reader for each RangeLocationPair, then summing
    // up the rows for each split
    List<InputSplit> splits = null;
    final MapReduceDataStore dataStore = (MapReduceDataStore) dataStorePluginOptions.createDataStore();
    final PersistentAdapterStore as = dataStorePluginOptions.createAdapterStore();
    final InternalAdapterStore ias = dataStorePluginOptions.createInternalAdapterStore();
    final MapReduceDataStoreOperations ops = (MapReduceDataStoreOperations) dataStorePluginOptions.createDataStoreOperations();
    final IndexStore is = dataStorePluginOptions.createIndexStore();
    final AdapterIndexMappingStore aim = dataStorePluginOptions.createAdapterIndexMappingStore();
    final DataStatisticsStore stats = dataStorePluginOptions.createDataStatisticsStore();
    final MemoryAdapterStore mas = new MemoryAdapterStore();
    mas.addAdapter(fda);
    try {
        splits = dataStore.getSplits(new CommonQueryOptions(), new FilterByTypeQueryOptions<>(new String[] { fda.getTypeName() }), new QuerySingleIndex(idx.getName()), new EverythingQuery(), mas, aim, stats, ias, is, new JobContextImpl(new Configuration(), new JobID()), minSplits, maxSplits);
    } catch (final IOException e) {
        LOGGER.error("IOException thrown when calling getSplits", e);
    } catch (final InterruptedException e) {
        LOGGER.error("InterruptedException thrown when calling getSplits", e);
    }
    final double[] observed = new double[splits.size()];
    int totalCount = 0;
    int currentSplit = 0;
    for (final InputSplit split : splits) {
        int countPerSplit = 0;
        if (GeoWaveInputSplit.class.isAssignableFrom(split.getClass())) {
            final GeoWaveInputSplit gwSplit = (GeoWaveInputSplit) split;
            for (final String indexName : gwSplit.getIndexNames()) {
                final SplitInfo splitInfo = gwSplit.getInfo(indexName);
                for (final RangeLocationPair p : splitInfo.getRangeLocationPairs()) {
                    final RecordReaderParams readerParams = new RecordReaderParams(splitInfo.getIndex(), as, aim, ias, new short[] { ias.getAdapterId(fda.getTypeName()) }, null, null, null, splitInfo.isMixedVisibility(), splitInfo.isAuthorizationsLimiting(), splitInfo.isClientsideRowMerging(), p.getRange(), null, null);
                    try (RowReader<?> reader = ops.createReader(readerParams)) {
                        while (reader.hasNext()) {
                            reader.next();
                            countPerSplit++;
                        }
                    } catch (final Exception e) {
                        LOGGER.error("Exception thrown when calling createReader", e);
                    }
                }
            }
        }
        totalCount += countPerSplit;
        observed[currentSplit] = countPerSplit;
        currentSplit++;
    }
    final double expected = 1.0 / splits.size();
    double sum = 0;
    for (int i = 0; i < observed.length; i++) {
        sum += Math.pow((observed[i] / totalCount) - expected, 2);
    }
    return sum / splits.size();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) CommonQueryOptions(org.locationtech.geowave.core.store.query.options.CommonQueryOptions) DataStatisticsStore(org.locationtech.geowave.core.store.statistics.DataStatisticsStore) QuerySingleIndex(org.locationtech.geowave.core.store.query.options.QuerySingleIndex) InputSplit(org.apache.hadoop.mapreduce.InputSplit) MapReduceDataStoreOperations(org.locationtech.geowave.mapreduce.MapReduceDataStoreOperations) JobContextImpl(org.apache.hadoop.mapreduce.task.JobContextImpl) InternalAdapterStore(org.locationtech.geowave.core.store.adapter.InternalAdapterStore) EverythingQuery(org.locationtech.geowave.core.store.query.constraints.EverythingQuery) MemoryAdapterStore(org.locationtech.geowave.core.store.memory.MemoryAdapterStore) IOException(java.io.IOException) AdapterIndexMappingStore(org.locationtech.geowave.core.store.adapter.AdapterIndexMappingStore) IOException(java.io.IOException) PersistentAdapterStore(org.locationtech.geowave.core.store.adapter.PersistentAdapterStore) MapReduceDataStore(org.locationtech.geowave.mapreduce.MapReduceDataStore) FilterByTypeQueryOptions(org.locationtech.geowave.core.store.query.options.FilterByTypeQueryOptions) IndexStore(org.locationtech.geowave.core.store.index.IndexStore) JobID(org.apache.hadoop.mapreduce.JobID)

Aggregations

MapReduceDataStore (org.locationtech.geowave.mapreduce.MapReduceDataStore)4 IOException (java.io.IOException)3 DataStore (org.locationtech.geowave.core.store.api.DataStore)3 Configuration (org.apache.hadoop.conf.Configuration)1 InputSplit (org.apache.hadoop.mapreduce.InputSplit)1 JobID (org.apache.hadoop.mapreduce.JobID)1 RecordReader (org.apache.hadoop.mapreduce.RecordReader)1 JobContextImpl (org.apache.hadoop.mapreduce.task.JobContextImpl)1 AdapterIndexMappingStore (org.locationtech.geowave.core.store.adapter.AdapterIndexMappingStore)1 InternalAdapterStore (org.locationtech.geowave.core.store.adapter.InternalAdapterStore)1 PersistentAdapterStore (org.locationtech.geowave.core.store.adapter.PersistentAdapterStore)1 IndexStore (org.locationtech.geowave.core.store.index.IndexStore)1 MemoryAdapterStore (org.locationtech.geowave.core.store.memory.MemoryAdapterStore)1 EverythingQuery (org.locationtech.geowave.core.store.query.constraints.EverythingQuery)1 CommonQueryOptions (org.locationtech.geowave.core.store.query.options.CommonQueryOptions)1 FilterByTypeQueryOptions (org.locationtech.geowave.core.store.query.options.FilterByTypeQueryOptions)1 QuerySingleIndex (org.locationtech.geowave.core.store.query.options.QuerySingleIndex)1 DataStatisticsStore (org.locationtech.geowave.core.store.statistics.DataStatisticsStore)1 MapReduceDataStoreOperations (org.locationtech.geowave.mapreduce.MapReduceDataStoreOperations)1