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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? indexreader.cpp

?? clucene是c++版的全文檢索引擎,完全移植于lucene,采用 stl 編寫.
?? CPP
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*------------------------------------------------------------------------------
* 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.

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚洲综合一区| 欧美一级免费观看| 麻豆精品久久精品色综合| 国产欧美精品一区二区三区四区| 99re成人精品视频| 精品一区二区三区免费视频| 亚洲欧美日韩一区二区| 久久蜜桃一区二区| 欧美肥胖老妇做爰| 91蝌蚪porny九色| 黑人巨大精品欧美一区| 亚洲成av人片一区二区梦乃| 国产精品欧美极品| 欧美变态凌虐bdsm| 欧美日韩午夜在线视频| 91在线精品一区二区| 韩国一区二区视频| 日韩中文字幕区一区有砖一区| ...xxx性欧美| 日本一区免费视频| 久久这里只有精品首页| 欧美精品777| 在线视频国内自拍亚洲视频| 国产v日产∨综合v精品视频| 久久国产精品72免费观看| 一二三四社区欧美黄| 自拍偷拍欧美精品| 国产精品国产自产拍高清av王其| 欧美精品一区二区三区一线天视频| 538在线一区二区精品国产| 在线观看一区二区精品视频| 97久久超碰国产精品| 成人午夜激情影院| 粉嫩嫩av羞羞动漫久久久| 国内精品伊人久久久久av影院| 麻豆精品视频在线观看| 蜜芽一区二区三区| 麻豆精品视频在线| 精品亚洲国产成人av制服丝袜| 日本三级韩国三级欧美三级| 午夜天堂影视香蕉久久| 偷拍亚洲欧洲综合| 蜜臀久久99精品久久久久久9| 免费看日韩精品| 久久精品国产秦先生| 精品一区二区三区在线播放| 久久成人18免费观看| 精品一区二区三区在线观看国产| 精品一区二区免费看| 国产中文一区二区三区| 国产乱理伦片在线观看夜一区| 激情综合色播五月| 丁香一区二区三区| 99精品在线观看视频| 色综合天天狠狠| 欧美吻胸吃奶大尺度电影| 777精品伊人久久久久大香线蕉| 91麻豆精品91久久久久久清纯| 日韩欧美不卡在线观看视频| 337p粉嫩大胆色噜噜噜噜亚洲| 久久久精品tv| 中文字幕在线观看不卡| 亚洲乱码国产乱码精品精的特点| 亚洲精品欧美二区三区中文字幕| 亚洲成av人**亚洲成av**| 免费高清在线一区| 丁香婷婷综合激情五月色| 93久久精品日日躁夜夜躁欧美| 欧美影院精品一区| 欧美成人伊人久久综合网| 欧美激情一二三区| 一区二区三区在线观看欧美| 亚洲成人动漫精品| 国产一区二区三区免费看| av电影在线观看一区| 欧美日韩免费在线视频| 26uuu精品一区二区| 亚洲欧美怡红院| 婷婷开心激情综合| 国产成人亚洲综合a∨婷婷| 日本大香伊一区二区三区| 日韩视频一区二区三区在线播放 | 欧美精品久久久久久久久老牛影院| 欧美一级夜夜爽| 国产精品麻豆欧美日韩ww| 亚洲一二三四区不卡| 精东粉嫩av免费一区二区三区| gogogo免费视频观看亚洲一| 欧美日韩高清一区| 国产精品毛片大码女人| 天堂va蜜桃一区二区三区漫画版| 麻豆久久一区二区| 在线免费亚洲电影| 国产亚洲欧美在线| 日本欧美大码aⅴ在线播放| 成人理论电影网| 3atv在线一区二区三区| 中文字幕制服丝袜一区二区三区 | 日韩 欧美一区二区三区| 成人av在线网| 日韩欧美国产午夜精品| 亚洲色欲色欲www| 国产精品一区二区在线观看网站| 欧美日韩一区久久| 综合色中文字幕| 国产一区二区免费在线| 欧美日韩精品福利| 综合久久国产九一剧情麻豆| 国产一区二区91| 日韩区在线观看| 亚洲大片精品永久免费| 97se狠狠狠综合亚洲狠狠| 国产香蕉久久精品综合网| 蜜臀av一区二区三区| 欧美日韩一级二级| 亚洲精品中文字幕在线观看| 高清不卡一区二区在线| www国产精品av| 九九在线精品视频| 欧美一区二区在线免费观看| 亚洲不卡在线观看| 欧美三级在线视频| 一区二区三区不卡在线观看 | 欧美一区二区视频观看视频| 亚洲午夜久久久久久久久电影网| av电影天堂一区二区在线观看| 国产午夜精品一区二区| 国产在线精品一区二区夜色| 日韩欧美国产午夜精品| 日韩电影在线一区二区三区| 在线视频你懂得一区| 一区二区三区自拍| 91啦中文在线观看| 亚洲精品水蜜桃| 日本精品一级二级| 亚洲乱码国产乱码精品精的特点| 99re8在线精品视频免费播放| 国产精品污网站| 99视频精品免费视频| 综合自拍亚洲综合图不卡区| 91麻豆蜜桃一区二区三区| 亚洲素人一区二区| 日本韩国欧美一区| 亚洲一区二区综合| 8x福利精品第一导航| 日本aⅴ免费视频一区二区三区| 日韩精品一区二区三区四区视频 | 国产91丝袜在线播放| 国产日产欧产精品推荐色 | 91在线视频网址| 亚洲免费观看高清在线观看| 91成人免费在线视频| 亚洲风情在线资源站| 日韩一级高清毛片| 国模一区二区三区白浆| 国产999精品久久| 亚洲视频中文字幕| 日本道免费精品一区二区三区| 亚洲成人手机在线| 日韩欧美亚洲国产另类| 国产精品亚洲专一区二区三区| 国产精品欧美一区喷水| 色天天综合色天天久久| 日本午夜一区二区| 中文字幕乱码亚洲精品一区| 91麻豆.com| 秋霞av亚洲一区二区三| 国产午夜三级一区二区三| 91色在线porny| 五月激情综合婷婷| 日本一区二区成人| 在线视频一区二区免费| 久久精品国产99国产精品| 国产人久久人人人人爽| 欧美影院一区二区三区| 久草在线在线精品观看| 亚洲日本免费电影| 欧美一区二区三区在线观看 | 精品污污网站免费看| 精品亚洲aⅴ乱码一区二区三区| 国产精品嫩草久久久久| 欧美高清激情brazzers| 成人教育av在线| 婷婷综合五月天| 中文字幕高清一区| 在线播放中文一区| 波多野结衣中文字幕一区二区三区| 午夜精品一区二区三区电影天堂 | 国产一区二区精品久久| 一区二区三区四区不卡在线 | 国产激情一区二区三区四区 | 男人的天堂久久精品| 亚洲欧洲日本在线| 日韩欧美一区电影| 在线欧美日韩精品| 盗摄精品av一区二区三区| 日韩精品三区四区| 一区二区视频在线看| 国产欧美精品一区二区色综合| 制服丝袜在线91|