예제 #1
0
	CLuceneError::CLuceneError(int num, const char* str, bool ownstr)
	{
		error_number = num;
		_awhat=STRDUP_AtoA(str);
		_twhat=NULL;
		if ( ownstr )
			_CLDELETE_CaARRAY(str);
    }
예제 #2
0
파일: Misc.cpp 프로젝트: zipang29/rss
std::string Misc::toString(const TCHAR* s, int32_t len){
  if ( s == NULL || len == 0 ) return "";
  if ( len < 0 ) len = _tcslen(s);
  char* buf = _CL_NEWARRAY(char,len+1);
  STRCPY_WtoA(buf,s,len+1);
  string ret = buf;
  _CLDELETE_CaARRAY(buf);
  return ret;
}
예제 #3
0
  bool MMapIndexInput::open(const char* path, IndexInput*& ret, CLuceneError& error, int32_t __bufferSize )    {

	//Func - Constructor.
	//       Opens the file named path
	//Pre  - path != NULL
	//Post - if the file could not be opened  an exception is thrown.

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

    Internal* _internal = _CLNEW Internal;

#if defined(_CL_HAVE_FUNCTION_MAPVIEWOFFILE)
	  _internal->mmaphandle = NULL;
	  _internal->fhandle = CreateFileA(path,GENERIC_READ,FILE_SHARE_READ, 0,OPEN_EXISTING,0,0);
	  
	  //Check if a valid fhandle was retrieved
	  if (_internal->fhandle < 0){
		_cl_dword_t err = GetLastError();
        if ( err == ERROR_FILE_NOT_FOUND )
        error.set(CL_ERR_IO, "File does not exist");
        else if ( err == ERROR_ACCESS_DENIED )
        error.set(CL_ERR_IO, "File Access denied");
        else if ( err == ERROR_TOO_MANY_OPEN_FILES )
        error.set(CL_ERR_IO, "Too many open files");
		else
          error.set(CL_ERR_IO, "Could not open file");
	  }

	  _cl_dword_t dummy=0;
	  _internal->_length = GetFileSize(_internal->fhandle, &dummy);

	  if ( _internal->_length > 0 ){
			_internal->mmaphandle = CreateFileMappingA(_internal->fhandle,NULL,PAGE_READONLY,0,0,NULL);
			if ( _internal->mmaphandle != NULL ){
				void* address = MapViewOfFile(_internal->mmaphandle,FILE_MAP_READ,0,0,0);
				if ( address != NULL ){
					_internal->data = (uint8_t*)address;
          ret = _CLNEW MMapIndexInput(_internal);
          return true;
				}
			}
			
			//failure:
			int errnum = GetLastError(); 
			
			CloseHandle(_internal->mmaphandle);
	
			char* lpMsgBuf=strerror(errnum);
			size_t len = strlen(lpMsgBuf)+80;
			char* errstr = _CL_NEWARRAY(char, len); 
			cl_sprintf(errstr, len, "MMapIndexInput::MMapIndexInput failed with error %d: %s", errnum, lpMsgBuf); 
	
	    error.set(CL_ERR_IO, errstr);
			_CLDELETE_CaARRAY(errstr);
	  }
예제 #4
0
FieldsReader::FieldsReader(Directory* d, const char* segment, FieldInfos* fn):
	fieldInfos(fn)
{
//Func - Constructor
//Pre  - d contains a valid reference to a Directory
//       segment != NULL
//       fn contains a valid reference to a FieldInfos
//Post - The instance has been created

	CND_PRECONDITION(segment != NULL, "segment != NULL");

	const char* buf = Misc::segmentname(segment,".fdt");
	fieldsStream = d->openInput( buf );
	_CLDELETE_CaARRAY( buf );

	buf = Misc::segmentname(segment,".fdx");
	indexStream = d->openInput( buf );
	_CLDELETE_CaARRAY( buf );

	_size = (int32_t)indexStream->length()/8;
}
double lucene_tcstod(const TCHAR *value, TCHAR **end){
    int32_t len = _tcslen(value)+1;
    char* avalue=_CL_NEWARRAY(char,len);
    char* aend=NULL;
    STRCPY_TtoA(avalue,value,len);
    
    double ret = strtod(avalue,&aend);
    *end=(TCHAR*)value+(aend-avalue);
    _CLDELETE_CaARRAY(avalue);

    return ret;
}
예제 #6
0
SegmentMerger::~SegmentMerger(){
//Func - Destructor
//Pre  - true
//Post - The instance has been destroyed
    
	//Clear the readers set
	readers.clear();

	//Delete field Infos
	_CLDELETE(fieldInfos);     
	//Close and destroy the IndexOutput to the Frequency File
	if (freqOutput != NULL){ 
		freqOutput->close(); 
		_CLDELETE(freqOutput); 
	}
	//Close and destroy the IndexOutput to the Prox File
	if (proxOutput != NULL){
		proxOutput->close(); 
		_CLDELETE(proxOutput); 
	}
	//Close and destroy the termInfosWriter
	if (termInfosWriter != NULL){
		termInfosWriter->close(); 
		_CLDELETE(termInfosWriter); 
	}
	//Close and destroy the queue
	if (queue != NULL){
		queue->close(); 
		_CLDELETE(queue);
	}
	//close and destory the skipBuffer
	if ( skipBuffer != NULL ){
		skipBuffer->close();
		_CLDELETE(skipBuffer);
	}

	_CLDELETE_CaARRAY(segment);
}
예제 #7
0
	CLuceneError::~CLuceneError() throw(){
		_CLDELETE_CARRAY(_twhat);
		_CLDELETE_CaARRAY(_awhat);
	}