Search in sources :

Example 1 with RowAccounting

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);
}
Also used : RowAccounting(io.crate.breaker.RowAccounting) CircuitBreakingException(org.elasticsearch.common.breaker.CircuitBreakingException) Row(io.crate.data.Row) Test(org.junit.Test)

Example 2 with RowAccounting

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);
}
Also used : RowAccounting(io.crate.breaker.RowAccounting) CircuitBreakingException(org.elasticsearch.common.breaker.CircuitBreakingException) Row(io.crate.data.Row) Test(org.junit.Test)

Example 3 with RowAccounting

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);
}
Also used : RowN(io.crate.data.RowN) RowAccounting(io.crate.breaker.RowAccounting) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

RowAccounting (io.crate.breaker.RowAccounting)3 Row (io.crate.data.Row)2 CircuitBreakingException (org.elasticsearch.common.breaker.CircuitBreakingException)2 Test (org.junit.Test)2 RowN (io.crate.data.RowN)1 Setup (org.openjdk.jmh.annotations.Setup)1