예제 #1
0
void indri::collection::Repository::close() {
  if (_collection) {
    // TODO: make sure all the indexes get deleted
    std::string manifest = "manifest";
    std::string paramPath = indri::file::Path::combine(_path, manifest);
    std::string deletedPath = indri::file::Path::combine(_path, "deleted");

    if (!_readOnly) {
      write();
      merge();
    }

    // have to stop threads after the write request,
    // so the indexes actually get written
    _stopThreads();

    if (!_readOnly) {
      if (indri::file::Path::exists(deletedPath))
        lemur_compat::remove(deletedPath.c_str());
      _deletedList.write(deletedPath);
      _writeParameters(paramPath);
    }

    _closeIndexes();
    
    _closePriors();

    delete _collection;
    _collection = 0;

    _parameters.clear(); // close/reopen will cause duplicated entries.
    _fields.clear();
    indri::utility::delete_vector_contents(_transformations);
  }
}
예제 #2
0
void XmlProxyCallback::doRequest(const std::string & sXmlText)
{
	XmlProxyCallbackPtr cb = this;

	if (!_xmlReq.SetDoc(sXmlText) || !_xmlReq.FindElem("request"))
	{
		LOG->error() << " parse xml fail" << endl;
		_sendXmlMessage("parse xml fail");
		return ;
	}
	_bHasResXml = true;
	_xmlRes.AddElem("response");
	_xmlRes.IntoElem();

	_sResponseEncode = _xmlReq.GetAttrib("charset");

	for (_xmlReq.IntoElem(); _xmlReq.FindElem(); )
	{
		if (_xmlReq.GetTagName() != "req") continue;

		MCD_STR sRequestID = _xmlReq.GetAttrib("id");
		MCD_STR sSvtName;
		MCD_STR sFunName;
		taf::JceOutputStream<taf::BufferWriter> os;
		
		for (_xmlReq.IntoElem(); _xmlReq.FindElem(); )
		{
			MCD_STR sTagName = _xmlReq.GetTagName();
			MCD_STR sTagData = _xmlReq.GetData();
			if (sTagName == "svt")
			{
				sSvtName = sTagData;
			}
			else if (sTagName == "fun")
			{
				sFunName = sTagData;
			}
			else if (sTagName == "para")
			{
				_writeParameters(os);
			}
		}
		_xmlReq.OutOfElem();

		_invoke(sRequestID, sSvtName, sFunName, os.getBuffer(), os.getLength(), cb);
	}
}
예제 #3
0
void indri::collection::Repository::_checkpoint() {
  // Write manifest and deleted list. Close and reopen collection.
  // Enable opening the checkpoint as a valid index.
  if (_collection) {    
    std::string manifest = "manifest";
    std::string paramPath = indri::file::Path::combine(_path, manifest);
    std::string deletedPath = indri::file::Path::combine(_path, "deleted");
    std::string collectionPath = indri::file::Path::combine(_path, "collection");
    if (!_readOnly) {
      _collection->reopen(collectionPath);

      if (indri::file::Path::exists(deletedPath))
        lemur_compat::remove(deletedPath.c_str());
      _deletedList.write(deletedPath);
      _writeParameters(paramPath);
    }
  }
}