本文整理匯總了Java中org.apache.solr.client.solrj.response.QueryResponse.getQTime方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryResponse.getQTime方法的具體用法?Java QueryResponse.getQTime怎麽用?Java QueryResponse.getQTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.response.QueryResponse
的用法示例。
在下文中一共展示了QueryResponse.getQTime方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
public boolean execute() {
SolrQuery query = queryGenerator.generate();
try {
logger.debug("executing query: " + query);
long init = System.nanoTime();
QueryResponse response = this.executeQuery(query);
long clientTime = (System.nanoTime() - init)/1000000;
if (response.getGroupResponse() != null) {
for (GroupCommand command : response.getGroupResponse().getValues()) {
logger.debug(command.getNGroups() + " groups found for " + command.getName() + " in " + response.getQTime() + " ms");
}
} else {
logger.debug(response.getResults().getNumFound() + " results found in " + response.getQTime() + " ms");
}
if(response.getQTime() < 0) {
throw new RuntimeException("The query returned less than 0 as q time: " + response.getResponseHeader().get("q") + response.getQTime());
}
executor.notifyQueryExecuted(response, clientTime);
} catch (SolrServerException e) {
logger.error("Error on Query " + query);
e.printStackTrace();
executor.notifyError(new QueryException(e, query));
return false;
}
return true;
}
示例2: onExecutedQuery
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
@Override
public void onExecutedQuery(QueryResponse response, long clientTime) {
sortedQueryTimes.add(response.getQTime());
totalQTime+=response.getQTime();
long mapKey = new Date().getTime();
Integer actualValue = queryTimeByDate.get(mapKey);
Integer newValue;
if(actualValue == null) {
newValue = response.getQTime();
}else {
newValue = actualValue + response.getQTime();
}
queryTimeByDate.put(mapKey, newValue);
}
示例3: onExecutedQuery
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
@Override
public void onExecutedQuery(QueryResponse response, long clientTime) {
int qTime = response.getQTime();
Date date = getNewDate();
long second = (date.getTime()/1000L)/precision;
if(queriesPerInterval.containsKey(second)) {
queriesPerInterval.put(second, queriesPerInterval.get(second) + 1);
timePerInterval.put(second, timePerInterval.get(second) + qTime);
} else {
queriesPerInterval.put(second, 1);
timePerInterval.put(second, qTime);
}
}
示例4: onExecutedQuery
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
@Override
public void onExecutedQuery(QueryResponse response, long clientTime) {
long time = response.getQTime() / HISTOGRAM_INTERVAL;
int cant;
if(histogram.containsKey(time)) {
cant = histogram.get(time);
cant++;
}else {
cant = 1;
}
histogram.put(time, cant);
}
示例5: onExecutedQuery
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
@Override
public void onExecutedQuery(QueryResponse response, long clientTime) {
long qTime = response.getQTime();
this.totalQTime+=qTime;
this.totalClientTime+=clientTime;
this.totalQueries++;
}
示例6: QueryLogValue
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public QueryLogValue(QueryResponse response) {
Object parameter;
error = false;
NamedList<Object> params = (NamedList<Object>)response.getResponseHeader().get("params");
if(params!=null) {
parameter = params.get("q");
if (parameter != null) {
queryString = parameter.toString();
}
parameter = params.get("fq");
if (parameter != null) {
filterQueryString = parameter.toString();
}
}
facetQueryString = createFacetQuery(response.getFacetFields());
qTime = response.getQTime();
if (response.getGroupResponse() != null) {
results = new Long(0);
for (GroupCommand command : response.getGroupResponse().getValues()) {
if (command.getNGroups() != null) {
results += command.getNGroups();
}
}
} else {
results = response.getResults().getNumFound();
}
}
示例7: main
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
public static void main(String[] args) {
String solrUrl = "http://localhost:8983/solr";
SolrServer solrServer = new HttpSolrServer( solrUrl );
int numQueries = 1000;
long totalTime = 0;
long maxTime = 0;
long maxCount = 0;
long largestResultSet = 0;
for (int id = 0 ; id < numQueries; id++) {
ModifiableSolrParams params = new ModifiableSolrParams();
String queryString = "id:doc_"+id;
params.add("q", queryString);
params.add("defType", "graph");
params.add("rows", "0");
QueryResponse qresp;
try {
qresp = solrServer.query(params);
} catch (SolrServerException e) {
// throw new RuntimeException();
System.out.println(e.getLocalizedMessage());
e.printStackTrace();
break;
}
long numFound = qresp.getResults().getNumFound();
int qTime = qresp.getQTime();
System.out.println("Query " + queryString + " Found " + numFound + " in " + qTime + "ms.");
totalTime += qTime;
if (qTime > maxTime) {
maxTime = qTime;
maxCount = numFound;
}
if (numFound > largestResultSet) {
largestResultSet = numFound;
}
}
long avgTime = totalTime / numQueries;
System.out.println("Total Time : " + totalTime + " AVG: " + avgTime);
System.out.println("Max Time : " + maxTime + " Num: " + maxCount);
System.out.println("Largest Result Set : " + largestResultSet);
}