Skip to content

Commit

Permalink
Removing commons lang3 dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Dec 7, 2024
1 parent e4e56cd commit 33846a4
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 255 deletions.
1 change: 0 additions & 1 deletion opensearch-search-quality-evaluation-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ dependencies {
compileOnly "org.apache.httpcomponents:httpcore:${versions.httpcore}"
compileOnly "org.apache.httpcomponents:httpclient:${versions.httpclient}"
compileOnly "commons-logging:commons-logging:${versions.commonslogging}"
implementation "org.apache.commons:commons-lang3:3.17.0"
implementation "com.google.code.gson:gson:2.11.0"
yamlRestTestImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}"
}
Expand Down

This file was deleted.

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
package org.opensearch.eval;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.index.IndexRequest;
Expand Down Expand Up @@ -113,7 +112,7 @@ public void runJob(final ScheduledJobParameter jobParameter, final JobExecutionC
final long startTime = System.currentTimeMillis();
final long judgments;

if(StringUtils.equalsIgnoreCase(searchQualityEvaluationJobParameter.getClickModel(), "coec")) {
if("coec".equalsIgnoreCase(searchQualityEvaluationJobParameter.getClickModel())) {

LOGGER.info("Beginning implicit judgment generation using clicks-over-expected-clicks.");
final CoecClickModelParameters coecClickModelParameters = new CoecClickModelParameters(true, searchQualityEvaluationJobParameter.getMaxRank());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.opensearch.rest.RestResponse;

import java.io.IOException;
import java.nio.charset.Charset;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
Expand Down Expand Up @@ -174,7 +175,7 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
}

// Get the query JSON from the content.
final String query = new String(BytesReference.toBytes(request.content()));
final String query = new String(BytesReference.toBytes(request.content()), Charset.defaultCharset());

// Validate the query has a QUERY_PLACEHOLDER.
if(!query.contains(QUERY_PLACEHOLDER)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
package org.opensearch.eval.judgments.model;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.opensearch.eval.judgments.util.MathUtils;

/**
Expand Down Expand Up @@ -42,18 +41,6 @@ public ClickthroughRate(final String objectId, final int clicks, final int event
this.events = events;
}

@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}

@Override
public int hashCode() {
int result = 17;
result = 29 * result + objectId.hashCode();
return result;
}

@Override
public String toString() {
return "object_id: " + objectId + ", clicks: " + clicks + ", events: " + events + ", ctr: " + MathUtils.round(getClickthroughRate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
*/
package org.opensearch.eval.judgments.model;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.eval.judgments.util.MathUtils;
Expand Down Expand Up @@ -106,21 +104,6 @@ public String toString() {
return "query_id: " + queryId + ", query: " + query + ", document: " + document + ", judgment: " + MathUtils.round(judgment);
}

@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).
append(queryId).
append(query).
append(document).
append(judgment).
toHashCode();
}

/**
* Gets the judgment's query ID.
* @return The judgment's query ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
package org.opensearch.eval.judgments.model.ubi.query;

import com.google.gson.annotations.SerializedName;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.Map;

Expand Down Expand Up @@ -47,20 +45,6 @@ public UbiQuery() {

}

@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).
append(queryId).
append(userQuery).
append(clientId).
toHashCode();
}

/**
* Gets the timestamp for the query.
* @return The timestamp for the query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ public final Collection<Map<String, Long>> getQuerySet(final String querySetId)
// Will be at most one match.
sourceBuilder.from(0);
sourceBuilder.size(1);
sourceBuilder.trackTotalHits(true);

final SearchRequest searchRequest = new SearchRequest(SearchQualityEvaluationPlugin.QUERY_SETS_INDEX_NAME).source(sourceBuilder);

// TODO: Don't use .get()
final SearchResponse searchResponse = client.search(searchRequest).get();

if(searchResponse.getHits().getTotalHits().value > 0) {
if(searchResponse.getHits().getHits().length > 0) {

// The queries from the query set that will be run.
return (Collection<Map<String, Long>>) searchResponse.getHits().getAt(0).getSourceAsMap().get("queries");
Expand Down

0 comments on commit 33846a4

Please sign in to comment.