Skip to content

Commit 32e043f

Browse files
Make java compile task pass
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
1 parent 8c743ec commit 32e043f

13 files changed

+40
-52
lines changed

build.gradle

+14-8
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import java.util.concurrent.Callable
1414

1515
buildscript {
1616
ext {
17-
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
18-
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
17+
opensearch_version = System.getProperty("opensearch.version", "3.0.0-alpha1-SNAPSHOT")
18+
buildVersionQualifier = System.getProperty("build.version_qualifier", "alpha1")
1919
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
2020
version_tokens = opensearch_version.tokenize('-')
2121
opensearch_build = version_tokens[0] + '.0'
@@ -250,21 +250,26 @@ def knnJarDirectory = "$buildDir/dependencies/opensearch-knn"
250250

251251
dependencies {
252252
api "org.opensearch:opensearch:${opensearch_version}"
253-
zipArchive group: 'org.opensearch.plugin', name:'opensearch-knn', version: "${opensearch_build}"
254-
zipArchive group: 'org.opensearch.plugin', name:'opensearch-ml-plugin', version: "${opensearch_build}"
253+
//TODO need to replace by ${opensearch_build} once dependencies adapt new core version
254+
zipArchive group: 'org.opensearch.plugin', name:'opensearch-knn', version: "3.0.0.0-SNAPSHOT"
255+
//TODO need to replace by ${opensearch_build} once dependencies adapt new core version
256+
zipArchive group: 'org.opensearch.plugin', name:'opensearch-ml-plugin', version: "3.0.0.0-SNAPSHOT"
255257
secureIntegTestPluginArchive group: 'org.opensearch.plugin', name:'opensearch-security', version: "${opensearch_build}"
256-
compileOnly fileTree(dir: knnJarDirectory, include: "opensearch-knn-${opensearch_build}.jar")
258+
//TODO need to replace by ${opensearch_build} once dependencies adapt new core version
259+
compileOnly fileTree(dir: knnJarDirectory, include: "opensearch-knn-3.0.0.0-SNAPSHOT.jar")
257260
compileOnly group: 'com.google.guava', name: 'guava', version:'32.1.3-jre'
258261
compileOnly group: 'commons-lang', name: 'commons-lang', version: '2.6'
259-
api group: 'org.opensearch', name:'opensearch-ml-client', version: "${opensearch_build}"
262+
//TODO need to replace by ${opensearch_build} once dependencies adapt new core version
263+
api group: 'org.opensearch', name:'opensearch-ml-client', version: "3.0.0.0-SNAPSHOT"
260264
testFixturesImplementation "org.opensearch.test:framework:${opensearch_version}"
261265
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
262266
// ml-common excluded reflection for runtime so we need to add it by ourselves.
263267
// https://github.com/opensearch-project/ml-commons/commit/464bfe34c66d7a729a00dd457f03587ea4e504d9
264268
// TODO: Remove following three lines of dependencies if ml-common include them in their jar
265269
runtimeOnly group: 'org.reflections', name: 'reflections', version: '0.9.12'
266270
runtimeOnly group: 'org.javassist', name: 'javassist', version: '3.29.2-GA'
267-
runtimeOnly group: 'org.opensearch', name: 'common-utils', version: "${opensearch_build}"
271+
//TODO need to replace by ${opensearch_build} once dependencies adapt new core version
272+
runtimeOnly group: 'org.opensearch', name: 'common-utils', version: "3.0.0.0-SNAPSHOT"
268273
runtimeOnly group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'
269274
runtimeOnly group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
270275
runtimeOnly group: 'org.json', name: 'json', version: '20231013'
@@ -273,7 +278,8 @@ dependencies {
273278
testFixturesImplementation "org.opensearch:common-utils:${version}"
274279
testFixturesImplementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
275280
testFixturesCompileOnly group: 'com.google.guava', name: 'guava', version:'32.1.3-jre'
276-
testFixturesCompileOnly fileTree(dir: knnJarDirectory, include: "opensearch-knn-${opensearch_build}.jar")
281+
//TODO need to replace by ${opensearch_build} once dependencies adapt new core version
282+
testFixturesCompileOnly fileTree(dir: knnJarDirectory, include: "opensearch-knn-3.0.0.0-SNAPSHOT.jar")
277283
}
278284

279285
// In order to add the jar to the classpath, we need to unzip the

src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private List<CompoundTopDocs> getCompoundTopDocs(CombineScoresDto combineScoresD
233233
* @return max score
234234
*/
235235
private float maxScoreForShard(CompoundTopDocs updatedTopDocs, boolean isSortEnabled) {
236-
if (updatedTopDocs.getTotalHits().value == 0 || updatedTopDocs.getScoreDocs().isEmpty()) {
236+
if (updatedTopDocs.getTotalHits().value() == 0 || updatedTopDocs.getScoreDocs().isEmpty()) {
237237
return MAX_SCORE_WHEN_NO_HITS_FOUND;
238238
}
239239
if (isSortEnabled) {

src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombiner.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private void combineShardScores(
8181
final CompoundTopDocs compoundQueryTopDocs,
8282
final Sort sort
8383
) {
84-
if (Objects.isNull(compoundQueryTopDocs) || compoundQueryTopDocs.getTotalHits().value == 0) {
84+
if (Objects.isNull(compoundQueryTopDocs) || compoundQueryTopDocs.getTotalHits().value() == 0) {
8585
return;
8686
}
8787
List<TopDocs> topDocsPerSubQuery = compoundQueryTopDocs.getTopDocs();
@@ -292,7 +292,7 @@ private void updateQueryTopDocsWithCombinedScores(
292292
boolean isSortingEnabled
293293
) {
294294
// - max number of hits will be the same which are passed from QueryPhase
295-
long maxHits = compoundQueryTopDocs.getTotalHits().value;
295+
long maxHits = compoundQueryTopDocs.getTotalHits().value();
296296
// - update query search results with normalized scores
297297
compoundQueryTopDocs.setScoreDocs(
298298
getCombinedScoreDocs(
@@ -309,7 +309,7 @@ private void updateQueryTopDocsWithCombinedScores(
309309

310310
private TotalHits getTotalHits(final List<TopDocs> topDocsPerSubQuery, final long maxHits) {
311311
TotalHits.Relation totalHits = TotalHits.Relation.EQUAL_TO;
312-
if (topDocsPerSubQuery.stream().anyMatch(topDocs -> topDocs.totalHits.relation == TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO)) {
312+
if (topDocsPerSubQuery.stream().anyMatch(topDocs -> topDocs.totalHits.relation() == TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO)) {
313313
totalHits = TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO;
314314
}
315315
return new TotalHits(maxHits, totalHits);
@@ -343,7 +343,7 @@ private List<ExplanationDetails> explainByShard(
343343
final CompoundTopDocs compoundQueryTopDocs,
344344
final Sort sort
345345
) {
346-
if (Objects.isNull(compoundQueryTopDocs) || compoundQueryTopDocs.getTotalHits().value == 0) {
346+
if (Objects.isNull(compoundQueryTopDocs) || compoundQueryTopDocs.getTotalHits().value() == 0) {
347347
return List.of();
348348
}
349349
// create map of normalized scores results returned from the single shard

src/main/java/org/opensearch/neuralsearch/processor/rerank/RescoringRerankProcessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void rerank(
5959
final ActionListener<SearchResponse> listener
6060
) {
6161
try {
62-
if (searchResponse.getHits().getTotalHits().value == 0) {
62+
if (searchResponse.getHits().getTotalHits().value() == 0) {
6363
listener.onResponse(searchResponse);
6464
return;
6565
}

src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public HybridQueryScorer(final Weight weight, final List<Scorer> subScorers) thr
4949
}
5050

5151
HybridQueryScorer(final Weight weight, final List<Scorer> subScorers, final ScoreMode scoreMode) throws IOException {
52-
super(weight);
52+
super();
5353
this.subScorers = Collections.unmodifiableList(subScorers);
5454
this.numSubqueries = subScorers.size();
5555
this.subScorersPQ = initializeSubScorersPQ();

src/main/java/org/opensearch/neuralsearch/query/HybridQueryWeight.java

-18
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,6 @@ private Void addScoreSupplier(Weight weight, HybridQueryExecutorCollector<LeafRe
109109
return null;
110110
}
111111

112-
/**
113-
* Create the scorer used to score our associated Query
114-
*
115-
* @param context the {@link LeafReaderContext} for which to return the
116-
* {@link Scorer}.
117-
* @return scorer of hybrid query that contains scorers of each sub-query, null if there are no matches in any sub-query
118-
* @throws IOException
119-
*/
120-
@Override
121-
public Scorer scorer(LeafReaderContext context) throws IOException {
122-
ScorerSupplier supplier = scorerSupplier(context);
123-
if (supplier == null) {
124-
return null;
125-
}
126-
supplier.setTopLevelScoringClause();
127-
return supplier.get(Long.MAX_VALUE);
128-
}
129-
130112
/**
131113
* Check if weight object can be cached
132114
*

src/main/java/org/opensearch/neuralsearch/search/HybridDisiWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class HybridDisiWrapper extends DisiWrapper {
1717
private final int subQueryIndex;
1818

1919
public HybridDisiWrapper(Scorer scorer, int subQueryIndex) {
20-
super(scorer);
20+
super(scorer, false);
2121
this.subQueryIndex = subQueryIndex;
2222
}
2323
}

src/main/java/org/opensearch/neuralsearch/search/collector/HybridTopFieldDocSortCollector.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ private HybridQueryScorer getHybridQueryScorer(final Scorable scorer) throws IOE
166166
return (HybridQueryScorer) scorer;
167167
}
168168
for (Scorable.ChildScorable childScorable : scorer.getChildren()) {
169-
HybridQueryScorer hybridQueryScorer = getHybridQueryScorer(childScorable.child);
169+
HybridQueryScorer hybridQueryScorer = getHybridQueryScorer(childScorable.child());
170170
if (Objects.nonNull(hybridQueryScorer)) {
171171
log.debug(
172172
String.format(
173173
Locale.ROOT,
174174
"found hybrid query scorer, it's child of scorer %s",
175-
childScorable.child.getClass().getSimpleName()
175+
childScorable.child().getClass().getSimpleName()
176176
)
177177
);
178178
return hybridQueryScorer;
@@ -289,7 +289,7 @@ private void initializeLeafFieldComparators(LeafReaderContext context, int subQu
289289
private void initializeComparators(LeafReaderContext context, int subQueryNumber) throws IOException {
290290
// as all segments are sorted in the same way, enough to check only the 1st segment for indexSort
291291
if (searchSortPartOfIndexSort == null) {
292-
Sort indexSort = context.reader().getMetaData().getSort();
292+
Sort indexSort = context.reader().getMetaData().sort();
293293
searchSortPartOfIndexSort = canEarlyTerminate(sort, indexSort);
294294
if (searchSortPartOfIndexSort) {
295295
firstComparator.disableSkipping();

src/main/java/org/opensearch/neuralsearch/search/collector/HybridTopScoreDocCollector.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ private HybridQueryScorer getHybridQueryScorer(final Scorable scorer) throws IOE
7777
return (HybridQueryScorer) scorer;
7878
}
7979
for (Scorable.ChildScorable childScorable : scorer.getChildren()) {
80-
HybridQueryScorer hybridQueryScorer = getHybridQueryScorer(childScorable.child);
80+
HybridQueryScorer hybridQueryScorer = getHybridQueryScorer(childScorable.child());
8181
if (Objects.nonNull(hybridQueryScorer)) {
8282
log.debug(
8383
String.format(
8484
Locale.ROOT,
8585
"found hybrid query scorer, it's child of scorer %s",
86-
childScorable.child.getClass().getSimpleName()
86+
childScorable.child().getClass().getSimpleName()
8787
)
8888
);
8989
return hybridQueryScorer;

src/main/java/org/opensearch/neuralsearch/search/query/HybridCollectorManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ private void reduceCollectorResults(
455455
}
456456
// in this case top docs are already present in result, and we need to merge next result object with what we have.
457457
// if collector doesn't have any hits we can just skip it and save some cycles by not doing merge
458-
if (topDocsAndMaxScore.topDocs.totalHits.value == 0) {
458+
if (topDocsAndMaxScore.topDocs.totalHits.value() == 0) {
459459
return;
460460
}
461461
// we need to do actual merge because query result and current collector both have some score hits
@@ -509,7 +509,7 @@ private static HybridQuery unwrapHybridQuery(final SearchContext searchContext)
509509
// In case of nested fields and alias filter, hybrid query is wrapped under bool query and lies in the first clause.
510510
if (isHybridQueryWrappedInBooleanQuery(searchContext, searchContext.query())) {
511511
BooleanQuery booleanQuery = (BooleanQuery) query;
512-
hybridQuery = (HybridQuery) booleanQuery.clauses().get(0).getQuery();
512+
hybridQuery = (HybridQuery) booleanQuery.clauses().get(0).query();
513513
} else {
514514
hybridQuery = (HybridQuery) query;
515515
}

src/main/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcher.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ private QueryPhaseSearcher getQueryPhaseSearcher(final SearchContext searchConte
7777
protected Query extractHybridQuery(final SearchContext searchContext, final Query query) {
7878
if (isHybridQueryWrappedInBooleanQuery(searchContext, query)) {
7979
List<BooleanClause> booleanClauses = ((BooleanQuery) query).clauses();
80-
if (!(booleanClauses.get(0).getQuery() instanceof HybridQuery)) {
80+
if (!(booleanClauses.get(0).query() instanceof HybridQuery)) {
8181
throw new IllegalStateException("cannot process hybrid query due to incorrect structure of top level query");
8282
}
83-
HybridQuery hybridQuery = (HybridQuery) booleanClauses.stream().findFirst().get().getQuery();
83+
HybridQuery hybridQuery = (HybridQuery) booleanClauses.stream().findFirst().get().query();
8484
List<Query> filterQueries = booleanClauses.stream()
85-
.filter(clause -> BooleanClause.Occur.FILTER == clause.getOccur())
86-
.map(BooleanClause::getQuery)
85+
.filter(clause -> BooleanClause.Occur.FILTER == clause.occur())
86+
.map(BooleanClause::query)
8787
.collect(Collectors.toList());
8888
HybridQuery hybridQueryWithFilter = new HybridQuery(hybridQuery.getSubQueries(), filterQueries, hybridQuery.getQueryContext());
8989
return hybridQueryWithFilter;
@@ -112,7 +112,7 @@ private void validateQuery(final SearchContext searchContext, final Query query)
112112
if (query instanceof BooleanQuery) {
113113
List<BooleanClause> booleanClauses = ((BooleanQuery) query).clauses();
114114
for (BooleanClause booleanClause : booleanClauses) {
115-
validateNestedBooleanQuery(booleanClause.getQuery(), getMaxDepthLimit(searchContext));
115+
validateNestedBooleanQuery(booleanClause.query(), getMaxDepthLimit(searchContext));
116116
}
117117
}
118118
}
@@ -130,7 +130,7 @@ private void validateNestedBooleanQuery(final Query query, final int level) {
130130
}
131131
if (query instanceof BooleanQuery) {
132132
for (BooleanClause booleanClause : ((BooleanQuery) query).clauses()) {
133-
validateNestedBooleanQuery(booleanClause.getQuery(), level - 1);
133+
validateNestedBooleanQuery(booleanClause.query(), level - 1);
134134
}
135135
}
136136
}

src/main/java/org/opensearch/neuralsearch/search/query/TopDocsMerger.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public TopDocsAndMaxScore merge(final TopDocsAndMaxScore source, final TopDocsAn
8080
private static boolean isEmpty(final TopDocsAndMaxScore topDocsAndMaxScore) {
8181
if (Objects.isNull(topDocsAndMaxScore)
8282
|| Objects.isNull(topDocsAndMaxScore.topDocs)
83-
|| topDocsAndMaxScore.topDocs.totalHits.value == 0) {
83+
|| topDocsAndMaxScore.topDocs.totalHits.value() == 0) {
8484
return true;
8585
}
8686
return false;
@@ -89,11 +89,11 @@ private static boolean isEmpty(final TopDocsAndMaxScore topDocsAndMaxScore) {
8989
private TotalHits getMergedTotalHits(final TopDocsAndMaxScore source, final TopDocsAndMaxScore newTopDocs) {
9090
// merged value is a lower bound - if both are equal_to than merged will also be equal_to,
9191
// otherwise assign greater_than_or_equal
92-
TotalHits.Relation mergedHitsRelation = source.topDocs.totalHits.relation == TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO
93-
|| newTopDocs.topDocs.totalHits.relation == TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO
92+
TotalHits.Relation mergedHitsRelation = source.topDocs.totalHits.relation() == TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO
93+
|| newTopDocs.topDocs.totalHits.relation() == TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO
9494
? TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO
9595
: TotalHits.Relation.EQUAL_TO;
96-
return new TotalHits(source.topDocs.totalHits.value + newTopDocs.topDocs.totalHits.value, mergedHitsRelation);
96+
return new TotalHits(source.topDocs.totalHits.value() + newTopDocs.topDocs.totalHits.value(), mergedHitsRelation);
9797
}
9898

9999
private TopDocs getTopDocs(ScoreDoc[] mergedScoreDocs, TotalHits mergedTotalHits) {

src/main/java/org/opensearch/neuralsearch/util/HybridQueryUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static boolean hasNestedFieldOrNestedDocs(final Query query, final Searc
6161

6262
private static boolean isWrappedHybridQuery(final Query query) {
6363
return query instanceof BooleanQuery
64-
&& ((BooleanQuery) query).clauses().stream().anyMatch(clauseQuery -> clauseQuery.getQuery() instanceof HybridQuery);
64+
&& ((BooleanQuery) query).clauses().stream().anyMatch(clauseQuery -> clauseQuery.query() instanceof HybridQuery);
6565
}
6666

6767
private static boolean hasAliasFilter(final Query query, final SearchContext searchContext) {

0 commit comments

Comments
 (0)