Package com.tistory.devyongsik.crescent.admin.entity

Examples of com.tistory.devyongsik.crescent.admin.entity.IndexInfo


  //TODO 호출할때마다 계산하는게 아니라, 색인시간 체크해서 보여주도록
  private Logger logger = LoggerFactory.getLogger(getClass());
   
    @Override
    public IndexInfo getIndexInfo(CrescentCollection selectCollection) throws IOException {
        IndexInfo indexInfo = new IndexInfo();

        Directory directory = FSDirectory.open(new File(selectCollection.getIndexingDirectory()));
        DirectoryReader directoryReader = DirectoryReader.open(directory);

        indexInfo.setNumOfDoc(directoryReader.numDocs());
        indexInfo.setHasDel(directoryReader.hasDeletions());
        indexInfo.setIndexVersion(directoryReader.getVersion());
        indexInfo.setSelectCollectionName(selectCollection.getName());
        indexInfo.setIndexName(selectCollection.getIndexingDirectory());

        Map<String, Long> termCountByFieldNameMap = new HashMap<String, Long>();
       
        long totalTermCount = 0L;
        long totalTermCountByField = 0L;
       
        List<String> fieldNames = new ArrayList<String>();
        for (CrescentCollectionField field : selectCollection.getFields()) {
            fieldNames.add(field.getName());
           
            totalTermCountByField = directoryReader.getSumTotalTermFreq(field.getName());
            totalTermCount += totalTermCountByField;
           
            termCountByFieldNameMap.put(field.getName(), totalTermCountByField);
        }

        indexInfo.setFieldNames(fieldNames);
        indexInfo.setNumOfField(fieldNames.size());
        indexInfo.setTermCountByFieldNameMap(termCountByFieldNameMap);
        indexInfo.setTotalTermCount(totalTermCount);
       
        try {
     
          HighFreqTermResult highFreqTermResult = getHighFreqTerms(selectCollection);
      TermStatsQueue q = highFreqTermResult.getTermStatsQueue();
     
      List<CrescentTermStats> crescentTermStatsList = new ArrayList<CrescentTermStats>();
     
      while(q.size() > 0) {
        CrescentTermStats stats = q.pop();
       
        crescentTermStatsList.add(stats);
      }
     
      Collections.sort(crescentTermStatsList, new Comparator<CrescentTermStats>() {

        @Override
        public int compare(CrescentTermStats o1, CrescentTermStats o2) {
          if (o2.getTotalTermFreq() > o1.getTotalTermFreq()) {
            return 1;
          } else if (o2.getTotalTermFreq() < o1.getTotalTermFreq()) {
            return -1;
          } else {
            return 0;
          }
        }
      });
     
      indexInfo.setCrescentTermStatsList(crescentTermStatsList);
     
    } catch (Exception e) {
      logger.error("Exception in getIndexInfo : " , e);
    }
View Full Code Here


        String selectCollectionName = collectionNames.get(0);
        CrescentCollection selectCollection = collectionHandler
                                                    .getCrescentCollections()
                                                    .getCrescentCollection(selectCollectionName);

    IndexInfo indexInfo = indexFileManageService.getIndexInfo(selectCollection);

    result.put("collectionNames", collectionNames);
    result.put("selectCollection", selectCollectionName);
    result.put("collectionNames", collectionNames);
    result.put("indexName", indexInfo.getIndexName());
    result.put("numOfField", indexInfo.getNumOfField());
    result.put("numOfDoc", indexInfo.getNumOfDoc());
    result.put("hasDel", indexInfo.isHasDel());
    result.put("indexVersion", indexInfo.getIndexVersion());
    result.put("termCountByFieldName", indexInfo.getTermCountByFieldNameMap());
    result.put("numOfTerm", indexInfo.getTotalTermCount());
    result.put("termStatsList", indexInfo.getCrescentTermStatsList());


    modelAndView.addObject("RESULT", result);
    return modelAndView;
  }
View Full Code Here

TOP

Related Classes of com.tistory.devyongsik.crescent.admin.entity.IndexInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.