
org.elasticsearch.search.profile.SearchProfileQueryPhaseResult Maven / Gradle / Ivy
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.search.profile;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult;
import org.elasticsearch.search.profile.query.QueryProfileShardResult;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* Profile results from a shard for the search phase.
*/
public class SearchProfileQueryPhaseResult implements Writeable {
private final List queryProfileResults;
private final AggregationProfileShardResult aggProfileShardResult;
public SearchProfileQueryPhaseResult(
List queryProfileResults,
AggregationProfileShardResult aggProfileShardResult
) {
this.aggProfileShardResult = aggProfileShardResult;
this.queryProfileResults = Collections.unmodifiableList(queryProfileResults);
}
public SearchProfileQueryPhaseResult(StreamInput in) throws IOException {
int profileSize = in.readVInt();
List queryProfileResults = new ArrayList<>(profileSize);
for (int i = 0; i < profileSize; i++) {
QueryProfileShardResult result = new QueryProfileShardResult(in);
queryProfileResults.add(result);
}
this.queryProfileResults = Collections.unmodifiableList(queryProfileResults);
this.aggProfileShardResult = new AggregationProfileShardResult(in);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(queryProfileResults.size());
for (QueryProfileShardResult queryShardResult : queryProfileResults) {
queryShardResult.writeTo(out);
}
aggProfileShardResult.writeTo(out);
}
public List getQueryProfileResults() {
return queryProfileResults;
}
public AggregationProfileShardResult getAggregationProfileResults() {
return aggProfileShardResult;
}
@Override
public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
SearchProfileQueryPhaseResult other = (SearchProfileQueryPhaseResult) obj;
return queryProfileResults.equals(other.queryProfileResults) && aggProfileShardResult.equals(other.aggProfileShardResult);
}
@Override
public int hashCode() {
return Objects.hash(queryProfileResults, aggProfileShardResult);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy