AbstractCoreKeyIteratorSettingsFactory implements IteratorSettingFactory { @Override public IteratorSetting getElementPostAggregationFilterIteratorSetting(final View view, final AccumuloStore store) throws IteratorSettingException { if (!view.hasPostAggregationFilters()) { LOGGER.debug("Returning null from getElementPostAggregationFilterIteratorSetting as view.hasPostAggregationFilters = {}", view.hasPostAggregationFilters()); return null; } final IteratorSetting is = new IteratorSettingBuilder(AccumuloStoreConstants.ELEMENT_POST_AGGREGATION_FILTER_ITERATOR_PRIORITY, AccumuloStoreConstants.ELEMENT_POST_AGGREGATION_FILTER_ITERATOR_NAME, ElementPostAggregationFilter.class) .schema(store.getSchema()) .view(view) .keyConverter(store.getKeyPackage().getKeyConverter()) .build(); LOGGER.debug("Creating IteratorSetting for iterator class {} with priority = {}, " + "schema = {}, view = {}, keyConverter = {}", ElementPostAggregationFilter.class.getName(), AccumuloStoreConstants.ELEMENT_POST_AGGREGATION_FILTER_ITERATOR_PRIORITY, store.getSchema(), view, store.getKeyPackage().getKeyConverter()); return is; }  @Override IteratorSetting getBloomFilterIteratorSetting(final BloomFilter filter); @Override IteratorSetting getElementPreAggregationFilterIteratorSetting(final View view, final AccumuloStore store); @Override IteratorSetting getElementPostAggregationFilterIteratorSetting(final View view, final AccumuloStore store); @Override IteratorSetting getAggregatorIteratorSetting(final AccumuloStore store); @Override IteratorSetting getRowIDAggregatorIteratorSetting(final AccumuloStore store, final String columnFamily); @Override IteratorSetting getValidatorIteratorSetting(final AccumuloStore store); @Override IteratorSetting getQueryTimeAggregatorIteratorSetting(final View view, final AccumuloStore store); boolean queryTimeAggregatorRequired(final View view, final AccumuloStore store); @Override IteratorSetting getIteratorSetting(final AccumuloStore store, final String iteratorName);  }
@Test public void shouldReturnNullPostAggFilterIfNoPreAggFilters() throws Exception { final AccumuloStore store = mock(AccumuloStore.class); final Schema schema = createSchema(); final View view = new View.Builder() .edge(TestGroups.EDGE, new ViewElementDefinition.Builder() .preAggregationFilter(new ElementFilter.Builder() .select(TestPropertyNames.PROP_1) .execute(new Exists()) .build()) .build()) .build(); given(store.getSchema()).willReturn(schema); final IteratorSetting iterator = factory.getElementPostAggregationFilterIteratorSetting(view, store); assertNull(iterator); }
@Test public void shouldReturnPostAggFilterIterator() throws Exception { final AccumuloStore store = mock(AccumuloStore.class); final Schema schema = createSchema(); final View view = new View.Builder() .edge(TestGroups.EDGE, new ViewElementDefinition.Builder() .postAggregationFilter(new ElementFilter.Builder() .select(TestPropertyNames.PROP_1) .execute(new Exists()) .build()) .build()) .build(); final AccumuloKeyPackage keyPackage = mock(AccumuloKeyPackage.class); final AccumuloElementConverter converter = mock(AccumuloElementConverter.class); given(store.getSchema()).willReturn(schema); given(store.getKeyPackage()).willReturn(keyPackage); given(keyPackage.getKeyConverter()).willReturn(converter); final IteratorSetting iterator = factory.getElementPostAggregationFilterIteratorSetting(view, store); assertEquals(AccumuloStoreConstants.ELEMENT_POST_AGGREGATION_FILTER_ITERATOR_NAME, iterator.getName()); assertEquals(AccumuloStoreConstants.ELEMENT_POST_AGGREGATION_FILTER_ITERATOR_PRIORITY, iterator.getPriority()); assertEquals(ElementPostAggregationFilter.class.getName(), iterator.getIteratorClass()); JsonAssert.assertEquals(schema.toCompactJson(), iterator.getOptions().get(AccumuloStoreConstants.SCHEMA).getBytes()); JsonAssert.assertEquals(view.toCompactJson(), iterator.getOptions().get(AccumuloStoreConstants.VIEW).getBytes()); assertEquals(converter.getClass().getName(), iterator.getOptions().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS)); }