the-algorithm/src/java/com/twitter/search/earlybird_root/mergers/PartitionResponseAccumulator.java
twitter-team ef4c5eb65e Twitter Recommendation Algorithm
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
2023-03-31 17:36:31 -05:00

45 lines
1.4 KiB
Java

package com.twitter.search.earlybird_root.mergers;
import com.twitter.search.earlybird.thrift.EarlybirdResponse;
import com.twitter.search.earlybird.thrift.EarlybirdResponseCode;
public final class PartitionResponseAccumulator extends ResponseAccumulator {
private static final String TARGET_TYPE_PARTITION = "partition";
@Override
public String getNameForLogging(int responseIndex, int numTotalResponses) {
return TARGET_TYPE_PARTITION + responseIndex;
}
@Override
public String getNameForEarlybirdResponseCodeStats(int responseIndex, int numTotalResponses) {
// We do not need to differentiate between partitions: we just want to get the number of
// responses returned by Earlybirds, for each EarlybirdResponseCode.
return TARGET_TYPE_PARTITION;
}
@Override
boolean shouldEarlyTerminateMerge(EarlyTerminateTierMergePredicate merger) {
return false;
}
@Override
public void handleSkippedResponse(EarlybirdResponseCode responseCode) { }
@Override
public void handleErrorResponse(EarlybirdResponse response) {
}
@Override
public AccumulatedResponses.PartitionCounts getPartitionCounts() {
return new AccumulatedResponses.PartitionCounts(getNumResponses(),
getSuccessResponses().size() + getSuccessfulEmptyResponseCount(), null);
}
@Override
protected boolean isMergingAcrossTiers() {
return false;
}
}