Search in sources :

Example 1 with DataStoreProperty

use of org.locationtech.geowave.core.store.DataStoreProperty in project geowave by locationtech.

the class GeoWaveVisibilityIT method testIngestAndQueryVisibilityFields.

public static void testIngestAndQueryVisibilityFields(final DataStorePluginOptions dataStoreOptions, final VisibilityHandler visibilityHandler, final Consumer<DifferingVisibilityCountValue> verifyDifferingVisibilities, final BiConsumer<Pair<DataStore, DataStatisticsStore>, Pair<Short, Boolean>> verifyQuery, final int totalFeatures) {
    // Specify visibility at the global level
    dataStoreOptions.createPropertyStore().setProperty(new DataStoreProperty(BaseDataStoreUtils.GLOBAL_VISIBILITY_PROPERTY, visibilityHandler));
    final SimpleFeatureBuilder bldr = new SimpleFeatureBuilder(getType());
    final FeatureDataAdapter adapter = new FeatureDataAdapter(getType());
    final DataStore store = dataStoreOptions.createDataStore();
    store.addType(adapter, TestUtils.DEFAULT_SPATIAL_INDEX);
    try (Writer<SimpleFeature> writer = store.createWriter(adapter.getTypeName())) {
        for (int i = 0; i < totalFeatures; i++) {
            bldr.set("a", Integer.toString(i));
            bldr.set("b", Integer.toString(i));
            bldr.set("c", Integer.toString(i));
            bldr.set("geometry", new GeometryFactory().createPoint(new Coordinate(0, 0)));
            writer.write(bldr.buildFeature(Integer.toString(i)), visibilityHandler);
        }
    }
    final DataStore dataStore = dataStoreOptions.createDataStore();
    final DataStatisticsStore statsStore = dataStoreOptions.createDataStatisticsStore();
    final InternalAdapterStore internalDataStore = dataStoreOptions.createInternalAdapterStore();
    final short internalAdapterId = internalDataStore.getAdapterId(adapter.getTypeName());
    final DifferingVisibilityCountValue count = dataStore.aggregateStatistics(StatisticQueryBuilder.newBuilder(DifferingVisibilityCountStatistic.STATS_TYPE).indexName(TestUtils.DEFAULT_SPATIAL_INDEX.getName()).binConstraints(BinConstraints.of(DataTypeBinningStrategy.getBin(adapter))).build());
    verifyDifferingVisibilities.accept(count);
    verifyQuery.accept(Pair.of(store, statsStore), Pair.of(internalAdapterId, false));
    verifyQuery.accept(Pair.of(store, statsStore), Pair.of(internalAdapterId, true));
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) InternalAdapterStore(org.locationtech.geowave.core.store.adapter.InternalAdapterStore) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Point(org.locationtech.jts.geom.Point) DataStatisticsStore(org.locationtech.geowave.core.store.statistics.DataStatisticsStore) DataStoreProperty(org.locationtech.geowave.core.store.DataStoreProperty) Coordinate(org.locationtech.jts.geom.Coordinate) DataStore(org.locationtech.geowave.core.store.api.DataStore) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) DifferingVisibilityCountValue(org.locationtech.geowave.core.store.statistics.index.DifferingVisibilityCountStatistic.DifferingVisibilityCountValue) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder)

Example 2 with DataStoreProperty

use of org.locationtech.geowave.core.store.DataStoreProperty in project geowave by locationtech.

the class MigrationCommand method execute.

/**
 * Prep the driver & run the operation.
 */
@Override
public void execute(final OperationParams params) {
    if (parameters.size() != 1) {
        throw new ParameterException("Requires arguments: <store name>");
    }
    final String storeName = parameters.get(0);
    final StoreLoader inputStoreLoader = new StoreLoader(storeName);
    if (!inputStoreLoader.loadFromConfig(getGeoWaveConfigFile(), params.getConsole())) {
        throw new ParameterException("Cannot find store name: " + inputStoreLoader.getStoreName());
    }
    final DataStorePluginOptions storeOptions = inputStoreLoader.getDataStorePlugin();
    final DataStoreOperations operations = storeOptions.createDataStoreOperations();
    final PropertyStore propertyStore = storeOptions.createPropertyStore();
    try {
        if (!operations.metadataExists(MetadataType.ADAPTER) && !operations.metadataExists(MetadataType.INDEX)) {
            throw new ParameterException("There is no data in the data store to migrate.");
        }
    } catch (final IOException e) {
        throw new RuntimeException("Unable to determine if metadata tables exist for data store.", e);
    }
    final DataStoreProperty dataVersionProperty = propertyStore.getProperty(BaseDataStoreUtils.DATA_VERSION_PROPERTY);
    final int dataVersion = dataVersionProperty == null ? 0 : (int) dataVersionProperty.getValue();
    if (dataVersion == BaseDataStoreUtils.DATA_VERSION) {
        throw new ParameterException("The data version matches the CLI version, there are no migrations to apply.");
    }
    if (dataVersion > BaseDataStoreUtils.DATA_VERSION) {
        throw new ParameterException("The data store is using a newer serialization format.  Please update to a newer version " + "of the CLI that is compatible with the data store.");
    }
    // Do migration
    if (dataVersion < 1) {
        migrate0to1(storeOptions, operations, params.getConsole());
    }
    propertyStore.setProperty(new DataStoreProperty(BaseDataStoreUtils.DATA_VERSION_PROPERTY, BaseDataStoreUtils.DATA_VERSION));
    params.getConsole().println("Migration completed successfully!");
}
Also used : DataStoreOperations(org.locationtech.geowave.core.store.operations.DataStoreOperations) DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) DataStoreProperty(org.locationtech.geowave.core.store.DataStoreProperty) ParameterException(com.beust.jcommander.ParameterException) StoreLoader(org.locationtech.geowave.core.store.cli.store.StoreLoader) IOException(java.io.IOException) PropertyStore(org.locationtech.geowave.core.store.PropertyStore)

Example 3 with DataStoreProperty

use of org.locationtech.geowave.core.store.DataStoreProperty in project geowave by locationtech.

the class BaseDataStoreUtils method verifyCLIVersion.

public static void verifyCLIVersion(final String storeName, final DataStorePluginOptions options) {
    final DataStoreOperations operations = options.createDataStoreOperations();
    final PropertyStore propertyStore = options.createPropertyStore();
    final DataStoreProperty storeVersionProperty = propertyStore.getProperty(DATA_VERSION_PROPERTY);
    if ((storeVersionProperty == null) && !hasMetadata(operations, MetadataType.ADAPTER) && !hasMetadata(operations, MetadataType.INDEX)) {
        // Nothing has been loaded into the store yet
        return;
    }
    final int storeVersion = storeVersionProperty == null ? 0 : (int) storeVersionProperty.getValue();
    if (storeVersion < DATA_VERSION) {
        throw new ParameterException("The data store '" + storeName + "' is using an older serialization format.  Either use an older " + "version of the CLI that is compatible with the data store, or migrate the data " + "store to a later version using the `geowave util migrate` command.");
    } else if (storeVersion > DATA_VERSION) {
        throw new ParameterException("The data store '" + storeName + "' is using a newer serialization format.  Please update to a " + "newer version of the CLI that is compatible with the data store.");
    }
}
Also used : DataStoreOperations(org.locationtech.geowave.core.store.operations.DataStoreOperations) DataStoreProperty(org.locationtech.geowave.core.store.DataStoreProperty) ParameterException(com.beust.jcommander.ParameterException) IndexDimensionHint(org.locationtech.geowave.core.index.IndexDimensionHint) PropertyStore(org.locationtech.geowave.core.store.PropertyStore)

Aggregations

DataStoreProperty (org.locationtech.geowave.core.store.DataStoreProperty)3 ParameterException (com.beust.jcommander.ParameterException)2 PropertyStore (org.locationtech.geowave.core.store.PropertyStore)2 DataStoreOperations (org.locationtech.geowave.core.store.operations.DataStoreOperations)2 IOException (java.io.IOException)1 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)1 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)1 IndexDimensionHint (org.locationtech.geowave.core.index.IndexDimensionHint)1 InternalAdapterStore (org.locationtech.geowave.core.store.adapter.InternalAdapterStore)1 DataStore (org.locationtech.geowave.core.store.api.DataStore)1 DataStorePluginOptions (org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions)1 StoreLoader (org.locationtech.geowave.core.store.cli.store.StoreLoader)1 DataStatisticsStore (org.locationtech.geowave.core.store.statistics.DataStatisticsStore)1 DifferingVisibilityCountValue (org.locationtech.geowave.core.store.statistics.index.DifferingVisibilityCountStatistic.DifferingVisibilityCountValue)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)1 Point (org.locationtech.jts.geom.Point)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1