use of uk.gov.gchq.gaffer.operation.impl.Limit in project Gaffer by gchq.
the class CoreOperationChainOptimiserTest method shouldAddLimitOperationForGetOperationsWithLimit.
@Test
public void shouldAddLimitOperationForGetOperationsWithLimit() throws Exception {
// Given
final Store store = mock(Store.class);
final CoreOperationChainOptimiser optimiser = new CoreOperationChainOptimiser(store);
final GetIterableOperation getOperation = mock(GetIterableOperation.class);
final OperationChain<Integer> opChain = new OperationChain<>(getOperation);
final int resultLimit = 5;
given(getOperation.getResultLimit()).willReturn(resultLimit);
// When
final OperationChain<Integer> optimisedOpChain = optimiser.optimise(opChain);
// Then
assertEquals(2, optimisedOpChain.getOperations().size());
assertSame(getOperation, optimisedOpChain.getOperations().get(0));
assertTrue(optimisedOpChain.getOperations().get(1) instanceof Limit);
assertEquals(resultLimit, (int) ((Limit) optimisedOpChain.getOperations().get(1)).getResultLimit());
}
use of uk.gov.gchq.gaffer.operation.impl.Limit in project Gaffer by gchq.
the class CoreOperationChainOptimiserTest method shouldAddLimitOperationBeforeDeduplicateOperationForPerformance.
@Test
public void shouldAddLimitOperationBeforeDeduplicateOperationForPerformance() throws Exception {
// Given
final Store store = mock(Store.class);
final CoreOperationChainOptimiser optimiser = new CoreOperationChainOptimiser(store);
final GetIterableOperation getOperation = mock(GetIterableOperation.class);
final OperationChain<Integer> opChain = new OperationChain<>(getOperation);
final int resultLimit = 5;
given(getOperation.getResultLimit()).willReturn(resultLimit);
given(getOperation.isDeduplicate()).willReturn(true);
// When
final OperationChain<Integer> optimisedOpChain = optimiser.optimise(opChain);
// Then
assertEquals(3, optimisedOpChain.getOperations().size());
assertSame(getOperation, optimisedOpChain.getOperations().get(0));
assertTrue(optimisedOpChain.getOperations().get(1) instanceof Limit);
assertEquals(resultLimit, (int) ((Limit) optimisedOpChain.getOperations().get(1)).getResultLimit());
assertTrue(optimisedOpChain.getOperations().get(2) instanceof Deduplicate);
}
Aggregations