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");
}
}
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());
}
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());
}
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());
}
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();
}
Aggregations