• solr深分页,游标操作分页,解决性能问题


    solr深分页,游标操作分页,解决性能问题
    

      

    @Test  
        public void pageByCursor() {  
    try {  
       solrServer.connect();  
       String query = "tablename:log_baseresult_netbehavior";  
       SolrQuery q = new SolrQuery(query);  
       q.setRows(10000000).setSort(SortClause.asc("rowkey"));  
      
      
       String cursorMark = CursorMarkParams.CURSOR_MARK_START;  
      
      
       boolean done = false;  
      
      
       long time1 = System.currentTimeMillis();  
       while (!done) {  
    q.set(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark);  
    QueryResponse qresponse = solrServer.query(q, METHOD.POST);  
      
    String nextCursorMark = qresponse.getNextCursorMark();  
      
    SolrDocumentList sList = qresponse.getResults();  
    System.out.println("---------"+sList.size());  
    /*for (SolrDocument doc : sList) { 
       Collection<String> fieldNames = doc.getFieldNames(); 
       if (fieldNames.contains("rowkey")) { 
    String rowKey = (String) doc.getFieldValue("rowkey"); 
    //System.out.println(rowKey); 
       } 
    }*/  
      
    if (cursorMark.equals(nextCursorMark)) {  
       done = true;  
    }  
    cursorMark = nextCursorMark;  
       }  
       long time2 = System.currentTimeMillis();  
       System.out.println("time:"+(time2-time1));  
    } catch (SolrServerException e) {  
       // TODO Auto-generated catch block  
       e.printStackTrace();  
    }  
        }  
    

      

  • 相关阅读:
    logging- 日志记录
    apscheduler -定时任务
    mysql
    Time-python
    pandas 常用语句
    re 正则
    sublime text3的快捷键
    git 常用操作
    tf.nn的conv2d卷积与max_pool池化
    WebApi 接口返回值类型详解 ( 转 )
  • 原文地址:https://www.cnblogs.com/firstdream/p/7732829.html
Copyright © 2020-2023  润新知