Skip to content

Commit

Permalink
Optimizing code
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Jain <[email protected]>
  • Loading branch information
vibrantvarun committed Jan 17, 2024
1 parent a3ef808 commit a523130
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.opensearch.core.xcontent.ToXContent.EMPTY_PARAMS;
import org.opensearch.index.query.MatchAllQueryBuilder;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.index.query.QueryShardContext;
import org.opensearch.index.query.TermQueryBuilder;
import org.opensearch.index.query.QueryBuilderVisitor;
import static org.opensearch.index.query.AbstractQueryBuilder.BOOST_FIELD;
import static org.opensearch.index.query.AbstractQueryBuilder.DEFAULT_BOOST;
import static org.opensearch.knn.index.query.KNNQueryBuilder.FILTER_FIELD;
Expand Down Expand Up @@ -42,18 +48,12 @@
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.index.mapper.TextFieldMapper;
import org.opensearch.index.query.MatchAllQueryBuilder;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.index.query.QueryShardContext;
import org.opensearch.index.query.TermQueryBuilder;
import org.opensearch.knn.index.VectorDataType;
import org.opensearch.knn.index.mapper.KNNVectorFieldMapper;
import org.opensearch.knn.index.query.KNNQuery;
import org.opensearch.knn.index.query.KNNQueryBuilder;
import org.opensearch.neuralsearch.util.NeuralSearchClusterTestUtils;
import org.opensearch.neuralsearch.util.NeuralSearchClusterUtil;
import static org.opensearch.neuralsearch.TestUtils.createTestVisitor;

import com.carrotsearch.randomizedtesting.RandomizedTest;

Expand Down Expand Up @@ -713,7 +713,7 @@ public void testBoost_whenDefaultBoostSet_thenBuildSuccessfully() {
public void testVisit() {
HybridQueryBuilder hybridQueryBuilder = new HybridQueryBuilder().add(new NeuralQueryBuilder()).add(new NeuralSparseQueryBuilder());
List<QueryBuilder> visitedQueries = new ArrayList<>();
hybridQueryBuilder.visit(createTestVisitor(visitedQueries));
hybridQueryBuilder.visit(QueryBuilderVisitor.NO_OP_VISITOR);
assertEquals(3, visitedQueries.size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.index.query.QueryBuilderVisitor;
import static org.opensearch.test.OpenSearchTestCase.randomFloat;

import java.util.ArrayList;
Expand Down Expand Up @@ -312,8 +310,4 @@ public static String getModelId(Map<String, Object> pipeline, String processor)

return (String) textEmbeddingProcessor.get("model_id");
}

public static QueryBuilderVisitor createTestVisitor(List<QueryBuilder> visitedQueries) {
return QueryBuilderVisitor.NO_OP_VISITOR;
}
}

0 comments on commit a523130

Please sign in to comment.