Search in sources :

Example 1 with GlobalVisibilityHandler

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);
    }
}
Also used : GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Example 2 with GlobalVisibilityHandler

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;
}
Also used : FieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FieldLevelVisibilityHandler) JsonFieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler) FallbackVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FallbackVisibilityHandler) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) FieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FieldLevelVisibilityHandler) FallbackVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FallbackVisibilityHandler) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) FieldMappedVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FieldMappedVisibilityHandler) JsonFieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler) JsonFieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler)

Example 3 with GlobalVisibilityHandler

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());
    }
}
Also used : NumericRangeStatistic(org.locationtech.geowave.core.store.statistics.field.NumericRangeStatistic) Index(org.locationtech.geowave.core.store.api.Index) DataStatisticsStore(org.locationtech.geowave.core.store.statistics.DataStatisticsStore) NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) MockAbstractDataAdapter(org.locationtech.geowave.core.store.adapter.MockComponents.MockAbstractDataAdapter) Statistic(org.locationtech.geowave.core.store.api.Statistic) CountStatistic(org.locationtech.geowave.core.store.statistics.adapter.CountStatistic) NumericRangeStatistic(org.locationtech.geowave.core.store.statistics.field.NumericRangeStatistic) MockComponents(org.locationtech.geowave.core.store.adapter.MockComponents) DataStore(org.locationtech.geowave.core.store.api.DataStore) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) DataIdQuery(org.locationtech.geowave.core.store.query.constraints.DataIdQuery) StoreFactoryFamilySpi(org.locationtech.geowave.core.store.StoreFactoryFamilySpi) IndexImpl(org.locationtech.geowave.core.store.index.IndexImpl) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) Test(org.junit.Test)

Example 4 with GlobalVisibilityHandler

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());
    }
}
Also used : NumericRangeStatistic(org.locationtech.geowave.core.store.statistics.field.NumericRangeStatistic) Index(org.locationtech.geowave.core.store.api.Index) DataStatisticsStore(org.locationtech.geowave.core.store.statistics.DataStatisticsStore) NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) MockAbstractDataAdapter(org.locationtech.geowave.core.store.adapter.MockComponents.MockAbstractDataAdapter) Statistic(org.locationtech.geowave.core.store.api.Statistic) CountStatistic(org.locationtech.geowave.core.store.statistics.adapter.CountStatistic) NumericRangeStatistic(org.locationtech.geowave.core.store.statistics.field.NumericRangeStatistic) MockComponents(org.locationtech.geowave.core.store.adapter.MockComponents) DataStore(org.locationtech.geowave.core.store.api.DataStore) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) DataIdQuery(org.locationtech.geowave.core.store.query.constraints.DataIdQuery) CountStatistic(org.locationtech.geowave.core.store.statistics.adapter.CountStatistic) StoreFactoryFamilySpi(org.locationtech.geowave.core.store.StoreFactoryFamilySpi) IndexImpl(org.locationtech.geowave.core.store.index.IndexImpl) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) Test(org.junit.Test)

Example 5 with GlobalVisibilityHandler

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);
        }
    }
}
Also used : GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Aggregations

VisibilityHandler (org.locationtech.geowave.core.store.api.VisibilityHandler)5 GlobalVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler)5 Test (org.junit.Test)2 NumericRange (org.locationtech.geowave.core.index.numeric.NumericRange)2 StoreFactoryFamilySpi (org.locationtech.geowave.core.store.StoreFactoryFamilySpi)2 MockComponents (org.locationtech.geowave.core.store.adapter.MockComponents)2 MockAbstractDataAdapter (org.locationtech.geowave.core.store.adapter.MockComponents.MockAbstractDataAdapter)2 DataStore (org.locationtech.geowave.core.store.api.DataStore)2 Index (org.locationtech.geowave.core.store.api.Index)2 Statistic (org.locationtech.geowave.core.store.api.Statistic)2 IndexImpl (org.locationtech.geowave.core.store.index.IndexImpl)2 DataIdQuery (org.locationtech.geowave.core.store.query.constraints.DataIdQuery)2 DataStatisticsStore (org.locationtech.geowave.core.store.statistics.DataStatisticsStore)2 CountStatistic (org.locationtech.geowave.core.store.statistics.adapter.CountStatistic)2 NumericRangeStatistic (org.locationtech.geowave.core.store.statistics.field.NumericRangeStatistic)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 FallbackVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.FallbackVisibilityHandler)1 FieldLevelVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.FieldLevelVisibilityHandler)1 FieldMappedVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.FieldMappedVisibilityHandler)1 JsonFieldLevelVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler)1