Skip to content

Commit

Permalink
Addresing more PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Potemkin committed Feb 11, 2025
1 parent 52bad48 commit 3c46276
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
24 changes: 12 additions & 12 deletions src/main/perf/SearchTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,20 @@ public void go(IndexState state, TaskParser taskParser) throws IOException {
facetResults = new ArrayList<FacetResult>();
// TODO: support sort, filter too!!
// TODO: support other facet methods
List<TaskParser.TaskBuilder.FacetTask> classicFacetRequests = new ArrayList<>();
List<TaskParser.TaskBuilder.FacetTask> sandboxFacetRequests = new ArrayList<>();
List<TaskParser.TaskBuilder.FacetTask> postCollectionFacetTasks = new ArrayList<>();
List<TaskParser.TaskBuilder.FacetTask> duringCollectionFacetTasks = new ArrayList<>();
for (TaskParser.TaskBuilder.FacetTask request : facetRequests) {
switch (request.facetMode()) {
case UNDEFINED:
case CLASSIC:
classicFacetRequests.add(request);
case POST_COLLECTION:
postCollectionFacetTasks.add(request);
break;
case SANDBOX:
sandboxFacetRequests.add(request);
case DURING_COLLECTION:
duringCollectionFacetTasks.add(request);
}
}
long t0 = System.nanoTime();
if (sandboxFacetRequests.isEmpty() == false) {
if (duringCollectionFacetTasks.isEmpty() == false) {
// TODO: once we have helper methods for easy sandbox facet use cases
// lets use them to make this code shorter and less prone to errors
// TODO: sandbox facet module doesn't currently have methods to aggregate for all docs in the index.
Expand All @@ -264,7 +264,7 @@ public void go(IndexState state, TaskParser taskParser) throws IOException {
if (q instanceof MatchAllDocsQuery == false) {
collectorManagers.add(new TopScoreDocCollectorManager(10, null, Integer.MAX_VALUE));
}
for (TaskParser.TaskBuilder.FacetTask request : sandboxFacetRequests) {
for (TaskParser.TaskBuilder.FacetTask request : duringCollectionFacetTasks) {
String indexFieldName;
// TODO: handle other types, not just taxonomy
if (request.dimension().endsWith(".taxonomy")) {
Expand All @@ -287,7 +287,7 @@ public void go(IndexState state, TaskParser taskParser) throws IOException {
if (q instanceof MatchAllDocsQuery == false) {
hits = (TopDocs) results[0];
}
for (TaskParser.TaskBuilder.FacetTask request : sandboxFacetRequests) {
for (TaskParser.TaskBuilder.FacetTask request : duringCollectionFacetTasks) {
FacetsConfig.DimConfig dimConfig = state.facetsConfig.getDimConfig(request.dimension());
String indexFieldName = dimConfig.indexFieldName;
CountFacetRecorder recorder = indexFieldToRecorder.get(indexFieldName);
Expand Down Expand Up @@ -350,9 +350,9 @@ public void go(IndexState state, TaskParser taskParser) throws IOException {
childCount));
}
}
if (classicFacetRequests.isEmpty() == false) {
if (postCollectionFacetTasks.isEmpty() == false) {
if (q instanceof MatchAllDocsQuery) {
for (TaskParser.TaskBuilder.FacetTask request : classicFacetRequests) {
for (TaskParser.TaskBuilder.FacetTask request : postCollectionFacetTasks) {
if (request.dimension().startsWith("range:")) {
throw new AssertionError("fix me!");
} else if (request.dimension().endsWith(".taxonomy")) {
Expand All @@ -376,7 +376,7 @@ public void go(IndexState state, TaskParser taskParser) throws IOException {
FacetsCollectorManager.FacetsResult fr = FacetsCollectorManager.search(searcher, q, 10, new FacetsCollectorManager());
hits = fr.topDocs();
FacetsCollector fc = fr.facetsCollector();
for (TaskParser.TaskBuilder.FacetTask facetRequest : classicFacetRequests) {
for (TaskParser.TaskBuilder.FacetTask facetRequest : postCollectionFacetTasks) {
String request = facetRequest.dimension();
if (request.startsWith("range:")) {
int i = request.indexOf(':', 6);
Expand Down
4 changes: 2 additions & 2 deletions src/main/perf/TaskParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ List<String> parseDismaxFields() {
List<FacetTask> parseFacets() {
List<FacetTask> facets = new ArrayList<>();
Map<String, TestContext.FacetMode> prefixTypes = Map.of(" +facets:", TestContext.FacetMode.UNDEFINED,
" +сlassic_facets:", TestContext.FacetMode.CLASSIC,
" +sandbox_facets:", TestContext.FacetMode.SANDBOX
" +post_collection_facets:", TestContext.FacetMode.POST_COLLECTION,
" +during_collection_facets:", TestContext.FacetMode.DURING_COLLECTION
);
while (true) {
boolean found = false;
Expand Down
4 changes: 2 additions & 2 deletions src/main/perf/TestContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static TestContext parse(String context) {

public enum FacetMode {
UNDEFINED,
CLASSIC,
SANDBOX, // TODO: better names?
POST_COLLECTION,
DURING_COLLECTION,
}

}
1 change: 1 addition & 0 deletions src/python/benchUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ def runSimpleSearchBench(self, iter, id, c,
f',filename={constants.LOGS_DIR}/bench-search-{id}-{c.name}-{iter}.jfr',
'-XX:+UnlockDiagnosticVMOptions',
'-XX:+DebugNonSafepoints',
# uncomment the line below to enable remote debugging
# '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:7891'
]

Expand Down
10 changes: 5 additions & 5 deletions src/python/localrunFacets.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
('taxonomy:RandomLabel', 'RandomLabel'),
('sortedset:RandomLabel', 'RandomLabel')))
# create a competitor named baseline with sources in the ../trunk folder
comp.competitor('classic_facets', args.lucene_dir,
comp.competitor('post_collection_facets', args.lucene_dir,
index = index, searchConcurrency = args.searchConcurrency,
testContext="facetMode:CLASSIC")
comp.competitor('sandbox_facets', args.lucene_dir,
testContext="facetMode:POST_COLLECTION", pk = False)
comp.competitor('during_collection_facets', args.lucene_dir,
index = index, searchConcurrency = args.searchConcurrency,
testContext="facetMode:SANDBOX")
testContext="facetMode:DURING_COLLECTION", pk = False)

# start the benchmark - this can take long depending on your index and machines
comp.benchmark("sandbox_facets")
comp.benchmark("facet_implementations")

0 comments on commit 3c46276

Please sign in to comment.