当前位置: 首页>>代码示例>>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;未经允许,请勿转载。