Search in sources :

Example 16 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptDeduplicatedUndirectedEdges.

@Test
public void shouldOnlyAcceptDeduplicatedUndirectedEdges() throws OperationException, AccumuloElementConversionException {
    // Given
    final ClassicEdgeDirectedUndirectedFilterIterator filter = new ClassicEdgeDirectedUndirectedFilterIterator();
    final Map<String, String> options = new HashMap<String, String>() {

        {
            put(AccumuloStoreConstants.DEDUPLICATE_UNDIRECTED_EDGES, "true");
            put(AccumuloStoreConstants.UNDIRECTED_EDGE_ONLY, "true");
        }
    };
    filter.validateOptions(options);
    // value should not be used
    final Value value = null;
    // When / Then
    for (final Edge edge : EDGES) {
        final Pair<Key> keys = converter.getKeysFromEdge(edge);
        // First key is deduplicated
        assertEquals("Failed for edge: " + edge.toString(), !edge.isDirected(), filter.accept(keys.getFirst(), value));
        if (null != keys.getSecond()) {
            // self edges are not added the other way round
            assertFalse("Failed for edge: " + edge.toString(), filter.accept(keys.getSecond(), value));
        }
    }
}
Also used : HashMap(java.util.HashMap) ClassicEdgeDirectedUndirectedFilterIterator(uk.gov.gchq.gaffer.accumulostore.key.core.impl.classic.ClassicEdgeDirectedUndirectedFilterIterator) Value(org.apache.accumulo.core.data.Value) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 17 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ElementPostAggregationFilterTest method shouldAcceptElementWhenViewValidatorAcceptsElement.

@Test
public void shouldAcceptElementWhenViewValidatorAcceptsElement() throws Exception {
    // Given
    final AbstractElementFilter filter = new ElementPostAggregationFilter();
    final Map<String, String> options = new HashMap<>();
    options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
    options.put(AccumuloStoreConstants.VIEW, getViewJson());
    options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
    filter.validateOptions(options);
    final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
    final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
    final Pair<Key> key = converter.getKeysFromElement(element);
    final Value value = converter.getValueFromElement(element);
    // When
    final boolean accept = filter.accept(key.getFirst(), value);
    // Then
    assertTrue(accept);
}
Also used : AbstractElementFilter(uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter) HashMap(java.util.HashMap) Element(uk.gov.gchq.gaffer.data.element.Element) Value(org.apache.accumulo.core.data.Value) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 18 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ElementPostAggregationFilterTest method shouldNotAcceptElementWhenViewValidatorDoesNotAcceptElement.

@Test
public void shouldNotAcceptElementWhenViewValidatorDoesNotAcceptElement() throws Exception {
    // Given
    final AbstractElementFilter filter = new ElementPostAggregationFilter();
    final Map<String, String> options = new HashMap<>();
    options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
    options.put(AccumuloStoreConstants.VIEW, getEmptyViewJson());
    options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
    filter.validateOptions(options);
    final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
    final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
    final Pair<Key> key = converter.getKeysFromElement(element);
    final Value value = converter.getValueFromElement(element);
    // When
    final boolean accept = filter.accept(key.getFirst(), value);
    // Then
    assertFalse(accept);
}
Also used : AbstractElementFilter(uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter) HashMap(java.util.HashMap) Element(uk.gov.gchq.gaffer.data.element.Element) Value(org.apache.accumulo.core.data.Value) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 19 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ElementPreAggregationFilterTest method shouldAcceptElementWhenViewValidatorAcceptsElement.

@Test
public void shouldAcceptElementWhenViewValidatorAcceptsElement() throws Exception {
    // Given
    final AbstractElementFilter filter = new ElementPreAggregationFilter();
    final Map<String, String> options = new HashMap<>();
    options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
    options.put(AccumuloStoreConstants.VIEW, getViewJson());
    options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
    filter.validateOptions(options);
    final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
    final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
    final Pair<Key> key = converter.getKeysFromElement(element);
    final Value value = converter.getValueFromElement(element);
    // When
    final boolean accept = filter.accept(key.getFirst(), value);
    // Then
    assertTrue(accept);
}
Also used : AbstractElementFilter(uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter) HashMap(java.util.HashMap) Element(uk.gov.gchq.gaffer.data.element.Element) Value(org.apache.accumulo.core.data.Value) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 20 with Key

use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.

the class ValidatorFilterTest method shouldAcceptElementWhenSchemaValidatorAcceptsElement.

@Test
public void shouldAcceptElementWhenSchemaValidatorAcceptsElement() throws Exception {
    // Given
    final ValidatorFilter filter = new ValidatorFilter();
    final Map<String, String> options = new HashMap<>();
    options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
    options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
    filter.validateOptions(options);
    final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
    final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
    final Pair<Key> key = converter.getKeysFromElement(element);
    final Value value = converter.getValueFromElement(element);
    // When
    final boolean accept = filter.accept(key.getFirst(), value);
    // Then
    assertTrue(accept);
}
Also used : HashMap(java.util.HashMap) Element(uk.gov.gchq.gaffer.data.element.Element) Value(org.apache.accumulo.core.data.Value) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

Key (org.apache.accumulo.core.data.Key)115 Value (org.apache.accumulo.core.data.Value)68 Test (org.junit.Test)66 Edge (uk.gov.gchq.gaffer.data.element.Edge)44 Range (org.apache.accumulo.core.data.Range)35 HashMap (java.util.HashMap)29 Text (org.apache.hadoop.io.Text)23 Element (uk.gov.gchq.gaffer.data.element.Element)23 Scanner (org.apache.accumulo.core.client.Scanner)19 Authorizations (org.apache.accumulo.core.security.Authorizations)18 Mutation (org.apache.accumulo.core.data.Mutation)17 Entity (uk.gov.gchq.gaffer.data.element.Entity)15 Entry (java.util.Map.Entry)14 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)13 AccumuloException (org.apache.accumulo.core.client.AccumuloException)11 Connector (org.apache.accumulo.core.client.Connector)11 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)11 ExprNodeColumnDesc (org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc)11 ExprNodeConstantDesc (org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc)11 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)11