use of com.yelp.nrtsearch.server.luceneserver.ShardState in project nrtsearch by Yelp.
the class TimeoutTest method queryWithFunction.
private TopDocs queryWithFunction(SearchRequest request, Function<SearchContext, TopDocs> func) throws Exception {
SearcherTaxonomyManager.SearcherAndTaxonomy s = null;
IndexState indexState = getGlobalState().getIndex(TEST_INDEX);
ShardState shardState = indexState.getShard(0);
try {
s = shardState.acquire();
SearchContext context = SearchRequestProcessor.buildContextForRequest(request, indexState, shardState, s, ProfileResult.newBuilder());
return func.apply(context);
} finally {
if (s != null) {
shardState.release(s);
}
}
}
use of com.yelp.nrtsearch.server.luceneserver.ShardState in project nrtsearch by Yelp.
the class EagerGlobalOrdinalsTest method testEagerOrdinals.
@Test
public void testEagerOrdinals() throws Exception {
SearcherTaxonomyManager.SearcherAndTaxonomy s = null;
ShardState shardState = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getShard(0);
try {
FieldDef fieldDef = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getField(EAGER_FIELD);
addDocAndRefresh();
s = shardState.acquire();
assertGlobalOrdinals(s.searcher.getIndexReader(), fieldDef);
doQuery(EAGER_FIELD);
assertGlobalOrdinals(s.searcher.getIndexReader(), fieldDef);
// create new reader version
addDocAndRefresh();
shardState.release(s);
s = null;
s = shardState.acquire();
assertGlobalOrdinals(s.searcher.getIndexReader(), fieldDef);
} finally {
if (s != null) {
shardState.release(s);
}
}
}
use of com.yelp.nrtsearch.server.luceneserver.ShardState in project nrtsearch by Yelp.
the class BucketedTieredMergePolicyTest method testFindMerges.
@Test
public void testFindMerges() throws Exception {
setLiveSettings(5, 10000, 100);
addData(500);
ShardState shardState = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getShard(0);
MergePolicy policy = shardState.writer.getConfig().getMergePolicy();
assertTrue(policy instanceof BucketedTieredMergePolicy);
waitForMerges(shardState);
shardState.maybeRefreshBlocking();
SearcherAndTaxonomy s = null;
try {
s = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getShard(0).acquire();
assertEquals(5, s.searcher.getSlices().length);
for (LeafSlice slice : s.searcher.getSlices()) {
assertTrue(slice.leaves.length < 100);
int totalDocs = 0;
for (LeafReaderContext context : slice.leaves) {
totalDocs += context.reader().numDocs();
}
assertEquals(100, totalDocs);
}
} finally {
if (s != null) {
shardState.release(s);
}
}
verifyData(500);
}
use of com.yelp.nrtsearch.server.luceneserver.ShardState in project nrtsearch by Yelp.
the class EagerGlobalOrdinalsTest method testWithoutEagerOrdinals.
@Test
public void testWithoutEagerOrdinals() throws Exception {
SearcherTaxonomyManager.SearcherAndTaxonomy s = null;
ShardState shardState = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getShard(0);
try {
FieldDef fieldDef = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getField(NOT_EAGER_FIELD);
addDocAndRefresh();
s = shardState.acquire();
assertNoGlobalOrdinals(s.searcher.getIndexReader(), fieldDef);
doQuery(NOT_EAGER_FIELD);
assertGlobalOrdinals(s.searcher.getIndexReader(), fieldDef);
// create new reader version
addDocAndRefresh();
shardState.release(s);
s = null;
s = shardState.acquire();
assertNoGlobalOrdinals(s.searcher.getIndexReader(), fieldDef);
doQuery(NOT_EAGER_FIELD);
assertGlobalOrdinals(s.searcher.getIndexReader(), fieldDef);
} finally {
if (s != null) {
shardState.release(s);
}
}
}
use of com.yelp.nrtsearch.server.luceneserver.ShardState in project nrtsearch by Yelp.
the class BucketedTieredMergePolicyTest method testFindForcedMerges.
@Test
public void testFindForcedMerges() throws Exception {
setLiveSettings(10, 10000, 100);
addData(600);
ShardState shardState = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getShard(0);
shardState.writer.forceMerge(1, true);
waitForMerges(shardState);
shardState.maybeRefreshBlocking();
SearcherAndTaxonomy s = null;
try {
s = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getShard(0).acquire();
assertEquals(10, s.searcher.getSlices().length);
for (LeafSlice slice : s.searcher.getSlices()) {
assertEquals(1, slice.leaves.length);
int totalDocs = 0;
for (LeafReaderContext context : slice.leaves) {
totalDocs += context.reader().numDocs();
}
assertEquals(60, totalDocs);
}
} finally {
if (s != null) {
shardState.release(s);
}
}
verifyData(600);
// cut virtual shards in half and re-merge
setLiveSettings(5, 10000, 100);
shardState.writer.forceMerge(1, true);
waitForMerges(shardState);
shardState.maybeRefreshBlocking();
s = null;
try {
s = getGlobalState().getIndex(DEFAULT_TEST_INDEX).getShard(0).acquire();
assertEquals(5, s.searcher.getSlices().length);
for (LeafSlice slice : s.searcher.getSlices()) {
assertEquals(1, slice.leaves.length);
int totalDocs = 0;
for (LeafReaderContext context : slice.leaves) {
totalDocs += context.reader().numDocs();
}
assertEquals(120, totalDocs);
}
} finally {
if (s != null) {
shardState.release(s);
}
}
verifyData(600);
}
Aggregations