use of uk.gov.gchq.gaffer.store.operation.handler.AbstractSampleElementsForSplitPointsHandler in project Gaffer by gchq.
the class SampleElementsForSplitPointsHandlerTest method shouldCalculateRequiredNumberOfSplitsFromEdges.
@Test
public void shouldCalculateRequiredNumberOfSplitsFromEdges() throws OperationException {
// Given
final int numSplits = 3;
final List<Element> elements = IntStream.range(0, numSplits * 10).mapToObj(i -> new Edge(TestGroups.EDGE, "source_" + i, "dest_" + i, true)).collect(Collectors.toList());
final AbstractSampleElementsForSplitPointsHandler<String, AccumuloStore> handler = createHandler();
final SampleElementsForSplitPoints<String> operation = new SampleElementsForSplitPoints.Builder<String>().input(elements).numSplits(numSplits).build();
// When
createHandler().doOperation(operation, new Context(), store);
// Then
final ArgumentCaptor<GenerateSplitPointsFromSample> generateSplitPointsFromSampleCaptor = ArgumentCaptor.forClass(GenerateSplitPointsFromSample.class);
verify(store).execute(generateSplitPointsFromSampleCaptor.capture(), any(Context.class));
final int expectedElementCount = elements.size() * 2;
assertExpectedNumberOfSplitPointsAndSampleSize(generateSplitPointsFromSampleCaptor, numSplits, expectedElementCount);
}
use of uk.gov.gchq.gaffer.store.operation.handler.AbstractSampleElementsForSplitPointsHandler in project Gaffer by gchq.
the class SampleElementsForSplitPointsHandlerTest method shouldUseTheNumberOfTabletServersToCalculateNumSplits.
@Test
public void shouldUseTheNumberOfTabletServersToCalculateNumSplits() throws OperationException {
// Given
final Integer numSplits = null;
final List<Element> elements = IntStream.range(0, 30).mapToObj(i -> new Edge(TestGroups.EDGE, "source_" + i, "dest_" + i, true)).collect(Collectors.toList());
final AbstractSampleElementsForSplitPointsHandler<String, AccumuloStore> handler = createHandler();
final SampleElementsForSplitPoints<String> operation = new SampleElementsForSplitPoints.Builder<String>().input(elements).numSplits(numSplits).build();
// When
createHandler().doOperation(operation, new Context(), store);
// Then
final ArgumentCaptor<GenerateSplitPointsFromSample> generateSplitPointsFromSampleCaptor = ArgumentCaptor.forClass(GenerateSplitPointsFromSample.class);
verify(store).execute(generateSplitPointsFromSampleCaptor.capture(), any(Context.class));
final int expectedNumOfSplits = NUM_TABLET_SERVERS - 1;
final int expectedElementCount = elements.size() * 2;
assertExpectedNumberOfSplitPointsAndSampleSize(generateSplitPointsFromSampleCaptor, expectedNumOfSplits, expectedElementCount);
}
use of uk.gov.gchq.gaffer.store.operation.handler.AbstractSampleElementsForSplitPointsHandler in project Gaffer by gchq.
the class SampleElementsForSplitPointsHandlerTest method shouldUseTheNumberOfRegionsToCalculateNumSplits.
@Test
public void shouldUseTheNumberOfRegionsToCalculateNumSplits() throws OperationException {
// Given
final Integer numSplits = null;
final List<Element> elements = IntStream.range(0, 30).mapToObj(i -> new Edge(TestGroups.EDGE, "source_" + i, "dest_" + i, true)).collect(Collectors.toList());
final AbstractSampleElementsForSplitPointsHandler<String, HBaseStore> handler = createHandler();
final SampleElementsForSplitPoints<String> operation = new SampleElementsForSplitPoints.Builder<String>().input(elements).numSplits(numSplits).build();
// When
createHandler().doOperation(operation, new Context(), store);
// Then
final ArgumentCaptor<GenerateSplitPointsFromSample> generateSplitPointsFromSampleCaptor = ArgumentCaptor.forClass(GenerateSplitPointsFromSample.class);
verify(store).execute(generateSplitPointsFromSampleCaptor.capture(), any(Context.class));
final int expectedNumOfSplits = NUM_TABLE_REGIONS - 1;
final int expectedElementCount = elements.size() * 2;
assertExpectedNumberOfSplitPointsAndSampleSize(generateSplitPointsFromSampleCaptor, expectedNumOfSplits, expectedElementCount);
}
use of uk.gov.gchq.gaffer.store.operation.handler.AbstractSampleElementsForSplitPointsHandler in project Gaffer by gchq.
the class SampleElementsForSplitPointsHandlerTest method shouldCalculateRequiredNumberOfSplitsFromEdges.
@Test
public void shouldCalculateRequiredNumberOfSplitsFromEdges() throws OperationException {
// Given
final int numSplits = 3;
final List<Element> elements = IntStream.range(0, numSplits * 10).mapToObj(i -> new Edge(TestGroups.EDGE, "source_" + i, "dest_" + i, true)).collect(Collectors.toList());
final AbstractSampleElementsForSplitPointsHandler<String, HBaseStore> handler = createHandler();
final SampleElementsForSplitPoints<String> operation = new SampleElementsForSplitPoints.Builder<String>().input(elements).numSplits(numSplits).build();
// When
createHandler().doOperation(operation, new Context(), createStore());
// Then
final ArgumentCaptor<GenerateSplitPointsFromSample> generateSplitPointsFromSampleCaptor = ArgumentCaptor.forClass(GenerateSplitPointsFromSample.class);
verify(store).execute(generateSplitPointsFromSampleCaptor.capture(), any(Context.class));
final int expectedElementCount = elements.size() * 2;
assertExpectedNumberOfSplitPointsAndSampleSize(generateSplitPointsFromSampleCaptor, numSplits, expectedElementCount);
}
Aggregations