use of io.crate.breaker.RowAccounting in project crate by crate.
the class OrderedLuceneBatchIteratorFactoryTest method testOrderedLuceneBatchIteratorWithMultipleCollectorsTripsCircuitBreaker.
@Test
public void testOrderedLuceneBatchIteratorWithMultipleCollectorsTripsCircuitBreaker() throws Exception {
RowAccounting rowAccounting = mock(RowAccountingWithEstimators.class);
CircuitBreakingException circuitBreakingException = new CircuitBreakingException("tripped circuit breaker");
doThrow(circuitBreakingException).when(rowAccounting).accountForAndMaybeBreak(any(Row.class));
LuceneOrderedDocCollector collector1 = createOrderedCollector(searcher1, 1);
LuceneOrderedDocCollector collector2 = createOrderedCollector(searcher2, 2);
BatchIterator<Row> rowBatchIterator = OrderedLuceneBatchIteratorFactory.newInstance(Arrays.asList(collector1, collector2), OrderingByPosition.rowOrdering(new int[] { 0 }, reverseFlags, nullsFirst), rowAccounting, Runnable::run, () -> 1, true);
consumeIteratorAndVerifyResultIsException(rowBatchIterator, circuitBreakingException);
}
use of io.crate.breaker.RowAccounting in project crate by crate.
the class OrderedLuceneBatchIteratorFactoryTest method testSingleCollectorOrderedLuceneBatchIteratorTripsCircuitBreaker.
@Test
public void testSingleCollectorOrderedLuceneBatchIteratorTripsCircuitBreaker() throws Exception {
RowAccounting rowAccounting = mock(RowAccounting.class);
CircuitBreakingException circuitBreakingException = new CircuitBreakingException("tripped circuit breaker");
doThrow(circuitBreakingException).when(rowAccounting).accountForAndMaybeBreak(any(Row.class));
BatchIterator<Row> rowBatchIterator = OrderedLuceneBatchIteratorFactory.newInstance(Arrays.asList(createOrderedCollector(searcher1, 1)), OrderingByPosition.rowOrdering(new int[] { 0 }, reverseFlags, nullsFirst), rowAccounting, Runnable::run, () -> 2, true);
consumeIteratorAndVerifyResultIsException(rowBatchIterator, circuitBreakingException);
}
use of io.crate.breaker.RowAccounting in project crate by crate.
the class SortingTopNCollectorBenchmark method setUp.
@Setup
public void setUp() {
rows = IntStream.range(0, 10_000_000).mapToObj(i -> new RowN(i)).collect(Collectors.toList());
boundedSortingCollector = new BoundedSortingTopNCollector(new RowAccounting<Object[]>() {
@Override
public void accountForAndMaybeBreak(Object[] row) {
}
@Override
public void release() {
}
}, INPUTS, COLLECT_EXPRESSIONS, 1, COMPARATOR, 10_000, 0);
unboundedSortingCollector = new UnboundedSortingTopNCollector(new RowAccounting<Object[]>() {
@Override
public void accountForAndMaybeBreak(Object[] row) {
}
@Override
public void release() {
}
}, INPUTS, COLLECT_EXPRESSIONS, 1, COMPARATOR, 10_000, 10_000, 0);
}
Aggregations