use of org.elasticsearch.common.util.MockBigArrays in project elasticsearch by elastic.
the class NettyTransportMultiPortTests method startTransport.
private TcpTransport<?> startTransport(Settings settings, ThreadPool threadPool) {
BigArrays bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
TcpTransport<?> transport = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()), bigArrays, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService());
transport.start();
assertThat(transport.lifecycleState(), is(Lifecycle.State.STARTED));
return transport;
}
use of org.elasticsearch.common.util.MockBigArrays in project elasticsearch by elastic.
the class Netty4HttpChannelTests method setup.
@Before
public void setup() throws Exception {
networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
threadPool = new TestThreadPool("test");
bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
}
use of org.elasticsearch.common.util.MockBigArrays in project elasticsearch by elastic.
the class BestDocsDeferringCollectorTests method testReplay.
public void testReplay() throws Exception {
Directory directory = newDirectory();
RandomIndexWriter indexWriter = new RandomIndexWriter(random(), directory);
int numDocs = randomIntBetween(1, 128);
int maxNumValues = randomInt(16);
for (int i = 0; i < numDocs; i++) {
Document document = new Document();
document.add(new StringField("field", String.valueOf(randomInt(maxNumValues)), Field.Store.NO));
indexWriter.addDocument(document);
}
indexWriter.close();
IndexReader indexReader = DirectoryReader.open(directory);
IndexSearcher indexSearcher = new IndexSearcher(indexReader);
TermQuery termQuery = new TermQuery(new Term("field", String.valueOf(randomInt(maxNumValues))));
TopDocs topDocs = indexSearcher.search(termQuery, numDocs);
BestDocsDeferringCollector collector = new BestDocsDeferringCollector(numDocs, new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService()));
Set<Integer> deferredCollectedDocIds = new HashSet<>();
collector.setDeferredCollector(Collections.singleton(testCollector(deferredCollectedDocIds)));
collector.preCollection();
indexSearcher.search(termQuery, collector);
collector.postCollection();
collector.replay(0);
assertEquals(topDocs.scoreDocs.length, deferredCollectedDocIds.size());
for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
assertTrue("expected docid [" + scoreDoc.doc + "] is missing", deferredCollectedDocIds.contains(scoreDoc.doc));
}
collector.close();
indexReader.close();
directory.close();
}
use of org.elasticsearch.common.util.MockBigArrays in project elasticsearch by elastic.
the class InternalAggregationTestCase method testReduceRandom.
public final void testReduceRandom() {
String name = randomAsciiOfLength(5);
List<T> inputs = new ArrayList<>();
List<InternalAggregation> toReduce = new ArrayList<>();
int toReduceSize = between(1, 200);
for (int i = 0; i < toReduceSize; i++) {
T t = randomBoolean() ? createUnmappedInstance(name) : createTestInstance(name);
inputs.add(t);
toReduce.add(t);
}
ScriptService mockScriptService = mockScriptService();
MockBigArrays bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
if (randomBoolean() && toReduce.size() > 1) {
Collections.shuffle(toReduce, random());
// we leave at least one element in the list
int r = Math.max(1, randomIntBetween(0, toReduceSize - 2));
List<InternalAggregation> internalAggregations = toReduce.subList(0, r);
InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(bigArrays, mockScriptService, false);
@SuppressWarnings("unchecked") T reduced = (T) inputs.get(0).reduce(internalAggregations, context);
toReduce = toReduce.subList(r, toReduceSize);
toReduce.add(reduced);
}
InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(bigArrays, mockScriptService, true);
@SuppressWarnings("unchecked") T reduced = (T) inputs.get(0).reduce(toReduce, context);
assertReduced(reduced, inputs);
}
Aggregations