當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryResponse.getQTime方法代碼示例

本文整理匯總了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;
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:27,代碼來源:QueryOperation.java

示例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);
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:15,代碼來源:FullQueryStatistic.java

示例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);
	}
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:14,代碼來源:QueryTimeHistoryStatistic.java

示例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);

}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:14,代碼來源:HistogramQueryStatistic.java

示例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++;
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:8,代碼來源:SimpleQueryStatistic.java

示例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();
  }
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:31,代碼來源:QueryLogStatistic.java

示例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);
  }
 
開發者ID:kwatters,項目名稱:solrgraph,代碼行數:41,代碼來源:QueryTest.java


注:本文中的org.apache.solr.client.solrj.response.QueryResponse.getQTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。