FirteX-高性能全文索引和检索平台API Documentation |
00001 // 00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 00003 // All rights reserved. 00004 // This file is part of FirteX (www.firtex.org) 00005 // 00006 // Use of the FirteX is subject to the terms of the software license set forth in 00007 // the LICENSE file included with this software, and also available at 00008 // http://www.firtex.org/license.html 00009 // 00010 // Author : 郭瑞杰(GuoRuijie) 00011 // Email : ruijieguo@software.ict.ac.cn,ruijieguo@gmail.com 00012 // Created : 2006/7/14 00013 // 00014 #ifndef _SORTFIELDCOMPARATOR_H 00015 #define _SORTFIELDCOMPARATOR_H 00016 00017 #if _MSC_VER > 1000 00018 #pragma once 00019 #endif // _MSC_VER > 1000 00020 00021 #include "../utility/StdHeader.h" 00022 #include "ScoreDoc.h" 00023 00024 namespace firtex 00025 { 00026 namespace search 00027 { 00028 class CSortFieldComparator 00029 { 00030 public: 00031 CSortFieldComparator(void){} 00032 virtual ~CSortFieldComparator(void){} 00033 public: 00034 virtual int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2) = 0; 00035 }; 00036 00037 class CSortFieldComparators 00038 { 00039 public: 00040 CSortFieldComparators(){} 00041 ~CSortFieldComparators(){} 00042 public: 00043 class Relevance : public CSortFieldComparator 00044 { 00045 public: 00046 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2) 00047 { 00048 if (pDoc1->m_fScore > pDoc2->m_fScore) return -1; 00049 if (pDoc1->m_fScore < pDoc2->m_fScore) return 1; 00050 return 0; 00051 } 00052 }; 00053 00054 class IndexOrder : public CSortFieldComparator 00055 { 00056 public: 00057 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2) 00058 { 00059 if (pDoc1->m_docID > pDoc2->m_docID) return -1; 00060 if (pDoc1->m_docID < pDoc2->m_docID) return 1; 00061 return 0; 00062 } 00063 }; 00064 00066 class I1 : public CSortFieldComparator 00067 { 00068 public: 00069 I1(int8_t* compArray,int32_t len); 00070 public: 00071 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00072 protected: 00073 int8_t* m_compArray; 00074 int32_t m_length; 00075 }; 00076 00078 class UI1 : public CSortFieldComparator 00079 { 00080 public: 00081 UI1(uint8_t* compArray,int32_t len); 00082 public: 00083 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00084 protected: 00085 uint8_t* m_compArray; 00086 int32_t m_length; 00087 }; 00088 00090 class I2 : public CSortFieldComparator 00091 { 00092 public: 00093 I2(int16_t* compArray,int32_t len); 00094 public: 00095 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00096 protected: 00097 int16_t* m_compArray; 00098 int32_t m_length; 00099 }; 00100 00102 class UI2 : public CSortFieldComparator 00103 { 00104 public: 00105 UI2(uint16_t* compArray,int32_t len); 00106 public: 00107 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00108 protected: 00109 uint16_t* m_compArray; 00110 int32_t m_length; 00111 }; 00112 00114 class I4 : public CSortFieldComparator 00115 { 00116 public: 00117 I4(int32_t* compArray,int32_t len); 00118 public: 00119 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00120 protected: 00121 int32_t* m_compArray; 00122 int32_t m_length; 00123 }; 00124 00126 class UI4 : public CSortFieldComparator 00127 { 00128 public: 00129 UI4(uint32_t* compArray,int32_t len); 00130 public: 00131 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00132 protected: 00133 uint32_t* m_compArray; 00134 int32_t m_length; 00135 }; 00136 00138 class I8 : public CSortFieldComparator 00139 { 00140 public: 00141 I8(int64_t* compArray,int32_t len); 00142 public: 00143 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00144 protected: 00145 int64_t* m_compArray; 00146 int32_t m_length; 00147 }; 00148 00150 class UI8 : public CSortFieldComparator 00151 { 00152 public: 00153 UI8(uint64_t* compArray,int32_t len); 00154 public: 00155 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00156 protected: 00157 uint64_t* m_compArray; 00158 int32_t m_length; 00159 }; 00160 00162 class R4 : public CSortFieldComparator 00163 { 00164 public: 00165 R4(float* compArray,int32_t len); 00166 public: 00167 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00168 protected: 00169 float* m_compArray; 00170 int32_t m_length; 00171 }; 00172 00174 class R8 : public CSortFieldComparator 00175 { 00176 public: 00177 R8(double* compArray,int32_t len); 00178 public: 00179 int32_t compare(CScoreDoc* pDoc1,CScoreDoc* pDoc2); 00180 protected: 00181 double* m_compArray; 00182 int32_t m_length; 00183 }; 00184 }; 00185 } 00186 } 00187 00188 #endif 00189
http://www.firtex.org http://www.sourceforge.net/projects/firtex