Search in sources :

Example 1 with PreAggregationFilterProcessor

use of uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor in project Gaffer by gchq.

the class QueryScannerTest method shouldConstructProcessorsWithNoExtras.

@Test
public void shouldConstructProcessorsWithNoExtras() throws OperationException, IOException {
    // Given
    final Scan scan = mock(Scan.class);
    given(scan.getAttribute(HBaseStoreConstants.VIEW)).willReturn(VIEW.toCompactJson());
    given(scan.getAttribute(HBaseStoreConstants.EXTRA_PROCESSORS)).willReturn(null);
    // When
    final List<GafferScannerProcessor> processors = QueryScanner.createProcessors(scan, SCHEMA, serialisation);
    // Then
    assertThat(processors).hasSize(6);
    int i = 0;
    assertTrue(processors.get(i) instanceof GroupFilterProcessor);
    assertEquals(VIEW, ((GroupFilterProcessor) processors.get(i)).getView());
    i++;
    assertTrue(processors.get(i) instanceof StoreAggregationProcessor);
    assertEquals(SCHEMA, ((StoreAggregationProcessor) processors.get(i)).getSchema());
    i++;
    assertTrue(processors.get(i) instanceof ValidationProcessor);
    assertEquals(SCHEMA, ((ValidationProcessor) processors.get(i)).getSchema());
    i++;
    assertTrue(processors.get(i) instanceof PreAggregationFilterProcessor);
    assertEquals(VIEW, ((PreAggregationFilterProcessor) processors.get(i)).getView());
    i++;
    assertTrue(processors.get(i) instanceof QueryAggregationProcessor);
    assertEquals(SCHEMA, ((QueryAggregationProcessor) processors.get(i)).getSchema());
    assertEquals(VIEW, ((QueryAggregationProcessor) processors.get(i)).getView());
    i++;
    assertTrue(processors.get(i) instanceof PostAggregationFilterProcessor);
    assertEquals(VIEW, ((PostAggregationFilterProcessor) processors.get(i)).getView());
}
Also used : StoreAggregationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.StoreAggregationProcessor) PostAggregationFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PostAggregationFilterProcessor) GafferScannerProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GafferScannerProcessor) GroupFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GroupFilterProcessor) Scan(org.apache.hadoop.hbase.client.Scan) ValidationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ValidationProcessor) PreAggregationFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor) QueryAggregationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.QueryAggregationProcessor) Test(org.junit.jupiter.api.Test)

Example 2 with PreAggregationFilterProcessor

use of uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor in project Gaffer by gchq.

the class QueryScannerTest method shouldConstructProcessors.

@Test
public void shouldConstructProcessors() throws OperationException, IOException {
    // Given
    final Scan scan = mock(Scan.class);
    given(scan.getAttribute(HBaseStoreConstants.VIEW)).willReturn(VIEW.toCompactJson());
    given(scan.getAttribute(HBaseStoreConstants.EXTRA_PROCESSORS)).willReturn(StringUtil.toCsv(ElementDedupeFilterProcessor.class));
    given(scan.getAttribute(HBaseStoreConstants.DIRECTED_TYPE)).willReturn(Bytes.toBytes(DirectedType.DIRECTED.name()));
    // When
    final List<GafferScannerProcessor> processors = QueryScanner.createProcessors(scan, SCHEMA, serialisation);
    // Then
    assertThat(processors).hasSize(7);
    int i = 0;
    assertTrue(processors.get(i) instanceof GroupFilterProcessor);
    assertEquals(VIEW, ((GroupFilterProcessor) processors.get(i)).getView());
    i++;
    assertTrue(processors.get(i) instanceof ElementDedupeFilterProcessor);
    assertTrue(((ElementDedupeFilterProcessor) processors.get(i)).isEntities());
    assertTrue(((ElementDedupeFilterProcessor) processors.get(i)).isEdges());
    assertTrue(((ElementDedupeFilterProcessor) processors.get(i)).isDirectedEdges());
    assertFalse(((ElementDedupeFilterProcessor) processors.get(i)).isUnDirectedEdges());
    i++;
    assertTrue(processors.get(i) instanceof StoreAggregationProcessor);
    assertEquals(SCHEMA, ((StoreAggregationProcessor) processors.get(i)).getSchema());
    i++;
    assertTrue(processors.get(i) instanceof ValidationProcessor);
    assertEquals(SCHEMA, ((ValidationProcessor) processors.get(i)).getSchema());
    i++;
    assertTrue(processors.get(i) instanceof PreAggregationFilterProcessor);
    assertEquals(VIEW, ((PreAggregationFilterProcessor) processors.get(i)).getView());
    i++;
    assertTrue(processors.get(i) instanceof QueryAggregationProcessor);
    assertEquals(SCHEMA, ((QueryAggregationProcessor) processors.get(i)).getSchema());
    assertEquals(VIEW, ((QueryAggregationProcessor) processors.get(i)).getView());
    i++;
    assertTrue(processors.get(i) instanceof PostAggregationFilterProcessor);
    assertEquals(VIEW, ((PostAggregationFilterProcessor) processors.get(i)).getView());
}
Also used : StoreAggregationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.StoreAggregationProcessor) PostAggregationFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PostAggregationFilterProcessor) GafferScannerProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GafferScannerProcessor) GroupFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GroupFilterProcessor) ElementDedupeFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ElementDedupeFilterProcessor) Scan(org.apache.hadoop.hbase.client.Scan) ValidationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ValidationProcessor) PreAggregationFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor) QueryAggregationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.QueryAggregationProcessor) Test(org.junit.jupiter.api.Test)

Example 3 with PreAggregationFilterProcessor

use of uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor in project Gaffer by gchq.

the class QueryScannerTest method shouldConstructProcessorsWithNoAggregation.

@Test
public void shouldConstructProcessorsWithNoAggregation() throws OperationException, IOException {
    // Given
    final Scan scan = mock(Scan.class);
    given(scan.getAttribute(HBaseStoreConstants.VIEW)).willReturn(VIEW.toCompactJson());
    given(scan.getAttribute(HBaseStoreConstants.EXTRA_PROCESSORS)).willReturn(StringUtil.toCsv(ElementDedupeFilterProcessor.class));
    // When
    final List<GafferScannerProcessor> processors = QueryScanner.createProcessors(scan, SCHEMA_NO_AGGREGATION, serialisation);
    // Then
    assertThat(processors).hasSize(5);
    int i = 0;
    assertTrue(processors.get(i) instanceof GroupFilterProcessor);
    assertEquals(VIEW, ((GroupFilterProcessor) processors.get(i)).getView());
    i++;
    assertTrue(processors.get(i) instanceof ElementDedupeFilterProcessor);
    assertTrue(((ElementDedupeFilterProcessor) processors.get(i)).isEntities());
    assertTrue(((ElementDedupeFilterProcessor) processors.get(i)).isEdges());
    assertFalse(((ElementDedupeFilterProcessor) processors.get(i)).isDirectedEdges());
    assertFalse(((ElementDedupeFilterProcessor) processors.get(i)).isUnDirectedEdges());
    i++;
    assertTrue(processors.get(i) instanceof ValidationProcessor);
    assertEquals(SCHEMA_NO_AGGREGATION, ((ValidationProcessor) processors.get(i)).getSchema());
    i++;
    assertTrue(processors.get(i) instanceof PreAggregationFilterProcessor);
    assertEquals(VIEW, ((PreAggregationFilterProcessor) processors.get(i)).getView());
    i++;
    assertTrue(processors.get(i) instanceof PostAggregationFilterProcessor);
    assertEquals(VIEW, ((PostAggregationFilterProcessor) processors.get(i)).getView());
}
Also used : PostAggregationFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PostAggregationFilterProcessor) GafferScannerProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GafferScannerProcessor) GroupFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GroupFilterProcessor) ElementDedupeFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ElementDedupeFilterProcessor) Scan(org.apache.hadoop.hbase.client.Scan) ValidationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ValidationProcessor) PreAggregationFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor) Test(org.junit.jupiter.api.Test)

Example 4 with PreAggregationFilterProcessor

use of uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor in project Gaffer by gchq.

the class QueryScanner method createProcessors.

protected static List<GafferScannerProcessor> createProcessors(final Scan scan, final Schema schema, final ElementSerialisation serialisation) {
    final List<GafferScannerProcessor> processors = new ArrayList<>();
    final Set<Class<? extends GafferScannerProcessor>> extraProcessors = getExtraProcessors(scan);
    // The view will be null if a scan of the table is done in the hbase shell
    final View view = getView(scan);
    if (null != view) {
        processors.add(new GroupFilterProcessor(view));
        if (extraProcessors.remove(ElementDedupeFilterProcessor.class)) {
            processors.add(new ElementDedupeFilterProcessor(view.hasEntities(), view.hasEdges(), getDirectedType(scan)));
        }
    }
    if (schema.isAggregationEnabled()) {
        processors.add(new StoreAggregationProcessor(serialisation, schema));
    }
    processors.add(new ValidationProcessor(schema));
    if (null != view) {
        processors.add(new PreAggregationFilterProcessor(view));
        if (schema.isAggregationEnabled()) {
            processors.add(new QueryAggregationProcessor(serialisation, schema, view));
        }
        processors.add(new PostAggregationFilterProcessor(view));
    }
    if (!extraProcessors.isEmpty()) {
        throw new RuntimeException("Unrecognised extra processors: " + extraProcessors);
    }
    return processors;
}
Also used : ArrayList(java.util.ArrayList) GroupFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GroupFilterProcessor) PreAggregationFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) StoreAggregationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.StoreAggregationProcessor) PostAggregationFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PostAggregationFilterProcessor) GafferScannerProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GafferScannerProcessor) ElementDedupeFilterProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ElementDedupeFilterProcessor) ValidationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ValidationProcessor) QueryAggregationProcessor(uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.QueryAggregationProcessor)

Aggregations

GafferScannerProcessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GafferScannerProcessor)4 GroupFilterProcessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.GroupFilterProcessor)4 PostAggregationFilterProcessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PostAggregationFilterProcessor)4 PreAggregationFilterProcessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.PreAggregationFilterProcessor)4 ValidationProcessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ValidationProcessor)4 Scan (org.apache.hadoop.hbase.client.Scan)3 Test (org.junit.jupiter.api.Test)3 ElementDedupeFilterProcessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.ElementDedupeFilterProcessor)3 QueryAggregationProcessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.QueryAggregationProcessor)3 StoreAggregationProcessor (uk.gov.gchq.gaffer.hbasestore.coprocessor.processor.StoreAggregationProcessor)3 ArrayList (java.util.ArrayList)1 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1