Search in sources :

Example 1 with Pair

use of uk.gov.gchq.gaffer.accumulostore.utils.Pair in project Gaffer by gchq.

the class AccumuloRangeIDRetrieverTest method shouldRetieveElementsInRangeBetweenSeeds.

private void shouldRetieveElementsInRangeBetweenSeeds(final AccumuloStore store) throws StoreException {
    // Create set to query for
    final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0000"), new EntitySeed("0999")));
    // Retrieve elements when less simple entities are provided than the max number of entries for the batch scanner
    final GetElementsOperation<Pair<ElementSeed>, CloseableIterable<Element>> operation = new GetElementsInRanges<>(defaultView, simpleEntityRanges);
    try {
        final AccumuloRangeIDRetriever retriever = new AccumuloRangeIDRetriever(store, operation, new User());
        assertEquals(numEntries, Iterables.size(retriever));
    } catch (IteratorSettingException e) {
        fail("Unable to construct Range Retriever");
    }
}
Also used : User(uk.gov.gchq.gaffer.user.User) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) HashSet(java.util.HashSet) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair)

Example 2 with Pair

use of uk.gov.gchq.gaffer.accumulostore.utils.Pair in project Gaffer by gchq.

the class GetElementsInRangesTest method shouldSerialiseAndDeserialiseOperation.

@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
    // Given
    final List<Pair<EntitySeed>> pairList = new ArrayList<>();
    final Pair<EntitySeed> pair1 = new Pair<>(AccumuloTestData.SEED_SOURCE_1, AccumuloTestData.SEED_DESTINATION_1);
    final Pair<EntitySeed> pair2 = new Pair<>(AccumuloTestData.SEED_SOURCE_2, AccumuloTestData.SEED_DESTINATION_2);
    pairList.add(pair1);
    pairList.add(pair2);
    final GetElementsInRanges<Pair<EntitySeed>, Edge> op = new GetElementsInRanges<>(pairList);
    // When
    byte[] json = serialiser.serialise(op, true);
    final GetElementsInRanges<Pair<EntitySeed>, Edge> deserialisedOp = serialiser.deserialise(json, GetElementsInRanges.class);
    // Then
    final Iterator itrPairs = deserialisedOp.getSeeds().iterator();
    assertEquals(pair1, itrPairs.next());
    assertEquals(pair2, itrPairs.next());
    assertFalse(itrPairs.hasNext());
}
Also used : ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Iterator(java.util.Iterator) Edge(uk.gov.gchq.gaffer.data.element.Edge) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.Test)

Example 3 with Pair

use of uk.gov.gchq.gaffer.accumulostore.utils.Pair in project Gaffer by gchq.

the class GetEntitiesInRangesTest method shouldSerialiseAndDeserialiseOperation.

@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
    // Given
    final List<Pair<EntitySeed>> pairList = new ArrayList<>();
    final Pair<EntitySeed> pair1 = new Pair<>(AccumuloTestData.SEED_SOURCE_1, AccumuloTestData.SEED_DESTINATION_1);
    final Pair<EntitySeed> pair2 = new Pair<>(AccumuloTestData.SEED_SOURCE_2, AccumuloTestData.SEED_DESTINATION_2);
    pairList.add(pair1);
    pairList.add(pair2);
    final GetEntitiesInRanges<Pair<EntitySeed>> op = new GetEntitiesInRanges<>(pairList);
    // When
    byte[] json = serialiser.serialise(op, true);
    final GetEntitiesInRanges<Pair<EntitySeed>> deserialisedOp = serialiser.deserialise(json, GetEntitiesInRanges.class);
    // Then
    final Iterator itrPairs = deserialisedOp.getSeeds().iterator();
    assertEquals(pair1, itrPairs.next());
    assertEquals(pair2, itrPairs.next());
    assertFalse(itrPairs.hasNext());
}
Also used : ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Iterator(java.util.Iterator) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.Test)

Example 4 with Pair

use of uk.gov.gchq.gaffer.accumulostore.utils.Pair in project Gaffer by gchq.

the class GetEdgesInRangesTest method shouldSerialiseAndDeserialiseOperation.

@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
    // Given
    final List<Pair<EntitySeed>> pairList = new ArrayList<>();
    final Pair<EntitySeed> pair1 = new Pair<>(AccumuloTestData.SEED_SOURCE_1, AccumuloTestData.SEED_DESTINATION_1);
    final Pair<EntitySeed> pair2 = new Pair<>(AccumuloTestData.SEED_SOURCE_2, AccumuloTestData.SEED_DESTINATION_2);
    pairList.add(pair1);
    pairList.add(pair2);
    final GetEdgesInRanges<Pair<EntitySeed>> op = new GetEdgesInRanges<>(pairList);
    // When
    byte[] json = serialiser.serialise(op, true);
    final GetEdgesInRanges<Pair<EntitySeed>> deserialisedOp = serialiser.deserialise(json, GetEdgesInRanges.class);
    // Then
    final Iterator itrPairs = deserialisedOp.getSeeds().iterator();
    assertEquals(pair1, itrPairs.next());
    assertEquals(pair2, itrPairs.next());
    assertFalse(itrPairs.hasNext());
}
Also used : ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Iterator(java.util.Iterator) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.Test)

Example 5 with Pair

use of uk.gov.gchq.gaffer.accumulostore.utils.Pair in project Gaffer by gchq.

the class GetElementsinRangesHandlerTest method shouldReturnNothingWhenNoEdgesSet.

private void shouldReturnNothingWhenNoEdgesSet(final AccumuloStore store) throws OperationException {
    // Create set to query for
    final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
    //get Everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
    simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0"), new EntitySeed("1")));
    final View view = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
    final GetElementsInRanges<Pair<ElementSeed>, Element> operation = new GetElementsInRanges<>(view, simpleEntityRanges);
    //All Edges stored should be outgoing from our provided seeds.
    operation.setIncludeEdges(IncludeEdgeType.UNDIRECTED);
    final GetElementsInRangesHandler handler = new GetElementsInRangesHandler();
    final CloseableIterable<Element> elements = handler.doOperation(operation, user, store);
    final int count = Iterables.size(elements);
    //There should be no incoming edges to the provided range
    assertEquals(0, count);
    elements.close();
}
Also used : GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) Element(uk.gov.gchq.gaffer.data.element.Element) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) HashSet(java.util.HashSet) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair)

Aggregations

Pair (uk.gov.gchq.gaffer.accumulostore.utils.Pair)13 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)9 HashSet (java.util.HashSet)6 GetElementsInRanges (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges)6 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)6 Element (uk.gov.gchq.gaffer.data.element.Element)5 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)4 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 Key (org.apache.accumulo.core.data.Key)3 Test (org.junit.Test)3 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)3 User (uk.gov.gchq.gaffer.user.User)3 Range (org.apache.accumulo.core.data.Range)1 Value (org.apache.accumulo.core.data.Value)1 Tuple2 (scala.Tuple2)1 ArrayBuffer (scala.collection.mutable.ArrayBuffer)1 AccumuloElementConversionException (uk.gov.gchq.gaffer.accumulostore.key.exception.AccumuloElementConversionException)1 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)1