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));
}
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!");
}
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.");
}
}
Aggregations