use of org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler in project geowave by locationtech.
the class GeoWaveDataStoreComponents method writeCommit.
public void writeCommit(final SimpleFeature feature, final GeoWaveTransaction transaction) throws IOException {
final VisibilityHandler visibilityHandler = new GlobalVisibilityHandler(transaction.composeVisibility());
dataStore.addType(adapter, adapterIndices);
try (Writer<SimpleFeature> indexWriter = dataStore.createWriter(adapter.getTypeName())) {
indexWriter.write(feature, visibilityHandler);
}
}
use of org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler in project geowave by locationtech.
the class VisibilityOptions method getConfiguredVisibilityHandler.
public VisibilityHandler getConfiguredVisibilityHandler() {
final VisibilityHandler globalVisibilityHandler;
if (visibility != null && visibility.trim().length() > 0) {
globalVisibilityHandler = new GlobalVisibilityHandler(visibility.trim());
} else {
globalVisibilityHandler = null;
}
if (visibilityAttribute != null && visibilityAttribute.trim().length() > 0) {
if (jsonVisibilityAttribute) {
return new JsonFieldLevelVisibilityHandler(visibilityAttribute);
}
return new FieldLevelVisibilityHandler(visibilityAttribute);
}
final VisibilityHandler fieldVisibilityHandler = parseFieldVisibilities();
if (fieldVisibilityHandler == null) {
if (globalVisibilityHandler != null) {
return globalVisibilityHandler;
}
return null;
} else if (globalVisibilityHandler != null) {
return new FallbackVisibilityHandler(new VisibilityHandler[] { fieldVisibilityHandler, globalVisibilityHandler });
}
return fieldVisibilityHandler;
}
use of org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler in project geowave by locationtech.
the class MemoryDataStoreTest method testMultipleIndices.
@Test
public void testMultipleIndices() throws IOException {
final Index index1 = new IndexImpl(new MockComponents.MockIndexStrategy(), new MockComponents.TestIndexModel("tm1"));
final Index index2 = new IndexImpl(new MockComponents.MockIndexStrategy(), new MockComponents.TestIndexModel("tm2"));
final String namespace = "test2_" + getClass().getName();
final StoreFactoryFamilySpi storeFamily = new MemoryStoreFactoryFamily();
final MemoryRequiredOptions opts = new MemoryRequiredOptions();
opts.setGeoWaveNamespace(namespace);
final DataStore dataStore = storeFamily.getDataStoreFactory().createStore(opts);
final DataStatisticsStore statsStore = storeFamily.getDataStatisticsStoreFactory().createStore(opts);
final DataTypeAdapter<Integer> adapter = new MockComponents.MockAbstractDataAdapter();
final VisibilityHandler visHandler = new GlobalVisibilityHandler("aaa&bbb");
final List<Statistic<?>> statistics = Lists.newArrayList();
statistics.add(new NumericRangeStatistic(adapter.getTypeName(), MockAbstractDataAdapter.INTEGER));
dataStore.addType(adapter, statistics, index1, index2);
try (final Writer<Integer> indexWriter = dataStore.createWriter(adapter.getTypeName())) {
indexWriter.write(new Integer(25), visHandler);
indexWriter.flush();
indexWriter.write(new Integer(35), visHandler);
indexWriter.flush();
}
// authorization check
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index2.getName()).addAuthorization("aaa").constraints(new TestQuery(23, 26)).build())) {
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index1.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 26)).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(25), itemIt.next());
assertFalse(itemIt.hasNext());
}
// pick an index
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 36)).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(25), itemIt.next());
assertTrue(itemIt.hasNext());
assertEquals(new Integer(35), itemIt.next());
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<? extends Statistic<? extends StatisticValue<?>>> statsIt = statsStore.getAllStatistics(null)) {
try (CloseableIterator<? extends StatisticValue<?>> statisticValues = statsStore.getStatisticValues(statsIt, null, "aaa", "bbb")) {
assertTrue(checkStats(statisticValues, 2, new NumericRange(25, 35)));
}
}
try (CloseableIterator<? extends Statistic<? extends StatisticValue<?>>> statsIt = statsStore.getAllStatistics(null)) {
try (CloseableIterator<? extends StatisticValue<?>> statisticValues = statsStore.getStatisticValues(statsIt, null)) {
assertTrue(checkStats(statisticValues, 0, null));
}
}
dataStore.delete(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 26)).build());
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index1.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 36)).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(35), itemIt.next());
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index2.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 36)).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(35), itemIt.next());
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index1.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 26)).build())) {
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index2.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 26)).build())) {
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index1.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new DataIdQuery(adapter.getDataId(new Integer(35)))).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(35), itemIt.next());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index2.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new DataIdQuery(adapter.getDataId(new Integer(35)))).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(35), itemIt.next());
}
}
use of org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler in project geowave by locationtech.
the class MemoryDataStoreTest method test.
@Test
public void test() throws IOException {
final Index index = new IndexImpl(new MockComponents.MockIndexStrategy(), new MockComponents.TestIndexModel());
final String namespace = "test_" + getClass().getName();
final StoreFactoryFamilySpi storeFamily = new MemoryStoreFactoryFamily();
final MemoryRequiredOptions reqOptions = new MemoryRequiredOptions();
reqOptions.setGeoWaveNamespace(namespace);
final DataStore dataStore = storeFamily.getDataStoreFactory().createStore(reqOptions);
final DataStatisticsStore statsStore = storeFamily.getDataStatisticsStoreFactory().createStore(reqOptions);
final DataTypeAdapter<Integer> adapter = new MockComponents.MockAbstractDataAdapter();
final VisibilityHandler visHandler = new GlobalVisibilityHandler("aaa&bbb");
final List<Statistic<?>> statistics = Lists.newArrayList();
statistics.add(new CountStatistic(adapter.getTypeName()));
statistics.add(new NumericRangeStatistic(adapter.getTypeName(), MockAbstractDataAdapter.INTEGER));
dataStore.addType(adapter, statistics, index);
try (final Writer<Integer> indexWriter = dataStore.createWriter(adapter.getTypeName())) {
indexWriter.write(new Integer(25), visHandler);
indexWriter.flush();
indexWriter.write(new Integer(35), visHandler);
indexWriter.flush();
}
// authorization check
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index.getName()).addAuthorization("aaa").constraints(new TestQuery(23, 26)).build())) {
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 26)).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(25), itemIt.next());
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 36)).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(25), itemIt.next());
assertTrue(itemIt.hasNext());
assertEquals(new Integer(35), itemIt.next());
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<? extends Statistic<? extends StatisticValue<?>>> statsIt = statsStore.getAllStatistics(null)) {
try (CloseableIterator<? extends StatisticValue<?>> statisticValues = statsStore.getStatisticValues(statsIt, null, "aaa", "bbb")) {
assertTrue(checkStats(statisticValues, 2, new NumericRange(25, 35)));
}
}
try (CloseableIterator<? extends Statistic<? extends StatisticValue<?>>> statsIt = statsStore.getAllStatistics(null)) {
try (CloseableIterator<? extends StatisticValue<?>> statisticValues = statsStore.getStatisticValues(statsIt, null)) {
assertTrue(checkStats(statisticValues, 0, null));
}
}
dataStore.delete(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 26)).build());
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 36)).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(35), itemIt.next());
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new TestQuery(23, 26)).build())) {
assertFalse(itemIt.hasNext());
}
try (CloseableIterator<?> itemIt = dataStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).indexName(index.getName()).addAuthorization("aaa").addAuthorization("bbb").constraints(new DataIdQuery(adapter.getDataId(new Integer(35)))).build())) {
assertTrue(itemIt.hasNext());
assertEquals(new Integer(35), itemIt.next());
}
}
use of org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler in project geowave by locationtech.
the class GeoWaveDataStoreComponents method write.
@SuppressWarnings("unchecked")
public void write(final Iterator<SimpleFeature> featureIt, final Set<String> fidList, final GeoWaveTransaction transaction) throws IOException {
final VisibilityHandler visibilityHandler = new GlobalVisibilityHandler(transaction.composeVisibility());
dataStore.addType(adapter, adapterIndices);
try (Writer<SimpleFeature> indexWriter = dataStore.createWriter(adapter.getTypeName())) {
while (featureIt.hasNext()) {
final SimpleFeature feature = featureIt.next();
fidList.add(feature.getID());
indexWriter.write(feature, visibilityHandler);
}
}
}
Aggregations