io.pinecone.unsigned_indices_model.QueryResponseWithUnsignedIndices Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pinecone-client Show documentation
Show all versions of pinecone-client Show documentation
The Pinecone.io Java Client
package io.pinecone.unsigned_indices_model;
import io.pinecone.proto.QueryResponse;
import io.pinecone.proto.ScoredVector;
import io.pinecone.proto.Usage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class QueryResponseWithUnsignedIndices {
private List matches;
private String namespace;
private Usage usage;
public QueryResponseWithUnsignedIndices(QueryResponse queryResponse) {
if (queryResponse == null) {
this.matches = Collections.emptyList();
this.namespace = "";
this.usage = null;
} else {
this.matches = convertToScoredVectorWithUnsignedIndices(queryResponse.getMatchesList());
this.namespace = queryResponse.getNamespace();
this.usage = queryResponse.getUsage();
}
}
public List getMatchesList() {
return matches;
}
public ScoredVectorWithUnsignedIndices getMatches(int index) {
return matches.get(index);
}
public List convertToScoredVectorWithUnsignedIndices(List matches) {
if (matches == null) {
throw new IllegalArgumentException("Matches list cannot be null.");
}
List scoredVectorList = new ArrayList<>(matches.size());
for (ScoredVector scoredVector : matches) {
scoredVectorList.add(new ScoredVectorWithUnsignedIndices(scoredVector));
}
return scoredVectorList;
}
public void setMatches(List matches) {
this.matches = matches;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public Usage getUsage() { return usage; }
public void setUsage(Usage usage) { this.usage = usage; }
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("class QueryResponseWithUnsignedIndices {").append("\n");
sb.append(" matches: ").append(toIndentedString(matches)).append("\n");
sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n");
sb.append(" usage: ").append(usage).append("\n");
sb.append("}");
return sb.toString();
}
}