亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? indexreader.cpp

?? clucene是c++版的全文檢索引擎,完全移植于lucene,采用 stl 編寫.
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
* 
* Distributable under the terms of either the Apache License (Version 2.0) or 
* the GNU Lesser General Public License, as specified in the COPYING file.
------------------------------------------------------------------------------*/
#include "CLucene/StdHeader.h"
#include "IndexReader.h"

#include "CLucene/store/Directory.h"
#include "CLucene/store/FSDirectory.h"
#include "CLucene/store/Lock.h"
#include "CLucene/document/Document.h"
#include "CLucene/search/Similarity.h"
#include "SegmentInfos.h"
#include "MultiReader.h"
#include "Terms.h"

CL_NS_USE(util)
CL_NS_USE(store)
CL_NS_DEF(index)

  IndexReader::IndexReader(Directory* dir):
   directory(_CL_POINTER(dir)){
  //Constructor.
  //Func - Creates an instance of IndexReader
  //Pre  - true
  //Post - An instance has been created with writeLock = NULL

      writeLock = NULL;
      segmentInfos = NULL;
      directoryOwner = false;
      closeDirectory = false;
      stale = false;
      hasChanges = false;
  }

   IndexReader::IndexReader(Directory* directory, SegmentInfos* segmentInfos, bool closeDirectory) {
    this->directory = _CL_POINTER(directory);
    this->segmentInfos = segmentInfos;
    directoryOwner = true;
    this->closeDirectory = closeDirectory;
    stale = false;
    hasChanges = false;
    writeLock = NULL;
  }

  IndexReader::~IndexReader(){
  //Func - Destructor
  //       Destroys the instance and releases the writeLock if needed
  //Pre  - true
  //Post - The instance has been destroyed if pre(writeLock) exists is has been released
      if (writeLock != NULL) {
		  //release writeLock
          writeLock->release();
		  _CLDELETE(writeLock);
      }
	  _CLDELETE(segmentInfos);
	  _CLDECDELETE(directory);
  }

  IndexReader* IndexReader::open(const char* path){
  //Func - Static method.
  //       Returns an IndexReader reading the index in an FSDirectory in the named path. 
  //Pre  - path != NULL and contains the path of the index for which an IndexReader must be 
  //       instantiated
  //       closeDir indicates if the directory needs to be closed
  //Post - An IndexReader has been returned that reads tnhe index located at path

	  CND_PRECONDITION(path != NULL, "path is NULL");

	  Directory* dir = FSDirectory::getDirectory(path,false);
     IndexReader* reader = open(dir,true);
     //because fsdirectory will now have a refcount of 1 more than
     //if the reader had been opened with a directory object,
     //we need to do a refdec
     _CLDECDELETE(dir);
     return reader;
  }

  IndexReader* IndexReader::open( Directory* directory, bool closeDirectory){
  //Func - Static method.
  //       Returns an IndexReader reading the index in an FSDirectory in the named path. 
  //Pre  - directory represents a directory 
  //       closeDir indicates if the directory needs to be closed
  //Post - An IndexReader has been returned that reads the index located at directory

	  // in- & inter-process sync
      SCOPED_LOCK_MUTEX(directory->THIS_LOCK)
      
     IndexReader* ret = NULL;     

	  LuceneLock* lock = directory->makeLock("commit.lock");

	  //Instantiate an IndexReaderLockWith which can produce an IndexReader
      IndexReaderLockWith with(lock,directory);

	  try{
	  //Create an IndexReader reading the index
		ret = (IndexReader*)with.run();
	  }_CLFINALLY(
        _CLDELETE( lock );
	  );

	  ret->closeDirectory = closeDirectory;

	   CND_CONDITION(ret != NULL,"ret is NULL");
	   //return reference 
       return ret;
  }

  void* IndexReader::IndexReaderLockWith::doBody() {
  //Func - Reads the segmentinfo file and depending on the number of segments found
  //       it returns a SegmentsReader or a SegmentReader
  //Pre  - directory != NULL
  //Post - Depending on the number of Segments present in directory this method
  //       returns an empty SegmentsReader when there are no segments, a SegmentReader when
  //       directory contains 1 segment and a nonempty SegmentsReader when directory
  //       contains multiple segements

	   CND_PRECONDITION(directory != NULL, "directory is NULL");

	   //Instantiate SegmentInfos
       SegmentInfos* infos = _CLNEW SegmentInfos;
	   try{
			//Have SegmentInfos read the segments file in directory
			infos->read(directory);
	   }catch(...){
	        //make sure infos is cleaned up
			_CLDELETE(infos);
			throw;
	   }

       // If there is at least one segment (if infos.size() >= 1), the last
       // SegmentReader object will close the directory when the SegmentReader
       // object itself is closed (see SegmentReader::doClose).
       // If there are no segments, there will be no "last SegmentReader object"
       // to fulfill this responsibility, so we need to explicitly close the
       // directory in the segmentsreader.close
       
	   //Count the number segments in the directory
	   const uint32_t nSegs = infos->size();

       if (nSegs == 1 ) {
			// index is optimized 
            return _CLNEW SegmentReader(infos, infos->info(0));
	    }else{
			//Instantiate an array of pointers to SegmentReaders of size nSegs (The number of segments in the index)
			IndexReader** readers = NULL;

			if (nSegs > 0){
				uint32_t infosize=infos->size();
				readers = _CL_NEWARRAY(IndexReader*,infosize+1);
				for (uint32_t i = 0; i < infosize; i++) {
					//Instantiate a SegementReader responsible for reading the i-th segment and store it in
					//the readers array
					readers[i] = _CLNEW SegmentReader(infos->info(i));
				}
				readers[infosize] = NULL;
			}

			//return an instance of SegmentsReader which is a reader that manages all Segments
			return _CLNEW MultiReader(directory, infos, readers);
        }// end if
  }

  uint64_t IndexReader::lastModified(const char* directory) {
  //Func - Static method
  //       Returns the time the index in the named directory was last modified. 
  //Pre  - directory != NULL and contains the path name of the directory to check
  //Post - The last modified time of the index has been returned

      CND_PRECONDITION(directory != NULL, "directory is NULL");

	  return FSDirectory::fileModified(directory,"segments");
  }

  int64_t IndexReader::getCurrentVersion(Directory* directory) {
     return SegmentInfos::readCurrentVersion(directory);
  }


   int64_t IndexReader::getCurrentVersion(const char* directory){
      Directory* dir = FSDirectory::getDirectory(directory, false);
      int64_t version = getCurrentVersion(dir);
	  dir->close();
      _CLDECDELETE(dir);
      return version;
   }
    
  uint64_t IndexReader::lastModified(const Directory* directory) {
  //Func - Static method
  //       Returns the time the index in this directory was last modified. 
  //Pre  - directory contains a valid reference
  //Post - The last modified time of the index has been returned

      return directory->fileModified("segments");
  }


  bool IndexReader::indexExists(const char* directory){
  //Func - Static method
  //       Checks if an index exists in the named directory
  //Pre  - directory != NULL
  //Post - Returns true if an index exists at the specified directory->
  //       If the directory does not exist or if there is no index in it.
  //       false is returned.

       CND_PRECONDITION(directory != NULL, "directory is NULL");

	   //Create a buffer of length CL_MAXDIR
       char f[CL_MAX_PATH+10]; //add 10 in case that directory is already 260 long
	   //Copy the directory string to the buffer
       strcpy(f,directory);
	   //Cat the name of the segments to buffer
       strcat(f, "/segments");
	   //Check if the segments file exists
       return Misc::dir_Exists(f);
  }
    

  void IndexReader::setNorm(int32_t doc, const TCHAR* field, uint8_t value){
    SCOPED_LOCK_MUTEX(THIS_LOCK)
    if(directoryOwner)
      aquireWriteLock();
    doSetNorm(doc, field, value);
    hasChanges = true;
  }

 void IndexReader::aquireWriteLock() {
    if (stale)
      _CLTHROWA(CL_ERR_IO,"IndexReader out of date and no longer valid for delete, undelete, or setNorm operations");

    if (writeLock == NULL) {
      LuceneLock* writeLock = directory->makeLock("write.lock");
      if (!writeLock->obtain(LUCENE_WRITE_LOCK_TIMEOUT)) // obtain write lock
       _CLTHROWA(CL_ERR_IO,"Index locked for write"); // + writeLock
      this->writeLock = writeLock;

      // we have to check whether index has changed since this reader was opened.
      // if so, this reader is no longer valid for deletion
      if (SegmentInfos::readCurrentVersion(directory) > segmentInfos->getVersion()) {
        stale = true;
        this->writeLock->release();
        _CLDELETE(this->writeLock);
        _CLTHROWA(CL_ERR_IO,"IndexReader out of date and no longer valid for delete, undelete, or setNorm operations");
      }
    }
  }
  

  void IndexReader::setNorm(int32_t doc, const TCHAR* field, float_t value){
     setNorm(doc, field, CL_NS(search)::Similarity::encodeNorm(value));
  }

  bool IndexReader::indexExists(const Directory* directory){
  //Func - Static method
  //       Checks if an index exists in the directory
  //Pre  - directory is a valid reference
  //Post - Returns true if an index exists at the specified directory->
  //       If the directory does not exist or if there is no index in it.
  //       false is returned.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久综合九色综合欧美就去吻| 久久久三级国产网站| 国产在线日韩欧美| 一区二区高清视频在线观看| 精品国产三级a在线观看| 色婷婷精品久久二区二区蜜臀av| 国产一区二区久久| 视频一区视频二区中文字幕| 国产精品久久久久久久久久久免费看| 欧美一区二区三区免费| 91在线国产观看| 国产福利不卡视频| 蜜臀av一级做a爰片久久| 亚洲一区二区成人在线观看| 国产精品传媒在线| 国产亚洲欧美日韩俺去了| 91麻豆精品国产91久久久久| 在线观看一区日韩| 9i看片成人免费高清| 国产激情精品久久久第一区二区 | 毛片不卡一区二区| 亚洲18色成人| 亚洲自拍欧美精品| 亚洲综合区在线| 1024国产精品| 亚洲欧洲美洲综合色网| 久久色.com| 精品久久久久一区二区国产| 欧美肥大bbwbbw高潮| 欧美日韩黄色影视| 欧美日韩一级二级三级| 欧美视频精品在线观看| 日本韩国欧美在线| 欧美在线free| 欧美性猛交xxxxxx富婆| 欧美日韩三级视频| 欧美日高清视频| 欧美二区在线观看| 日韩亚洲欧美在线| 欧美videos大乳护士334| 日韩一区二区三区电影在线观看| 欧美高清你懂得| 欧美一级夜夜爽| 精品福利一区二区三区免费视频| 日韩女优制服丝袜电影| 欧美成人a视频| 久久影院电视剧免费观看| 久久久久久久综合日本| 国产女人aaa级久久久级 | 欧美一区二区在线看| 777色狠狠一区二区三区| 91精品国产色综合久久不卡电影| 欧美一卡2卡3卡4卡| 日韩欧美国产wwwww| 精品理论电影在线观看| 久久精品人人爽人人爽| 国产精品污污网站在线观看| 国产精品久久久久久福利一牛影视| 中文在线免费一区三区高中清不卡| 中文字幕中文字幕在线一区 | 成人免费在线播放视频| 日韩毛片高清在线播放| 一区二区三区视频在线看| 婷婷久久综合九色综合绿巨人| 青青草原综合久久大伊人精品优势| 精油按摩中文字幕久久| 丁香婷婷综合激情五月色| 色综合天天综合给合国产| 69精品人人人人| 国产亚洲精品久| 一区二区三区在线观看欧美 | 91视频在线观看免费| 欧美日韩一二区| 国产亚洲一本大道中文在线| 最新国产精品久久精品| 图片区小说区国产精品视频| 久久99热国产| 色婷婷激情一区二区三区| 555www色欧美视频| 国产精品蜜臀在线观看| 亚洲与欧洲av电影| 国产精品1024久久| 欧美男女性生活在线直播观看| 精品成人在线观看| 亚洲精品免费看| 久久99久久久久| 91免费看片在线观看| 精品国产乱码久久久久久图片 | 天天色天天操综合| 成人午夜视频福利| 欧美一区二区三区在| 亚洲欧洲性图库| 久久99国产精品免费| 91官网在线观看| 国产欧美精品国产国产专区| 丝袜诱惑亚洲看片| 97超碰欧美中文字幕| 精品剧情v国产在线观看在线| 一区二区三区精密机械公司| 精品亚洲porn| 欧美性大战久久| 中文字幕免费不卡| 国产在线视频一区二区三区| 欧美色图免费看| 国产欧美视频一区二区三区| 久久精品噜噜噜成人88aⅴ| 日本久久电影网| 国产精品毛片大码女人| 国产美女久久久久| 日韩精品专区在线影院观看| 亚洲国产sm捆绑调教视频| av在线播放成人| 中文字幕av一区二区三区高| 国产综合色精品一区二区三区| 这里只有精品视频在线观看| 亚洲免费观看高清| www.欧美色图| 国产精品进线69影院| 国产成人精品影视| 国产日韩欧美a| 国产乱妇无码大片在线观看| 欧美mv和日韩mv国产网站| 青青草国产成人av片免费| 欧美老女人在线| 日韩中文字幕一区二区三区| 欧美探花视频资源| 亚洲国产另类精品专区| 欧美在线免费观看亚洲| 亚洲乱码国产乱码精品精可以看| 成人小视频在线观看| 国产午夜一区二区三区| 国产精品一区三区| 国产亚洲福利社区一区| 国产大陆亚洲精品国产| 国产性天天综合网| 成人app在线| 亚洲视频在线一区观看| 色综合久久久网| 亚洲永久精品国产| 欧美喷水一区二区| 麻豆国产精品777777在线| 精品福利一二区| 国产成人精品网址| 国产精品国产自产拍高清av王其 | 56国语精品自产拍在线观看| 丝袜亚洲另类欧美| 欧美一区二区视频在线观看| 精久久久久久久久久久| 久久九九全国免费| 91在线免费视频观看| 一区av在线播放| 欧美高清dvd| 国产一区二区剧情av在线| 国产欧美综合在线观看第十页| www.欧美日韩国产在线| 亚洲一区二区三区自拍| 日韩三级在线免费观看| 国产精品小仙女| 亚洲嫩草精品久久| 欧美精品在线视频| 国产一区二区在线视频| 国产精品色噜噜| 欧美色窝79yyyycom| 久色婷婷小香蕉久久| 国产精品天干天干在线综合| 在线视频一区二区三区| 蜜乳av一区二区| 国产精品三级av| 欧美午夜宅男影院| 国产在线不卡一区| 亚洲少妇屁股交4| 欧美一区二区三区免费大片| 国产suv精品一区二区883| 一区二区日韩av| 久久久午夜电影| 欧美日韩在线不卡| 国产成人激情av| 亚洲成人资源网| 国产色婷婷亚洲99精品小说| 日本高清无吗v一区| 久久国产精品99久久久久久老狼 | 成人午夜av在线| 亚洲18女电影在线观看| 国产婷婷色一区二区三区四区| 91黄色在线观看| 国产麻豆9l精品三级站| 亚洲一区二区三区在线看| 欧美va亚洲va| 欧美在线一区二区| 国产成人午夜精品影院观看视频| 亚洲最大成人网4388xx| 久久网这里都是精品| 欧美妇女性影城| 在线视频你懂得一区二区三区| 国产乱码精品一区二区三| 婷婷国产在线综合| 亚洲精品你懂的| 国产精品福利在线播放| 精品国产91九色蝌蚪| 欧美人xxxx|