CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_search_FieldSortedHitQueue_ 00008 #define _lucene_search_FieldSortedHitQueue_ 00009 00010 00011 CL_CLASS_DEF(search,FieldDoc) 00012 CL_CLASS_DEF(search,SortComparatorSource) 00013 CL_CLASS_DEF(search,SortField) 00014 //#include "FieldCache.h" 00015 //#include "Sort.h" 00016 //#include "FieldDocSortedHitQueue.h" 00017 #include "FieldDoc.h" //required to expose destructor 00018 //#include "SearchHeader.h" 00019 //#include "FieldCacheImpl.h" 00020 #include "CLucene/util/PriorityQueue.h" 00021 #include "CLucene/util/Equators.h" 00022 00023 CL_CLASS_DEF(index,IndexReader) 00024 00025 CL_NS_DEF(search) 00026 00027 class hitqueueCacheReaderType; 00028 class hitqueueCacheType; 00029 class ScoreDocComparator; 00030 00038 class CLUCENE_EXPORT FieldSortedHitQueue: public CL_NS(util)::PriorityQueue<FieldDoc*, 00039 CL_NS(util)::Deletor::Object<FieldDoc> > { 00040 00041 public: //todo: remove this and below after close callback is implemented 00042 00046 static hitqueueCacheType* Comparators; 00047 static void shutdown(); 00048 private: 00049 00051 static ScoreDocComparator* lookup (CL_NS(index)::IndexReader* reader, const TCHAR* field, int32_t type, SortComparatorSource* factory); 00052 00056 static void store (CL_NS(index)::IndexReader* reader, const TCHAR* field, int32_t type, SortComparatorSource* factory, ScoreDocComparator* value); 00057 00058 00059 //todo: Locale locale, not implemented yet 00060 static ScoreDocComparator* getCachedComparator (CL_NS(index)::IndexReader* reader, 00061 const TCHAR* fieldname, int32_t type, SortComparatorSource* factory); 00062 00063 00071 static ScoreDocComparator* comparatorInt (CL_NS(index)::IndexReader* reader, const TCHAR* fieldname); 00072 00080 static ScoreDocComparator* comparatorFloat (CL_NS(index)::IndexReader* reader, const TCHAR* fieldname); 00081 00089 static ScoreDocComparator* comparatorString (CL_NS(index)::IndexReader* reader, const TCHAR* fieldname); 00090 00091 00092 //todo: 00130 static ScoreDocComparator* comparatorAuto (CL_NS(index)::IndexReader* reader, const TCHAR* fieldname); 00131 00132 00133 protected: 00135 ScoreDocComparator** comparators; 00136 int32_t comparatorsLen; 00137 00139 SortField** fields; 00140 int32_t fieldsLen; 00141 00145 float_t maxscore; 00146 00153 bool lessThan (FieldDoc* docA, FieldDoc* docB); 00154 public: 00155 00163 FieldSortedHitQueue (CL_NS(index)::IndexReader* reader, SortField** fields, int32_t size); 00164 00165 ~FieldSortedHitQueue(); 00166 00171 static void closeCallback(CL_NS(index)::IndexReader* reader, void* param); 00172 00183 FieldDoc* fillFields (FieldDoc* doc) const; 00184 00185 void setFields (SortField** fields){ 00186 this->fields = fields; 00187 } 00188 00190 SortField** getFields() { 00191 return fields; 00192 } 00193 }; 00194 00195 00196 CL_NS_END 00197 #endif