the-algorithm/src/java/com/twitter/search/common/query/StaticHitAttributeProvider.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

33 lines
823 B
Java

package com.twitter.search.common.query;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* A hit attribute provider based on the static data
*/
public class StaticHitAttributeProvider implements HitAttributeProvider {
private int currentDocId;
private Map<Integer, List<String>> currentHitAttr;
public StaticHitAttributeProvider() {
}
/**
* Set a fake last doc id and hit attribution, this is only used to generate explanation.
*/
public void setCurrentHitAttr(int docId, Map<Integer, List<String>> hitAttr) {
this.currentDocId = docId;
this.currentHitAttr = hitAttr;
}
@Override
public Map<Integer, List<String>> getHitAttribution(int docId) {
if (docId == currentDocId) {
return currentHitAttr;
}
return Collections.EMPTY_MAP;
}
}