Search in sources :

Example 26 with Value

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

the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptUndirectedEdges.

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

        {
            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 boolean expectedResult = !edge.isDirected();
        final Pair<Key> keys = converter.getKeysFromEdge(edge);
        assertEquals("Failed for edge: " + edge.toString(), expectedResult, filter.accept(keys.getFirst(), value));
        if (null != keys.getSecond()) {
            // self edges are not added the other way round
            assertEquals("Failed for edge: " + edge.toString(), expectedResult, 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 27 with Value

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

the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptIncomingEdges.

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

        {
            put(AccumuloStoreConstants.DIRECTED_EDGE_ONLY, "true");
            put(AccumuloStoreConstants.INCOMING_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);
        assertEquals("Failed for edge: " + edge.toString(), false, filter.accept(keys.getFirst(), value));
        if (null != keys.getSecond()) {
            // self edges are not added the other way round
            final boolean expectedResult = edge.isDirected();
            assertEquals("Failed for edge: " + edge.toString(), expectedResult, 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 28 with Value

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

the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptDeduplicatedEdges.

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

        {
            put(AccumuloStoreConstants.OUTGOING_EDGE_ONLY, "true");
            put(AccumuloStoreConstants.DEDUPLICATE_UNDIRECTED_EDGES, "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
        assertTrue("Failed for edge: " + edge.toString(), 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 29 with Value

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

the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptDeduplicatedDirectedEdges.

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

        {
            put(AccumuloStoreConstants.OUTGOING_EDGE_ONLY, "true");
            put(AccumuloStoreConstants.DIRECTED_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 30 with Value

use of org.apache.accumulo.core.data.Value 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)

Aggregations

Value (org.apache.accumulo.core.data.Value)79 Key (org.apache.accumulo.core.data.Key)64 Test (org.junit.Test)38 Edge (uk.gov.gchq.gaffer.data.element.Edge)30 HashMap (java.util.HashMap)23 Element (uk.gov.gchq.gaffer.data.element.Element)23 Mutation (org.apache.accumulo.core.data.Mutation)21 Text (org.apache.hadoop.io.Text)21 Authorizations (org.apache.accumulo.core.security.Authorizations)18 Entry (java.util.Map.Entry)15 Scanner (org.apache.accumulo.core.client.Scanner)15 BatchWriter (org.apache.accumulo.core.client.BatchWriter)12 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)11 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)11 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)11 AccumuloException (org.apache.accumulo.core.client.AccumuloException)10 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)10 Connector (org.apache.accumulo.core.client.Connector)9 Properties (uk.gov.gchq.gaffer.data.element.Properties)9 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)8