mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-01 00:38:46 +02:00
ef4c5eb65e
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.
30 lines
1.1 KiB
Java
30 lines
1.1 KiB
Java
package com.twitter.search.common.util.earlybird;
|
|
|
|
import com.twitter.search.common.query.thriftjava.CollectorParams;
|
|
import com.twitter.search.earlybird.thrift.EarlybirdRequest;
|
|
import com.twitter.search.earlybird.thrift.ThriftSearchQuery;
|
|
|
|
/**
|
|
* Utility class from constructing ThriftSearchQuery.
|
|
*/
|
|
public final class ThriftSearchQueryUtil {
|
|
private ThriftSearchQueryUtil() { }
|
|
|
|
/**
|
|
* Convenience methods for constructing a ThriftSearchQuery.
|
|
*/
|
|
public static ThriftSearchQuery newSearchQuery(String serializedQuery, int numResults) {
|
|
ThriftSearchQuery searchQuery = new ThriftSearchQuery();
|
|
searchQuery.setSerializedQuery(serializedQuery);
|
|
searchQuery.setCollectorParams(new CollectorParams().setNumResultsToReturn(numResults));
|
|
return searchQuery;
|
|
}
|
|
|
|
/** Determines if the given request was initiated by a logged in user. */
|
|
public static boolean requestInitiatedByLoggedInUser(EarlybirdRequest request) {
|
|
ThriftSearchQuery searchQuery = request.getSearchQuery();
|
|
return (searchQuery != null) && searchQuery.isSetSearcherId()
|
|
&& (searchQuery.getSearcherId() > 0);
|
|
}
|
|
}
|