Search in sources :

Example 1 with CommonIndexedPersistenceEncoding

use of org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding in project geowave by locationtech.

the class WholeRowAggregationIterator method filter.

@Override
protected boolean filter(final Text currentRow, final List<Key> keys, final List<Value> values) {
    if ((aggregationIterator != null) && (aggregationIterator.queryFilterIterator != null)) {
        final PersistentDataset<Object> commonData = new MultiFieldPersistentDataset<>();
        final List<FlattenedUnreadData> unreadData = new ArrayList<>();
        for (int i = 0; (i < keys.size()) && (i < values.size()); i++) {
            final Key key = keys.get(i);
            final Value value = values.get(i);
            final FlattenedUnreadData singleRow = aggregationIterator.queryFilterIterator.aggregateFieldData(key, value, commonData);
            if (singleRow != null) {
                unreadData.add(singleRow);
            }
        }
        final CommonIndexedPersistenceEncoding encoding = QueryFilterIterator.getEncoding(currentRow, queryFilterIterator.partitionKeyLength, commonData, unreadData.isEmpty() ? null : new UnreadFieldDataList(unreadData));
        boolean queryFilterResult = true;
        if (aggregationIterator.queryFilterIterator.isSet()) {
            queryFilterResult = aggregationIterator.queryFilterIterator.applyRowFilter(encoding);
        }
        if (queryFilterResult) {
            aggregationIterator.aggregateRow(currentRow, queryFilterIterator.model, encoding);
        }
    }
    // we don't want to return anything but the aggregation result
    return false;
}
Also used : MultiFieldPersistentDataset(org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset) CommonIndexedPersistenceEncoding(org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding) FlattenedUnreadData(org.locationtech.geowave.core.store.flatten.FlattenedUnreadData) UnreadFieldDataList(org.locationtech.geowave.core.store.data.UnreadFieldDataList) ArrayList(java.util.ArrayList) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key)

Example 2 with CommonIndexedPersistenceEncoding

use of org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding in project geowave by locationtech.

the class BinningAggregationTest method testMerge.

@Test
public void testMerge() {
    final BinningAggregation<Persistable, Long, CommonIndexedPersistenceEncoding> agg = new BinningAggregation<>(new CountAggregation(), randomBinStrategy, -1);
    final Map<ByteArray, Long> res1 = ImmutableMap.of(new ByteArray("0"), 3L, new ByteArray("1"), 2L);
    final Map<ByteArray, Long> res2 = ImmutableMap.of(new ByteArray("0"), 2L, new ByteArray("1"), 3L);
    // relies on CountAggregation#merge, which adds the values.
    final Map<ByteArray, Long> merged = agg.merge(res1, res2);
    assertEquals(5L, merged.get(new ByteArray("0")).longValue());
    assertEquals(5L, merged.get(new ByteArray("1")).longValue());
}
Also used : Persistable(org.locationtech.geowave.core.index.persist.Persistable) CommonIndexedPersistenceEncoding(org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding) ByteArray(org.locationtech.geowave.core.index.ByteArray) Test(org.junit.Test)

Example 3 with CommonIndexedPersistenceEncoding

use of org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding in project geowave by locationtech.

the class BinningAggregationTest method testFullSerialization.

@Test
public void testFullSerialization() {
    final BinningAggregation<Persistable, Long, CommonIndexedPersistenceEncoding> agg = new BinningAggregation<>(new CountAggregation(), randomBinStrategy, -1);
    final byte[] serialized = PersistenceUtils.toBinary(agg);
    final BinningAggregationOptions<Persistable, CommonIndexedPersistenceEncoding> params = agg.getParameters();
    final BinningAggregation<Persistable, Long, CommonIndexedPersistenceEncoding> roundtrip = (BinningAggregation<Persistable, Long, CommonIndexedPersistenceEncoding>) PersistenceUtils.fromBinary(serialized);
    roundtrip.setParameters(params);
    // ensure that roundtrip can still properly instantiate the objects that it needs to on the fly.
    final Map<ByteArray, Long> res1 = ImmutableMap.of(new ByteArray("0"), 3L, new ByteArray("1"), 2L);
    final Map<ByteArray, Long> res2 = ImmutableMap.of(new ByteArray("0"), 2L, new ByteArray("1"), 3L);
    final Map<ByteArray, Long> merged = roundtrip.merge(res1, res2);
    assertEquals(5L, merged.get(new ByteArray("0")).longValue());
    assertEquals(5L, merged.get(new ByteArray("1")).longValue());
    roundtrip.aggregate(null, null);
    roundtrip.aggregate(null, null);
    roundtrip.aggregate(null, null);
    assertEquals(3, roundtrip.getResult().size());
}
Also used : Persistable(org.locationtech.geowave.core.index.persist.Persistable) CommonIndexedPersistenceEncoding(org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding) ByteArray(org.locationtech.geowave.core.index.ByteArray) Test(org.junit.Test)

Example 4 with CommonIndexedPersistenceEncoding

use of org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding in project geowave by locationtech.

the class BasicQueryByClassTest method testDisjointCasesWithPersistence.

@Test
public void testDisjointCasesWithPersistence() {
    final List<MultiDimensionalNumericData> expectedResults = new ArrayList<>();
    expectedResults.add(new BasicNumericDataset(new NumericData[] { new ConstrainedIndexValue(0.3, 0.7), new ConstrainedIndexValue(0.1, 2.3) }));
    expectedResults.add(new BasicNumericDataset(new NumericData[] { new ConstrainedIndexValue(0.3, 0.7), new ConstrainedIndexValue(3.4, 3.7) }));
    final ConstraintSet cs1 = new ConstraintSet();
    cs1.addConstraint(ExampleDimensionOne.class, new ConstraintData(new ConstrainedIndexValue(0.3, 0.5), true));
    cs1.addConstraint(ExampleDimensionOne.class, new ConstraintData(new ConstrainedIndexValue(0.4, 0.7), true));
    final ConstraintSet cs2a = new ConstraintSet();
    cs2a.addConstraint(ExampleDimensionTwo.class, new ConstraintData(new ConstrainedIndexValue(0.1, 0.2), true));
    cs2a.addConstraint(ExampleDimensionTwo.class, new ConstraintData(new ConstrainedIndexValue(2.1, 2.3), true));
    final ConstraintSet cs2b = new ConstraintSet();
    cs2b.addConstraint(ExampleDimensionTwo.class, new ConstraintData(new ConstrainedIndexValue(3.4, 3.7), true));
    final ConstraintsByClass constraints = new ConstraintsByClass(Arrays.asList(cs2a, cs2b)).merge(Collections.singletonList(cs1));
    assertEquals(expectedResults, constraints.getIndexConstraints(new IndexImpl(new ExampleNumericIndexStrategy(), null)));
    final byte[] image = new BasicQueryByClass(constraints).toBinary();
    final BasicQueryByClass query = new BasicQueryByClass();
    query.fromBinary(image);
    final Index index = new CustomNameIndex(new ExampleNumericIndexStrategy(), new BasicIndexModel(new NumericDimensionField[] { new ExampleDimensionOne(), new ExampleDimensionTwo() }), "22");
    assertEquals(expectedResults, query.getIndexConstraints(index));
    final List<QueryFilter> filters = query.createFilters(index);
    assertEquals(1, filters.size());
    final Map<String, ConstrainedIndexValue> fieldIdToValueMap = new HashMap<>();
    fieldIdToValueMap.put("one", new ConstrainedIndexValue(0.4, 0.4));
    fieldIdToValueMap.put("two", new ConstrainedIndexValue(0.5, 0.5));
    final CommonIndexModel model = null;
    assertTrue(filters.get(0).accept(model, new CommonIndexedPersistenceEncoding((short) 1, StringUtils.stringToBinary("data"), StringUtils.stringToBinary("partition"), StringUtils.stringToBinary("sort"), // duplicate count
    1, new MultiFieldPersistentDataset(fieldIdToValueMap), null)));
    fieldIdToValueMap.put("one", new ConstrainedIndexValue(0.1, 0.1));
    assertFalse(filters.get(0).accept(model, new CommonIndexedPersistenceEncoding((short) 1, StringUtils.stringToBinary("data"), StringUtils.stringToBinary("partition"), StringUtils.stringToBinary("sort"), // duplicate count
    1, new MultiFieldPersistentDataset(fieldIdToValueMap), null)));
    fieldIdToValueMap.put("one", new ConstrainedIndexValue(0.4, 0.4));
    fieldIdToValueMap.put("two", new ConstrainedIndexValue(5.0, 5.0));
    assertFalse(filters.get(0).accept(model, new CommonIndexedPersistenceEncoding((short) 1, StringUtils.stringToBinary("data"), StringUtils.stringToBinary("partition"), StringUtils.stringToBinary("sort"), // duplicate count
    1, new MultiFieldPersistentDataset(fieldIdToValueMap), null)));
    /**
     * Tests the 'OR' Case
     */
    fieldIdToValueMap.put("two", new ConstrainedIndexValue(3.5, 3.5));
    assertTrue(filters.get(0).accept(model, new CommonIndexedPersistenceEncoding((short) 1, StringUtils.stringToBinary("data"), StringUtils.stringToBinary("partition"), StringUtils.stringToBinary("sort"), // duplicate count
    1, new MultiFieldPersistentDataset(fieldIdToValueMap), null)));
}
Also used : NumericDimensionField(org.locationtech.geowave.core.store.dimension.NumericDimensionField) BasicNumericDataset(org.locationtech.geowave.core.index.numeric.BasicNumericDataset) HashMap(java.util.HashMap) CommonIndexedPersistenceEncoding(org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding) ArrayList(java.util.ArrayList) NumericData(org.locationtech.geowave.core.index.numeric.NumericData) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) CustomNameIndex(org.locationtech.geowave.core.store.index.CustomNameIndex) Index(org.locationtech.geowave.core.store.api.Index) CommonIndexModel(org.locationtech.geowave.core.store.index.CommonIndexModel) ConstraintsByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass) ConstraintData(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintData) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) ConstraintSet(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet) CustomNameIndex(org.locationtech.geowave.core.store.index.CustomNameIndex) QueryFilter(org.locationtech.geowave.core.store.query.filter.QueryFilter) MultiFieldPersistentDataset(org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset) IndexImpl(org.locationtech.geowave.core.store.index.IndexImpl) BasicIndexModel(org.locationtech.geowave.core.store.index.BasicIndexModel) BasicQueryByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass) Test(org.junit.Test)

Example 5 with CommonIndexedPersistenceEncoding

use of org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding in project geowave by locationtech.

the class AbstractCommonIndexAggregationTest method generateObjects.

public static List<CommonIndexedPersistenceEncoding> generateObjects(final int count) {
    final List<CommonIndexedPersistenceEncoding> objects = Lists.newArrayListWithCapacity(count);
    for (int i = 0; i < count; i++) {
        final String dataId = "entry" + i;
        final PersistentDataset<Object> commonData = new MultiFieldPersistentDataset<>();
        commonData.addValue("value", new MockComponents.TestIndexFieldType(i));
        objects.add(new CommonIndexedPersistenceEncoding((short) 0, dataId.getBytes(), new byte[0], new byte[0], 0, commonData, new SingleFieldPersistentDataset<byte[]>()));
    }
    return objects;
}
Also used : MultiFieldPersistentDataset(org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset) CommonIndexedPersistenceEncoding(org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding) MockComponents(org.locationtech.geowave.core.store.adapter.MockComponents) SingleFieldPersistentDataset(org.locationtech.geowave.core.store.data.SingleFieldPersistentDataset)

Aggregations

CommonIndexedPersistenceEncoding (org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding)11 Test (org.junit.Test)5 MultiFieldPersistentDataset (org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset)5 ByteArray (org.locationtech.geowave.core.index.ByteArray)4 Index (org.locationtech.geowave.core.store.api.Index)3 QueryFilter (org.locationtech.geowave.core.store.query.filter.QueryFilter)3 Coordinate (org.locationtech.jts.geom.Coordinate)3 ArrayList (java.util.ArrayList)2 SpatialTemporalOptions (org.locationtech.geowave.core.geotime.index.SpatialTemporalOptions)2 Persistable (org.locationtech.geowave.core.index.persist.Persistable)2 FlattenedUnreadData (org.locationtech.geowave.core.store.flatten.FlattenedUnreadData)2 BasicQueryByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass)2 ConstraintData (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintData)2 ConstraintSet (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet)2 ConstraintsByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass)2 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)2 HashMap (java.util.HashMap)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 TimeDefinition (org.locationtech.geowave.core.geotime.index.dimension.TimeDefinition)1