Skip to content

Commit

Permalink
HACK
Browse files Browse the repository at this point in the history
  • Loading branch information
finnegancarroll committed Sep 23, 2024
1 parent 881c919 commit 64fcf30
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.proto.search.fetch.FetchSearchResultProtoDef;
import org.opensearch.search.SearchHit;
import org.opensearch.search.SearchHits;
import org.opensearch.search.SearchPhaseResult;
import org.opensearch.search.SearchShardTarget;
import org.opensearch.search.internal.ShardSearchContextId;
import org.opensearch.search.query.QuerySearchResult;

import org.opensearch.transport.protobuf.FetchSearchResultProtobuf;
import org.opensearch.transport.protobuf.SearchHitsProtobuf;

import java.io.IOException;

/**
Expand All @@ -58,12 +62,33 @@ public class FetchSearchResult extends SearchPhaseResult {

public FetchSearchResult() {}

////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////

public FetchSearchResult(StreamInput in) throws IOException {
super(in);
contextId = new ShardSearchContextId(in);
hits = new SearchHits(in);
System.out.println("FetchSearchResult In - PROTOBUF");
FetchSearchResultProtoDef.FetchSearchResultProto proto = FetchSearchResultProtoDef.FetchSearchResultProto.parseFrom(in);
hits = new SearchHitsProtobuf(proto.getHits());
}

FetchSearchResultProtoDef.FetchSearchResultProto toProto() {
FetchSearchResultProtoDef.FetchSearchResultProto.Builder builder = FetchSearchResultProtoDef.FetchSearchResultProto.newBuilder()
.setHits(new SearchHitsProtobuf(hits).toProto())
.setCounter(this.counter);
return builder.build();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
System.out.println("FetchSearchResult Out - PROTOBUF");
toProto().writeTo(out);
}

////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////

public FetchSearchResult(ShardSearchContextId id, SearchShardTarget shardTarget) {
this.contextId = id;
setSearchShardTarget(shardTarget);
Expand Down Expand Up @@ -103,10 +128,4 @@ public FetchSearchResult initCounter() {
public int counterGetAndIncrement() {
return counter++;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
contextId.writeTo(out);
hits.writeTo(out);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void fromProtobufStream(StreamInput in) throws IOException {
fromProto(proto);
}

SearchHitsProto toProto() {
public SearchHitsProto toProto() {
SearchHitsProto.Builder builder = SearchHitsProto.newBuilder().setMaxScore(maxScore);

for (SearchHit hit : hits) {
Expand Down

0 comments on commit 64fcf30

Please sign in to comment.