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_FieldDocSortedHitQueue_ 00008 #define _lucene_search_FieldDocSortedHitQueue_ 00009 00010 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 #include "Sort.h" 00015 #include "CLucene/util/PriorityQueue.h" 00016 00017 CL_NS_DEF(search) 00018 00019 00035 class FieldDoc: LUCENE_BASE { 00036 public: 00037 //FieldDoc did inherit from ScoreDoc, but now we make the scoredoc a member 00038 struct ScoreDoc scoreDoc; 00039 00047 CL_NS(util)::Comparable** fields; 00048 00050 FieldDoc (int32_t doc, float_t score); 00052 FieldDoc (int32_t doc, float_t score, CL_NS(util)::Comparable** fields); 00053 ~FieldDoc(); 00054 }; 00055 00060 class FieldDocSortedHitQueue: 00061 public CL_NS(util)::PriorityQueue<FieldDoc*,CL_NS(util)::Deletor::Object<FieldDoc> > 00062 { 00063 private: 00064 DEFINE_MUTEX(THIS_LOCK) 00065 00066 // this cannot contain AUTO fields - any AUTO fields should 00067 // have been resolved by the time this class is used. 00068 SortField** fields; 00069 int32_t fieldsLen; 00070 00071 void _countsize(){ 00072 fieldsLen=0; 00073 while(fields[fieldsLen]!=NULL) 00074 fieldsLen++; 00075 } 00076 00077 // used in the case where the fields are sorted by locale 00078 // based strings 00079 //todo: not implemented in clucene because locales has not been implemented 00080 //Collator[] collators; //volatile 00081 00082 public: 00088 FieldDocSortedHitQueue (SortField** fields, int32_t size); 00089 ~FieldDocSortedHitQueue(); 00090 00091 00100 void setFields (SortField** fields); 00101 00103 SortField** getFields() { 00104 return fields; 00105 } 00106 00123 protected: 00130 bool lessThan (FieldDoc* docA, FieldDoc* docB); 00131 }; 00132 00133 00139 class TopFieldDocs: public TopDocs { 00140 public: 00142 SortField** fields; 00143 00144 FieldDoc** fieldDocs; 00145 00153 TopFieldDocs (int32_t totalHits, FieldDoc** fieldDocs, int32_t scoreDocsLen, SortField** fields); 00154 ~TopFieldDocs(); 00155 }; 00156 00157 CL_NS_END 00158 #endif 00159