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_FieldCache_ 00008 #define _lucene_search_FieldCache_ 00009 00010 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 #include "CLucene/index/IndexReader.h" 00015 #include "Sort.h" 00016 00017 00018 CL_NS_DEF(search) 00019 00020 class FieldCacheAuto; //predefine 00021 00026 class FieldCache :LUCENE_BASE { 00027 public: 00028 virtual ~FieldCache(){ 00029 } 00030 00032 class StringIndex:LUCENE_BASE { 00033 public: 00035 TCHAR** lookup; 00036 00038 int32_t* order; 00039 00040 int count; 00041 00045 StringIndex (int32_t* values, TCHAR** lookup, int count) { 00046 this->count = count; 00047 this->order = values; 00048 this->lookup = lookup; 00049 } 00050 00051 ~StringIndex(){ 00052 _CLDELETE_ARRAY(order); 00053 00054 for ( int i=0;i<count;i++ ) 00055 _CLDELETE_CARRAY(lookup[i]); 00056 _CLDELETE_ARRAY(lookup); 00057 } 00058 }; 00059 00060 00065 static int32_t STRING_INDEX; 00066 00068 static FieldCache* DEFAULT; 00069 00079 virtual FieldCacheAuto* getInts (CL_NS(index)::IndexReader* reader, const TCHAR* field) = 0; 00080 00090 virtual FieldCacheAuto* getFloats (CL_NS(index)::IndexReader* reader, const TCHAR* field) = 0; 00091 00101 virtual FieldCacheAuto* getStrings (CL_NS(index)::IndexReader* reader, const TCHAR* field) = 0; 00102 00112 virtual FieldCacheAuto* getStringIndex (CL_NS(index)::IndexReader* reader, const TCHAR* field) = 0; 00113 00125 virtual FieldCacheAuto* getAuto (CL_NS(index)::IndexReader* reader, const TCHAR* field) = 0; 00126 00138 virtual FieldCacheAuto* getCustom (CL_NS(index)::IndexReader* reader, const TCHAR* field, SortComparator* comparator) = 0; 00139 }; 00140 00151 class FieldCacheAuto:LUCENE_BASE{ 00152 public: 00153 enum{ 00154 INT_ARRAY=1, 00155 FLOAT_ARRAY=2, 00156 STRING_INDEX=3, 00157 STRING_ARRAY=4, 00158 COMPARABLE_ARRAY=5, 00159 SORT_COMPARATOR=6, 00160 SCOREDOC_COMPARATOR=7 00161 }; 00162 00163 FieldCacheAuto(int32_t len, int32_t type); 00164 ~FieldCacheAuto(); 00166 bool ownContents; 00167 int32_t contentLen; //number of items in the list 00168 uint8_t contentType; 00169 int32_t* intArray; //item 1 00170 float_t* floatArray; //item 2 00171 FieldCache::StringIndex* stringIndex; //item 3 00172 TCHAR** stringArray; //item 4 00173 CL_NS(util)::Comparable** comparableArray; //item 5 00174 SortComparator* sortComparator; //item 6 00175 ScoreDocComparator* scoreDocComparator; //item 7 00176 00177 }; 00178 00179 00180 CL_NS_END 00181 00182 #endif