You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(25) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(125) |
Feb
(23) |
Mar
(167) |
Apr
(2) |
May
|
Jun
(19) |
Jul
(304) |
Aug
(181) |
Sep
(189) |
Oct
(145) |
Nov
(110) |
Dec
(44) |
2006 |
Jan
(303) |
Feb
(40) |
Mar
(2) |
Apr
(143) |
May
|
Jun
(74) |
Jul
(31) |
Aug
(7) |
Sep
(21) |
Oct
(33) |
Nov
(102) |
Dec
(36) |
2007 |
Jan
|
Feb
(16) |
Mar
(38) |
Apr
(34) |
May
(3) |
Jun
(4) |
Jul
(4) |
Aug
(13) |
Sep
(5) |
Oct
|
Nov
|
Dec
|
2008 |
Jan
(2) |
Feb
|
Mar
(13) |
Apr
|
May
(18) |
Jun
(48) |
Jul
(136) |
Aug
(45) |
Sep
(21) |
Oct
(32) |
Nov
|
Dec
(9) |
2009 |
Jan
(4) |
Feb
|
Mar
(33) |
Apr
(23) |
May
(6) |
Jun
(3) |
Jul
(11) |
Aug
|
Sep
(5) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ust...@us...> - 2008-10-02 14:29:03
|
Revision: 2912 http://clucene.svn.sourceforge.net/clucene/?rev=2912&view=rev Author: ustramooner Date: 2008-10-02 14:28:52 +0000 (Thu, 02 Oct 2008) Log Message: ----------- cleanup... added cl_min3 for various new functions cleaned up lucene_utf8towc and lucene_utf8charlen function Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/store/IndexInput.cpp branches/lucene2_3_2/src/demo/Main.cpp branches/lucene2_3_2/src/shared/CLucene/_SharedHeader.h branches/lucene2_3_2/src/shared/CLucene/config/gunichartables.cpp branches/lucene2_3_2/src/shared/CLucene/config/repl_wchar.h branches/lucene2_3_2/src/shared/CLucene/config/utf8.cpp branches/lucene2_3_2/src/test/testall.cpp Removed Paths: ------------- branches/lucene2_3_2/src/core/CLucene/store/_IndexInput.h Modified: branches/lucene2_3_2/src/core/CLucene/store/IndexInput.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/store/IndexInput.cpp 2008-10-02 14:21:51 UTC (rev 2911) +++ branches/lucene2_3_2/src/core/CLucene/store/IndexInput.cpp 2008-10-02 14:28:52 UTC (rev 2912) @@ -241,23 +241,5 @@ } -IndexInputStream::IndexInputStream(IndexInput* input){ - this->input = input; - this->size = input->length(); - this->position = input->getFilePointer(); -} -IndexInputStream::~IndexInputStream(){ -} -int32_t IndexInputStream::fillBuffer(char* start, int32_t space){ - int64_t avail = input->length()-input->getFilePointer(); - if ( avail == 0 ) - return -1; - else if ( avail<space ) - space = (int32_t)avail; - - input->readBytes((uint8_t*)start,space); - return space; -} - CL_NS_END Deleted: branches/lucene2_3_2/src/core/CLucene/store/_IndexInput.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/store/_IndexInput.h 2008-10-02 14:21:51 UTC (rev 2911) +++ branches/lucene2_3_2/src/core/CLucene/store/_IndexInput.h 2008-10-02 14:28:52 UTC (rev 2912) @@ -1,31 +0,0 @@ -/*------------------------------------------------------------------------------ -* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team -* -* Distributable under the terms of either the Apache License (Version 2.0) or -* the GNU Lesser General Public License, as specified in the COPYING file. -------------------------------------------------------------------------------*/ -#ifndef _lucene_store_Internal_IndexInput_ -#define _lucene_store_Internal_IndexInput_ - -#include "CLucene/LuceneThreads.h" -#include "CLucene/util/_bufferedstream.h" - -CL_NS_DEF(store) - - /** - * JStream InputStream which reads from an IndexInput. This class is - * used by the FieldReader to create binary fields. You can then use - * a GZipInputStream to read compressed data or any of the other - * JStream stream types. - * todo: should we really use Buffered? isn't the underlying stream buffered enough? - */ - class IndexInputStream: public jstreams::BufferedInputStream{ - IndexInput* input; - public: - IndexInputStream(IndexInput* input); - ~IndexInputStream(); - int32_t fillBuffer(_stg_byte_t* start, int32_t space); - }; - -CL_NS_END -#endif Modified: branches/lucene2_3_2/src/demo/Main.cpp =================================================================== --- branches/lucene2_3_2/src/demo/Main.cpp 2008-10-02 14:21:51 UTC (rev 2911) +++ branches/lucene2_3_2/src/demo/Main.cpp 2008-10-02 14:28:52 UTC (rev 2912) @@ -11,7 +11,7 @@ //test for memory leaks: #ifdef _MSC_VER #ifdef _DEBUG - #define CRTDBG_MAP_ALLOC + #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #endif @@ -29,13 +29,11 @@ int main( int32_t argc, char** argv ){ //Dumper Debug - #ifdef TR_LEAKS - #ifdef _CLCOMPILER_MSVC + #ifdef _MSC_VER #ifdef _DEBUG _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );//| _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF ); #endif #endif - #endif uint64_t str = Misc::currentTimeMillis(); try{ @@ -63,21 +61,12 @@ _lucene_shutdown(); //clears all static memory //print lucenebase debug -#ifdef LUCENE_ENABLE_MEMLEAKTRACKING - lucene::debug::LuceneBase::__cl_PrintUnclosedObjects(); - //clear memtracking memory (not the unclosed objects) - lucene::debug::LuceneBase::__cl_ClearMemory(); -#endif + //Debuggin techniques: //For msvc, use this for breaking on memory leaks: // _crtBreakAlloc - //to break at this clucene item: - // _lucene_counter_break - //run a memory check before deleting objects: - // _lucene_run_objectcheck - //if LUCENE_ENABLE_CONSTRUCTOR_LOG is on, dont do log if this is true: - // _lucene_disable_debuglogging + //for linux, use valgrind printf ("\n\nTime taken: %d\n\n",Misc::currentTimeMillis() - str); return 0; Modified: branches/lucene2_3_2/src/shared/CLucene/_SharedHeader.h =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/_SharedHeader.h 2008-10-02 14:21:51 UTC (rev 2911) +++ branches/lucene2_3_2/src/shared/CLucene/_SharedHeader.h 2008-10-02 14:28:52 UTC (rev 2912) @@ -22,8 +22,10 @@ #include "CLucene/config/repl_tchar.h" #include "CLucene/config/repl_wchar.h" -#define cl_min(a,b) (a>b?b:a) -#define cl_max(a,b) (a>b?a:b) +#define cl_min(a,b) ((a)>(b) ? (b) : (a)) +#define cl_min3(a,b,c) ((a)<(b) ? ((a)<(c) ? (a) : (c)) : ((b)<(c) ? (b) : (c))) +#define cl_max(a,b) ((a)>(b) ? (a): (b)) +#define cl_max3(a,b,c) ((a)>(b) ? ((a)>(c) ? (a) : (c)) : ((b)>(c) ? (b) : (c))) #ifdef _CL_HAVE_SAFE_CRT #define cl_sprintf sprintf_s Modified: branches/lucene2_3_2/src/shared/CLucene/config/gunichartables.cpp =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/config/gunichartables.cpp 2008-10-02 14:21:51 UTC (rev 2911) +++ branches/lucene2_3_2/src/shared/CLucene/config/gunichartables.cpp 2008-10-02 14:28:52 UTC (rev 2912) @@ -232,7 +232,7 @@ { const gchar *p = special_case_table + val - 0x1000000; wchar_t ret=0; - lucene_utf8towc(&ret,p,6); + lucene_utf8towc(ret,p); #ifdef _UCS2 return ret; #else @@ -273,7 +273,7 @@ const gchar *p = special_case_table + val - 0x1000000; wchar_t ret=0; - lucene_utf8towc(&ret,p,6); + lucene_utf8towc(ret,p); #ifdef _UCS2 return ret; #else @@ -330,7 +330,7 @@ if (ch == casefold_table[half].ch) { wchar_t ret=0; - lucene_utf8towc(&ret,casefold_table[half].data,6); + lucene_utf8towc(ret,casefold_table[half].data); #ifdef _UCS2 return ret; Modified: branches/lucene2_3_2/src/shared/CLucene/config/repl_wchar.h =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/config/repl_wchar.h 2008-10-02 14:21:51 UTC (rev 2911) +++ branches/lucene2_3_2/src/shared/CLucene/config/repl_wchar.h 2008-10-02 14:28:52 UTC (rev 2912) @@ -20,11 +20,11 @@ CLUCENE_SHARED_EXPORT TCHAR* cl_tcscasefold( TCHAR * str, int len=-1 ); //we provide utf8 conversion functions -CLUCENE_SHARED_EXPORT size_t lucene_utf8towc (wchar_t *ret, const char *s, size_t n); +CLUCENE_SHARED_EXPORT size_t lucene_utf8towc (wchar_t& ret, const char *s); CLUCENE_SHARED_EXPORT size_t lucene_utf8towcs(wchar_t *, const char *, size_t maxslen); CLUCENE_SHARED_EXPORT size_t lucene_wctoutf8 (char * ret, const wchar_t str); CLUCENE_SHARED_EXPORT size_t lucene_wcstoutf8 (char *, const wchar_t *, size_t maxslen); -CLUCENE_SHARED_EXPORT size_t lucene_utf8charlen(const char *p); +CLUCENE_SHARED_EXPORT size_t lucene_utf8charlen(const unsigned char p); //< the number of characters that this first utf8 character will expect //string function replacements #if defined(LUCENE_USE_INTERNAL_CHAR_FUNCTIONS) || (defined(_UCS2) && !defined(_CL_HAVE_FUNCTION_WCSCASECMP)) || (defined(_ASCII) && !defined(_CL_HAVE_FUNCTION_STRCASECMP)) Modified: branches/lucene2_3_2/src/shared/CLucene/config/utf8.cpp =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/config/utf8.cpp 2008-10-02 14:21:51 UTC (rev 2911) +++ branches/lucene2_3_2/src/shared/CLucene/config/utf8.cpp 2008-10-02 14:28:52 UTC (rev 2912) @@ -173,9 +173,9 @@ * valid Unicode characters, you should use lucene_utf8towc_validated() * instead. * - * Return value: the resulting character + * Return value: the number of p consumed for the character **/ -size_t lucene_utf8towc(wchar_t *pwc, const char *p, size_t n) +size_t lucene_utf8towc(wchar_t& pwc, const char *p) { int i, mask = 0; int result; @@ -187,7 +187,7 @@ return 0; UTF8_GET (result, p, i, mask, len); - *pwc = result; + pwc = result; return len; } @@ -210,7 +210,7 @@ wchar_t *rp = result; while (rp < result + result_length && *sp!=0){ - size_t r = lucene_utf8towc(rp,sp,6); + size_t r = lucene_utf8towc(*rp,sp); if ( r == -1 ) return 0; sp += r; @@ -225,11 +225,10 @@ } //get the number of bytes that make up the utf8 character. //this function was not taken from gnome -size_t lucene_utf8charlen(const char *p) +size_t lucene_utf8charlen(const unsigned char c) { int mask = 0; int len=0; - unsigned char c = (unsigned char) *p; UTF8_COMPUTE (c, mask, len); return len; Modified: branches/lucene2_3_2/src/test/testall.cpp =================================================================== --- branches/lucene2_3_2/src/test/testall.cpp 2008-10-02 14:21:51 UTC (rev 2911) +++ branches/lucene2_3_2/src/test/testall.cpp 2008-10-02 14:28:52 UTC (rev 2912) @@ -4,17 +4,17 @@ * Distributable under the terms of either the Apache License (Version 2.0) or * the GNU Lesser General Public License, as specified in the COPYING file. ------------------------------------------------------------------------------*/ -#include "test.h" - -//test for memory leaks: +//msvc test for memory leaks: #ifdef _MSC_VER -#ifdef _DEBUG - #define CRTDBG_MAP_ALLOC - #include <stdlib.h> - #include <crtdbg.h> -#endif -#endif + #ifdef _DEBUG + #define _CRTDBG_MAP_ALLOC + #include <stdlib.h> + #include <crtdbg.h> + #endif +#endif +#include "test.h" + #include <fcntl.h> #ifdef _CL_HAVE_DIRECT_H #include <direct.h> @@ -32,9 +32,10 @@ int main(int argc, char *argv[]) { - #ifdef _CLCOMPILER_MSVC + #ifdef _MSC_VER #ifdef _DEBUG - _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );// | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF ); + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); //| _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF ); + _crtBreakAlloc=-1; #endif #endif int ret_result = 0; @@ -202,12 +203,6 @@ _lucene_shutdown(); //clears all static memory //print lucenebase debug -#ifdef LUCENE_ENABLE_MEMLEAKTRACKING - CL_NS(debug)::LuceneBase::__cl_PrintUnclosedObjects(); - //clear memtracking memory (not the unclosed objects) - CL_NS(debug)::LuceneBase::__cl_ClearMemory(); -#endif - if ( ret_result != 0 ) return ret_result; @@ -217,11 +212,6 @@ //Debuggin techniques: //For msvc, use this for breaking on memory leaks: // _crtBreakAlloc - //to break at this clucene item: - // _lucene_counter_break - //run a memory check before deleting objects: - // _lucene_run_objectcheck - //if LUCENE_ENABLE_CONSTRUCTOR_LOG is on, dont do log if this is true: - // _lucene_disable_debuglogging + //for linux, use valgrind } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-10-02 14:23:15
|
Revision: 2911 http://clucene.svn.sourceforge.net/clucene/?rev=2911&view=rev Author: ustramooner Date: 2008-10-02 14:21:51 +0000 (Thu, 02 Oct 2008) Log Message: ----------- The locking mechanism was using openInput and throwing errors. I think it's bad to throw errors when no error occurred. A new overload allows the result to be returned without any real exception being thrown. Backwards compatible with an overload in Directory. CLuceneError needed to be modified to modify the error object Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/debug/error.cpp branches/lucene2_3_2/src/core/CLucene/debug/error.h Modified: branches/lucene2_3_2/src/core/CLucene/debug/error.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/debug/error.cpp 2008-10-02 14:19:05 UTC (rev 2910) +++ branches/lucene2_3_2/src/core/CLucene/debug/error.cpp 2008-10-02 14:21:51 UTC (rev 2911) @@ -17,6 +17,11 @@ #warning "==================Lucene exceptions are disabled==================" #endif #else + CLuceneError::CLuceneError(){ + error_number = 0; + _awhat = NULL; + _twhat = NULL; + } CLuceneError::CLuceneError(int num, const char* str, bool ownstr) { error_number = num; @@ -60,6 +65,23 @@ return _twhat; } + void CLuceneError::set(int num, const char* str, bool ownstr){ + _CLDELETE_CARRAY(_twhat); + _CLDELETE_CaARRAY(_awhat); + _awhat=STRDUP_AtoA(str); + error_number = num; + if ( ownstr ) + _CLDELETE_CaARRAY(str); + } + void CLuceneError::set(int num, const TCHAR* str, bool ownstr){ + _CLDELETE_CARRAY(_twhat); + _CLDELETE_CaARRAY(_awhat); + _twhat=STRDUP_TtoT(str); + error_number = num; + if ( ownstr ) + _CLDELETE_CARRAY(str); + } + #ifndef _ASCII CLuceneError::CLuceneError(int num, const TCHAR* str, bool ownstr) { Modified: branches/lucene2_3_2/src/core/CLucene/debug/error.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/debug/error.h 2008-10-02 14:19:05 UTC (rev 2910) +++ branches/lucene2_3_2/src/core/CLucene/debug/error.h 2008-10-02 14:21:51 UTC (rev 2911) @@ -56,19 +56,23 @@ #else class CLUCENE_EXPORT CLuceneError { - int error_number; char* _awhat; TCHAR* _twhat; + int error_number; public: + CLuceneError(); CLuceneError(const CLuceneError& clone); CLuceneError(int num, const char* str, bool ownstr); #ifdef _UCS2 CLuceneError(int num, const TCHAR* str, bool ownstr); #endif int number(){return error_number;} - char* what(); - TCHAR* twhat(); - ~CLuceneError() throw(); + char* what(); + TCHAR* twhat(); + ~CLuceneError() throw(); + + void set(int num, const char*, bool ownstr=false); + void set(int num, const TCHAR*, bool ownstr=false); }; //#define _THROWS //does nothing This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-10-02 14:20:53
|
Revision: 2908 http://clucene.svn.sourceforge.net/clucene/?rev=2908&view=rev Author: ustramooner Date: 2008-10-02 14:18:10 +0000 (Thu, 02 Oct 2008) Log Message: ----------- Changed document(Document*) overload to document(Document&). This makes more sense to describe the function as copying data into the variable. Backwards compatibility is maintained through the IndexReader implementing the original prototype. Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.cpp branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.h branches/lucene2_3_2/src/core/CLucene/index/IndexReader.cpp branches/lucene2_3_2/src/core/CLucene/index/IndexReader.h branches/lucene2_3_2/src/core/CLucene/index/MultiReader.cpp branches/lucene2_3_2/src/core/CLucene/index/MultiReader.h branches/lucene2_3_2/src/core/CLucene/index/SegmentReader.cpp branches/lucene2_3_2/src/core/CLucene/search/IndexSearcher.cpp branches/lucene2_3_2/src/core/CLucene/search/IndexSearcher.h Modified: branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.cpp 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.cpp 2008-10-02 14:18:10 UTC (rev 2908) @@ -241,7 +241,7 @@ CL_NS(document)::Document* IndexModifier::document(const int32_t n){ Document* ret = _CLNEW Document; - if (!document(n,ret) ) + if (!document(n, *ret) ) _CLDELETE(ret); return ret; } @@ -249,6 +249,12 @@ SCOPED_LOCK_MUTEX(directory->THIS_LOCK) assureOpen(); createIndexReader(); + return indexReader->document(n, *doc); +} +bool IndexModifier::document(int32_t n, CL_NS(document)::Document& doc){ + SCOPED_LOCK_MUTEX(directory->THIS_LOCK) + assureOpen(); + createIndexReader(); return indexReader->document(n, doc); } CL_NS(store)::Directory* IndexModifier::getDirectory(){ Modified: branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.h 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.h 2008-10-02 14:18:10 UTC (rev 2908) @@ -312,7 +312,8 @@ * while using the TermDocs. If the IndexReader that the modifier manages * is closed, the Document will be invalid */ - bool document(const int32_t n, CL_NS(document)::Document* doc); + bool document(const int32_t n, CL_NS(document)::Document& doc); + _CL_DEPRECATED( document(i, Document&) )bool document(const int32_t n, CL_NS(document)::Document* doc); _CL_DEPRECATED( document(i, document) ) CL_NS(document)::Document* document(const int32_t n); /** Modified: branches/lucene2_3_2/src/core/CLucene/index/IndexReader.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/IndexReader.cpp 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/index/IndexReader.cpp 2008-10-02 14:18:10 UTC (rev 2908) @@ -183,7 +183,7 @@ CL_NS(document)::Document* IndexReader::document(const int32_t n){ CL_NS(document)::Document* ret = _CLNEW CL_NS(document)::Document; - if (!document(n,ret) ) + if (!document(n,*ret) ) _CLDELETE(ret); return ret; } @@ -367,6 +367,14 @@ return _termPositions; } + bool IndexReader::getTermFreqVectors(int32_t docNumber, Array<TermFreqVector*>& result){ + return this->getTermFreqVectors(docNumber, result); + } + + bool IndexReader::document(int32_t n, CL_NS(document)::Document* doc){ + return document(n, *doc); + } + void IndexReader::deleteDoc(const int32_t docNum){ deleteDocument(docNum); } Modified: branches/lucene2_3_2/src/core/CLucene/index/IndexReader.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/IndexReader.h 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/index/IndexReader.h 2008-10-02 14:18:10 UTC (rev 2908) @@ -309,7 +309,9 @@ * The fields are not cleared before retrieving the document, so the * object should be new or just cleared. */ - virtual bool document(int32_t n, CL_NS(document)::Document*) =0; + virtual bool document(int32_t n, CL_NS(document)::Document&) =0; + + _CL_DEPRECATED( document(i, Document&) ) bool document(int32_t n, CL_NS(document)::Document*); _CL_DEPRECATED( document(i, document) ) CL_NS(document)::Document* document(const int32_t n); Modified: branches/lucene2_3_2/src/core/CLucene/index/MultiReader.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/MultiReader.cpp 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/index/MultiReader.cpp 2008-10-02 14:18:10 UTC (rev 2908) @@ -129,7 +129,7 @@ return internal->_maxDoc; } -bool MultiReader::document(int32_t n, CL_NS(document)::Document* doc){ +bool MultiReader::document(int32_t n, CL_NS(document)::Document& doc){ int32_t i = readerIndex(n); // find segment num return subReaders[i]->document(n - starts[i],doc); // dispatch to segment reader } Modified: branches/lucene2_3_2/src/core/CLucene/index/MultiReader.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/MultiReader.h 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/index/MultiReader.h 2008-10-02 14:18:10 UTC (rev 2908) @@ -67,7 +67,7 @@ int32_t maxDoc() const; - bool document(int32_t n, CL_NS(document)::Document* doc); + bool document(int32_t n, CL_NS(document)::Document& doc); bool isDeleted(const int32_t n); bool hasDeletions() const; Modified: branches/lucene2_3_2/src/core/CLucene/index/SegmentReader.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/SegmentReader.cpp 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/index/SegmentReader.cpp 2008-10-02 14:18:10 UTC (rev 2908) @@ -453,7 +453,7 @@ return tis->terms(t); } - bool SegmentReader::document(int32_t n, Document* doc) { + bool SegmentReader::document(int32_t n, Document& doc) { //Func - writes the fields of document n into doc //Pre - n >=0 and identifies the document n //Post - if the document has been deleted then an exception has been thrown Modified: branches/lucene2_3_2/src/core/CLucene/search/IndexSearcher.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/search/IndexSearcher.cpp 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/search/IndexSearcher.cpp 2008-10-02 14:18:10 UTC (rev 2908) @@ -176,7 +176,7 @@ } // inherit javadoc - bool IndexSearcher::doc(int32_t i, CL_NS(document)::Document* d) { + bool IndexSearcher::doc(int32_t i, CL_NS(document)::Document& d) { //Func - Retrieves i-th document found // For use by HitCollector implementations. //Pre - reader != NULL @@ -186,7 +186,17 @@ return reader->document(i,d); } + bool IndexSearcher::doc(int32_t i, CL_NS(document)::Document* d) { + //Func - Retrieves i-th document found + // For use by HitCollector implementations. + //Pre - reader != NULL + //Post - The i-th document has been returned + CND_PRECONDITION(reader != NULL, "reader is NULL"); + + return reader->document(i,*d); + } + // inherit javadoc int32_t IndexSearcher::maxDoc() const { //Func - Return total number of documents including the ones marked deleted Modified: branches/lucene2_3_2/src/core/CLucene/search/IndexSearcher.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/search/IndexSearcher.h 2008-10-02 14:17:48 UTC (rev 2907) +++ branches/lucene2_3_2/src/core/CLucene/search/IndexSearcher.h 2008-10-02 14:18:10 UTC (rev 2908) @@ -63,6 +63,7 @@ int32_t docFreq(const CL_NS(index)::Term* term) const; + bool doc(int32_t i, CL_NS(document)::Document& document); bool doc(int32_t i, CL_NS(document)::Document* document); _CL_DEPRECATED( doc(i, document) ) CL_NS(document)::Document* doc(int32_t i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-10-02 14:19:30
|
Revision: 2907 http://clucene.svn.sourceforge.net/clucene/?rev=2907&view=rev Author: ustramooner Date: 2008-10-02 14:17:48 +0000 (Thu, 02 Oct 2008) Log Message: ----------- Removed jstreams namespace (and most of the jstreams code, or made them private). Jstreams was the old namespace for Strigi streams. Since we can't have dependencies in the core, using the Strigi namespace is not possible. To use Strigi, use the contribs package. A class will be created soon to easily use Strigi classes. InputStream and Reader are almost exact clones of jstreams (some changes were necessary for Reader use). It will be easy to have a Filter class which passes calls onto Strigi. pass readLine a buffer length BufferedReader is a reader which can be reset. Readers don't have to be resetable. Classes which need reset ability now ask for a BufferedReader Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.cpp branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.h branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardAnalyzer.h branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardTokenizer.cpp branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardTokenizer.h branches/lucene2_3_2/src/core/CLucene/document/Field.cpp branches/lucene2_3_2/src/core/CLucene/document/Field.h branches/lucene2_3_2/src/core/CLucene/index/DocumentWriter.cpp branches/lucene2_3_2/src/core/CLucene/queryParser/Lexer.cpp branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParser.cpp branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParser.h branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParserBase.cpp branches/lucene2_3_2/src/core/CLucene/queryParser/_Lexer.h branches/lucene2_3_2/src/core/CLucene/util/_FastCharStream.h branches/lucene2_3_2/src/core/CLucene.h branches/lucene2_3_2/src/core/CMakeLists.txt branches/lucene2_3_2/src/demo/IndexFiles.cpp Added Paths: ----------- branches/lucene2_3_2/src/core/CLucene/util/CLStreams.h branches/lucene2_3_2/src/core/CLucene/util/_bufferedstream.h branches/lucene2_3_2/src/core/CLucene/util/_streambase.h branches/lucene2_3_2/src/core/CLucene/util/_streambuffer.h Removed Paths: ------------- branches/lucene2_3_2/src/core/CLucene/util/bufferedstream.h branches/lucene2_3_2/src/core/CLucene/util/fileinputstream.cpp branches/lucene2_3_2/src/core/CLucene/util/fileinputstream.h branches/lucene2_3_2/src/core/CLucene/util/inputstreambuffer.h branches/lucene2_3_2/src/core/CLucene/util/jstreamsconfig.h branches/lucene2_3_2/src/core/CLucene/util/streambase.h branches/lucene2_3_2/src/core/CLucene/util/stringreader.h branches/lucene2_3_2/src/core/CLucene/util/subinputstream.h Modified: branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.cpp 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.cpp 2008-10-02 14:17:48 UTC (rev 2907) @@ -35,7 +35,7 @@ TCHAR c; offset++; if (bufferIndex >= dataLen) { - dataLen = input->read(ioBuffer, LUCENE_IO_BUFFER_SIZE); + dataLen = input->read(ioBuffer, 1, LUCENE_IO_BUFFER_SIZE ); if (dataLen == -1) dataLen = 0; bufferIndex = 0; @@ -504,7 +504,7 @@ int32_t rd; const TCHAR* buffer=0; while (true) { - rd = input->read(buffer, bufferSize); + rd = input->read(buffer, 1, bufferSize); if (rd == -1) break; token->growBuffer(token->_termTextLen +rd+1); @@ -577,7 +577,7 @@ TCHAR* word = NULL; try { word = _CL_NEWARRAY(TCHAR, LUCENE_DEFAULT_TOKEN_BUFFER_SIZE); - while (reader->readLine(word) > 0) { + while (reader->readLine(word, LUCENE_DEFAULT_TOKEN_BUFFER_SIZE) > 0) { stopTable->insert( STRDUP_TtoT(CL_NS(util)::Misc::wordTrim(word))); } } Modified: branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -11,7 +11,7 @@ # pragma once #endif -#include "CLucene/util/Reader.h" +#include "CLucene/util/CLStreams.h" #include "AnalysisHeader.h" #include "CLucene/util/VoidMapSetDefinitions.h" Modified: branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardAnalyzer.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardAnalyzer.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardAnalyzer.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -9,7 +9,7 @@ //#include "CLucene/util/VoidMap.h" -CL_CLASS_DEF(util,Reader) +CL_CLASS_DEF(util,BufferedReader) #include "CLucene/analysis/AnalysisHeader.h" #include "CLucene/util/VoidMapSetDefinitions.h" //#include "CLucene/analysis/Analyzers.h" Modified: branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardTokenizer.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardTokenizer.cpp 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardTokenizer.cpp 2008-10-02 14:17:48 UTC (rev 2907) @@ -92,7 +92,7 @@ #define CONTAINS_ANY(sb, ofThese) (_tcscspn(sb.getBuffer(), _T(ofThese)) != static_cast<size_t>(sb.len)) - StandardTokenizer::StandardTokenizer(Reader* reader): + StandardTokenizer::StandardTokenizer(BufferedReader* reader): /* rdPos is zero-based. It starts at -1, and will advance to the first ** position when readChar() is first called. */ rdPos(-1), Modified: branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardTokenizer.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardTokenizer.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/analysis/standard/StandardTokenizer.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -11,7 +11,7 @@ #include "../AnalysisHeader.h" //required for Tokenizer #include "StandardTokenizerConstants.h" CL_CLASS_DEF(analysis,Token) -CL_CLASS_DEF(util,Reader) +CL_CLASS_DEF(util,BufferedReader) CL_CLASS_DEF(util,StringBuffer) CL_CLASS_DEF(util,FastCharStream) @@ -53,7 +53,7 @@ CL_NS(util)::FastCharStream* rd; // Constructs a tokenizer for this Reader. - StandardTokenizer(CL_NS(util)::Reader* reader); + StandardTokenizer(CL_NS(util)::BufferedReader* reader); ~StandardTokenizer(); Modified: branches/lucene2_3_2/src/core/CLucene/document/Field.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/document/Field.cpp 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/document/Field.cpp 2008-10-02 14:17:48 UTC (rev 2907) @@ -8,23 +8,12 @@ #include "Field.h" #include "CLucene/util/_StringIntern.h" #include "CLucene/util/StringBuffer.h" -#include "CLucene/util/Reader.h" +#include "CLucene/util/CLStreams.h" +#include "CLucene/analysis/AnalysisHeader.h" CL_NS_USE(util) CL_NS_DEF(document) -/* -struct Field::Internal{ - //const TCHAR* _name; - //TCHAR* _stringValue; - //CL_NS(util)::Reader* _readerValue; - //jstreams::StreamBase<char>* _streamValue; - //void* fieldsData; - - //uint32_t config; - //float_t boost; -};*/ - Field::Field(const TCHAR* Name, Reader* reader, int config): /*_internal(new Internal),*/ lazy(false) { @@ -75,7 +64,7 @@ setConfig(_config); } -Field::Field(const TCHAR* Name, jstreams::StreamBase<char>* Value, int config): +Field::Field(const TCHAR* Name, InputStream* Value, int config): /*_internal(new Internal),*/ lazy(false) { CND_PRECONDITION(Name != NULL, "Name cannot be NULL"); @@ -122,7 +111,7 @@ const TCHAR* Field::name() const { return _name; } ///<returns reference TCHAR* Field::stringValue() const { return (valueType & VALUE_STRING) ? static_cast<TCHAR*>(fieldsData) : NULL; } ///<returns reference Reader* Field::readerValue() const { return (valueType & VALUE_READER) ? static_cast<Reader*>(fieldsData) : NULL; } ///<returns reference -jstreams::StreamBase<char>* Field::streamValue() const { return (valueType & VALUE_STREAM) ? static_cast<jstreams::StreamBase<char>*>(fieldsData) : NULL; } ///<returns reference +InputStream* Field::streamValue() const { return (valueType & VALUE_STREAM) ? static_cast<InputStream*>(fieldsData) : NULL; } ///<returns reference CL_NS(analysis)::TokenStream* Field::tokenStreamValue() const { return (valueType & VALUE_TOKENSTREAM) ? static_cast<CL_NS(analysis)::TokenStream*>(fieldsData) : NULL; } bool Field::isStored() const { return (config & STORE_YES) != 0; } @@ -154,7 +143,7 @@ fieldsData = value; valueType = VALUE_READER; } -void Field::setValue(jstreams::StreamBase<char>* value) { +void Field::setValue(InputStream* value) { _resetValue(); fieldsData = value; valueType = VALUE_STREAM; @@ -311,7 +300,7 @@ Reader* r = static_cast<Reader*>(fieldsData); _CLDELETE(r); } else if (valueType & VALUE_STREAM) { - jstreams::StreamBase<char>* v = static_cast<jstreams::StreamBase<char>*>(fieldsData); + InputStream* v = static_cast<InputStream*>(fieldsData); _CLVDELETE(v); } valueType=VALUE_NONE; Modified: branches/lucene2_3_2/src/core/CLucene/document/Field.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/document/Field.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/document/Field.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -18,11 +18,8 @@ */ CL_CLASS_DEF(util,Reader) +CL_CLASS_DEF(util,InputStream) CL_CLASS_DEF(analysis,TokenStream) -namespace jstreams{ - template <class T> - class StreamBase; -} CL_NS_DEF(document) /** @@ -151,7 +148,7 @@ /** * Stream constructor of Field. */ - Field(const TCHAR* name, jstreams::StreamBase<char>* stream, int _config); + Field(const TCHAR* name, CL_NS(util)::InputStream* stream, int _config); Field(const TCHAR* name, int _config); ///<No value, for lazy loading support ~Field(); @@ -173,7 +170,7 @@ /** The value of the field as a String, or null. If null, the String value * or Reader value is used. Exactly one of stringValue(), readerValue() and * streamValue() must be set. */ - jstreams::StreamBase<char>* streamValue() const; + CL_NS(util)::InputStream* streamValue() const; /** The value of the field as a TokesStream, or null. If null, the Reader value, * String value, or binary value is used. Exactly one of stringValue(), @@ -301,7 +298,7 @@ void setValue(CL_NS(util)::Reader* value); /** Expert: change the value of this field. See <a href="#setValue(TCHAR*)">setValue(TCHAR*)</a>. */ - void setValue(jstreams::StreamBase<char>* value) ; + void setValue(CL_NS(util)::InputStream* value) ; /** Expert: change the value of this field. See <a href="#setValue(TCHAR*)">setValue(TCHAR*)</a>. */ void setValue(CL_NS(analysis)::TokenStream* value); Modified: branches/lucene2_3_2/src/core/CLucene/index/DocumentWriter.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/DocumentWriter.cpp 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/index/DocumentWriter.cpp 2008-10-02 14:17:48 UTC (rev 2907) @@ -10,7 +10,7 @@ #include "CLucene/store/IndexOutput.h" #include "CLucene/util/Array.h" #include "CLucene/util/Misc.h" -#include "CLucene/util/Reader.h" +#include "CLucene/util/CLStreams.h" #include "CLucene/document/Field.h" #include "CLucene/document/Document.h" #include "_FieldInfos.h" @@ -256,7 +256,7 @@ // this may invalidate the string for the further calls // it may be better to do this via a FilterReader // TODO make a better implementation of this - dataLen = r->read(charBuf, LUCENE_INT32_MAX_SHOULDBE); + dataLen = r->read(charBuf, LUCENE_INT32_MAX_SHOULDBE,0); if (dataLen == -1) dataLen = 0; //todo: would be better to pass the string length, in case Modified: branches/lucene2_3_2/src/core/CLucene/queryParser/Lexer.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/queryParser/Lexer.cpp 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/queryParser/Lexer.cpp 2008-10-02 14:17:48 UTC (rev 2907) @@ -10,7 +10,7 @@ #include "QueryToken.h" #include "_Lexer.h" -#include "CLucene/util/Reader.h" +#include "CLucene/util/CLStreams.h" #include "CLucene/util/StringBuffer.h" #include "CLucene/util/_FastCharStream.h" @@ -46,7 +46,7 @@ } -Lexer::Lexer(QueryParserBase* queryparser, Reader* source) { +Lexer::Lexer(QueryParserBase* queryparser, BufferedReader* source) { //Func - Constructor // Initializes a new instance of the Lexer class with the specified // TextReader to lex. Modified: branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParser.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParser.cpp 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParser.cpp 2008-10-02 14:17:48 UTC (rev 2907) @@ -8,7 +8,7 @@ #include "QueryParser.h" #include "CLucene/analysis/AnalysisHeader.h" -#include "CLucene/util/Reader.h" +#include "CLucene/util/CLStreams.h" #include "CLucene/search/SearchHeader.h" #include "CLucene/search/BooleanClause.h" #include "CLucene/search/Query.h" @@ -72,7 +72,7 @@ CND_PRECONDITION(query != NULL, "query is NULL"); //Instantie a Stringer that can read the query string - Reader* r = _CLNEW StringReader(query); + BufferedReader* r = _CLNEW StringReader(query); //Check to see if r has been created properly CND_CONDITION(r != NULL, "Could not allocate memory for StringReader r"); @@ -91,7 +91,7 @@ return ret; } - Query* QueryParser::parse(Reader* reader){ + Query* QueryParser::parse(BufferedReader* reader){ //Func - Returns a parsed Query instance //Pre - reader contains a valid reference to a Reader and manages the query string //Post - A parsed Query instance has been returned or Modified: branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParser.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParser.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParser.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -9,7 +9,7 @@ //#include "CLucene/analysis/AnalysisHeader.h" -CL_CLASS_DEF(util,Reader) +CL_CLASS_DEF(util,BufferedReader) //#include "CLucene/search/SearchHeader.h" CL_CLASS_DEF(index,Term) CL_CLASS_DEF(analysis,Analyzer) @@ -267,7 +267,7 @@ * <param name="reader">The TextReader value to be parsed.</param> * <returns>A parsed Query instance.</returns> */ - virtual CL_NS(search)::Query* parse(CL_NS(util)::Reader* reader); + virtual CL_NS(search)::Query* parse(CL_NS(util)::BufferedReader* reader); /** * Returns a new instance of the Query class with a specified query, field and Modified: branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParserBase.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParserBase.cpp 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/queryParser/QueryParserBase.cpp 2008-10-02 14:17:48 UTC (rev 2907) @@ -16,7 +16,7 @@ #include "CLucene/search/BooleanQuery.h" #include "CLucene/analysis/AnalysisHeader.h" -#include "CLucene/util/Reader.h" +#include "CLucene/util/CLStreams.h" #include "CLucene/search/SearchHeader.h" #include "CLucene/search/BooleanClause.h" #include "CLucene/search/Query.h" Modified: branches/lucene2_3_2/src/core/CLucene/queryParser/_Lexer.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/queryParser/_Lexer.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/queryParser/_Lexer.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -9,7 +9,7 @@ CL_CLASS_DEF(util,FastCharStream) -CL_CLASS_DEF(util,Reader) +CL_CLASS_DEF(util,BufferedReader) CL_CLASS_DEF(util,StringBuffer) //#include "TokenList.h" @@ -34,7 +34,7 @@ // Initializes a new instance of the Lexer class with the specified // TextReader to lex. - Lexer(QueryParserBase* queryparser, CL_NS(util)::Reader* source); + Lexer(QueryParserBase* queryparser, CL_NS(util)::BufferedReader* source); //Breaks the input stream onto the tokens list tokens void Lex(TokenList *tokens); Added: branches/lucene2_3_2/src/core/CLucene/util/CLStreams.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/CLStreams.h (rev 0) +++ branches/lucene2_3_2/src/core/CLucene/util/CLStreams.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -0,0 +1,233 @@ +/*------------------------------------------------------------------------------ +* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team +* +* Distributable under the terms of either the Apache License (Version 2.0) or +* the GNU Lesser General Public License, as specified in the COPYING file. +------------------------------------------------------------------------------*/ +#ifndef _lucene_util_CLStreams_ +#define _lucene_util_CLStreams_ + +CL_NS_DEF(util) + +template <typename T> +class CLUCENE_EXPORT CLStream{ +public: + virtual ~CLStream(){} + + inline int read(){ + const T* buffer; + const int32_t nread = read(buffer,1, 1); + if ( nread < 0 ) + return -1; + else + return buffer[0]; + } + + /** Read one line, return the length of the line read. + * If the string is longer than len, only len of that line will be copied + */ + inline int32_t readLine(T* buffer, size_t len){ + size_t i = 0; + while (true && i<len-1) { + int32_t b = read(); + if (b < 1) + break; + if (b == '\n' || b == '\r') { + if (i > 0) + break; + else + continue; + } + buffer[i++] = b; + } + buffer[i] = 0; + return i; + } + + /** + * @brief Reads items from the stream and sets @p start to point to + * the first item that was read. + * + * Note: unless stated otherwise in the documentation for that method, + * this pointer will no longer be valid after calling another method of + * this class. The pointer will also no longer be valid after the class + * is destroyed. + * + * At least @p min items will be read from the stream, unless an error occurs + * or the end of the stream is reached. Under no circumstances will more than + * @p max items be read. + * + * If the end of the stream is reached before @p min items are read, the + * read is still considered successful and the number of items read will + * be returned. + * + * @param start pointer passed by reference that will be set to point to + * the retrieved array of items. If the end of the stream + * is encountered or an error occurs, the value of @p start + * is undefined + * @param min the minimal number of items to read from the stream. This + * value should be larger than 0. If it is 0 or smaller, the + * result is undefined + * @param max the maximal number of items to read from the stream. + * If this value is smaller than @p min, there is no limit on + * the number of items that can be read + * @return the number of items that were read. @c -1 is returned if + * end of the stream has already been reached. An error is thrown + * if an error occurs. + **/ + virtual int32_t read(const T*& start, int32_t min, int32_t max) = 0; + /** + * @brief Skip @p ntoskip items. + * + * If an error occurs, or the end of the stream is encountered, fewer + * than @p ntoskip items may be skipped. This can be checked by comparing + * the return value to @p ntoskip. + * + * Calling this function invalidates the data pointer that was obtained from + * StreamBase::read. + * + * @param ntoskip the number of items that should be skipped + * @return the number of items skipped + **/ + virtual int64_t skip(int64_t ntoskip) = 0; + /** + * @brief Get the current position in the stream. + * The value obtained from this function can be used to reset the stream. + **/ + virtual int64_t position() = 0; + + virtual size_t size() = 0; +}; + +template <class T> +class CLUCENE_EXPORT BufferedStream{ +public: + /** + * @brief Repositions this stream to a given position. + * + * A call to reset is only guaranteed to be successful when + * the requested position lies within the segment of a stream + * corresponding to a valid pointer obtained from read. + * In this case, the pointer will not be invalidated. + * + * Calling this function invalidates the data pointer that was obtained from + * StreamBase::read unless the conditions outlined above apply. + * + * To read n items, leaving the stream at the same position as before, you + * can do the following: + * @code + * int64_t start = stream.position(); + * if ( stream.read(data, min, max) > 0 ) { + * stream.reset(start); + * // The data pointer is still valid here + * } + * @endcode + * + * @param pos the position in the stream you want to go to, relative to + * the start of the stream + * @return the new position in the stream + **/ + virtual int64_t reset(int64_t) = 0; + /** + * @brief Sets the minimum size of the buffer + */ + virtual void setMinBufSize(int32_t s) = 0; +}; + +class BufferedReader; +class CLUCENE_EXPORT Reader: public CLStream<TCHAR>{ +public: + virtual BufferedReader* __asBufferedReader(){ return NULL; } +}; +class CLUCENE_EXPORT BufferedReader: public Reader, public BufferedStream<TCHAR>{ +public: + _CL_DEPRECATED( setMinBufSize ) int64_t mark(int32_t readAheadlimit){ + this->setMinBufSize(readAheadlimit); + return this->position(); + } + BufferedReader* __asBufferedReader(){ return this; } +}; +class CLUCENE_EXPORT InputStream: public CLStream<signed char>{}; +class CLUCENE_EXPORT BufferedInputStream: public InputStream, public BufferedStream<signed char>{}; + + +class CLUCENE_EXPORT StringReader: public BufferedReader{ + TCHAR* value; + bool ownValue; + int64_t pos; +protected: + size_t m_size; +public: + StringReader ( const TCHAR* value, const int32_t length = -1 ); + StringReader ( TCHAR* value, const int32_t length, bool copyData = true ); + virtual ~StringReader(); + + int32_t read(const TCHAR*& start, int32_t min, int32_t max); + int64_t position(); + int64_t reset(int64_t); + int64_t skip(int64_t ntoskip); + void setMinBufSize(int32_t s); + size_t size(); +}; + +/** +* A helper class which constructs a FileReader with a specified +* simple encodings, or a given inputstreamreader +*/ +class CLUCENE_EXPORT FileInputStream: public BufferedInputStream { + class Internal; + Internal* internal; +protected: + void init(InputStream *i, int encoding); +public: + LUCENE_STATIC_CONSTANT(int32_t, DEFAULT_BUFFER_SIZE=4096); + FileInputStream ( const char* path, int32_t buflen = -1 ); + virtual ~FileInputStream (); + + int32_t read(const signed char*& start, int32_t min, int32_t max); + int64_t position(); + int64_t reset(int64_t); + int64_t skip(int64_t ntoskip); + size_t size(); + void setMinBufSize(int32_t minbufsize); +}; + +class CLUCENE_EXPORT SimpleInputStreamReader: public BufferedReader{ + class Internal; + Internal* internal; +protected: + void init(InputStream *i, int encoding); +public: + enum{ + ASCII=1, + UTF8=2, + UCS2_LE=3 + }; + + SimpleInputStreamReader(); + virtual ~SimpleInputStreamReader(); + + int32_t read(const TCHAR*& start, int32_t min, int32_t max); + int64_t position(); + int64_t reset(int64_t); + int64_t skip(int64_t ntoskip); + void setMinBufSize(int32_t s); + size_t size(); +}; + +/** +* A helper class which constructs a FileReader with a specified +* simple encodings, or a given inputstreamreader. +* It is recommended that you use the contribs package for proper +* decoding using iconv. This class is provided only as a dependency-less +* replacement. +*/ +class CLUCENE_EXPORT FileReader: public SimpleInputStreamReader{ +public: + FileReader(const char* path, int encoding, int32_t buflen = -1); + FileReader(const char* path, const char* encoding, int32_t buflen = -1); + virtual ~FileReader(); +}; + +CL_NS_END +#endif Modified: branches/lucene2_3_2/src/core/CLucene/util/_FastCharStream.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/_FastCharStream.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/util/_FastCharStream.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -8,7 +8,7 @@ #define _lucene_util_FastCharStream_ -CL_CLASS_DEF(util,Reader) +CL_CLASS_DEF(util,BufferedReader) CL_NS_DEF(util) @@ -24,10 +24,10 @@ // read character from stream return false on error void readChar(TCHAR &); public: - Reader* input; + BufferedReader* input; /// Initializes a new instance of the FastCharStream class LUCENE_EXPORT. - FastCharStream(Reader* reader); + FastCharStream(BufferedReader* reader); ~FastCharStream(); /// Returns the next TCHAR from the stream. Copied: branches/lucene2_3_2/src/core/CLucene/util/_bufferedstream.h (from rev 2905, branches/lucene2_3_2/src/core/CLucene/util/bufferedstream.h) =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/_bufferedstream.h (rev 0) +++ branches/lucene2_3_2/src/core/CLucene/util/_bufferedstream.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -0,0 +1,179 @@ +#ifndef STRIGI_BUFFEREDSTREAM_H +#define STRIGI_BUFFEREDSTREAM_H + +#include "_streambase.h" +#include "_streambuffer.h" +#include <cassert> + +namespace jstreams { + +/** + * @brief Abstract class providing a buffered input stream. + * + * You can inherit this class to provide buffered access to a + * resource. You just need to implement fillBuffer, and + * BufferedStream will do the rest. + */ +template <class T> +class BufferedStream : public StreamBase<T> { +private: + StreamBuffer<T> buffer; + bool finishedWritingToBuffer; + + void writeToBuffer(int32_t minsize, int32_t maxsize); +protected: + /** + * @brief Fill the buffer with the provided data + * + * This function should be implemented by subclasses. + * It should write up to @p space characters from the + * stream to the buffer position pointed to by @p start. + * + * If the end of the stream is encountered, -1 should be + * returned. + * + * If an error occurs, the status should be set to Error, + * an error message should be set and -1 should be returned. + * + * You should @em not call this function yourself. + * + * @param start where the data should be written to + * @param space the maximum amount of data to write + * @return Number of characters written, or -1 on error + **/ + virtual int32_t fillBuffer(T* start, int32_t space) = 0; + /** + * @brief Resets the buffer, allowing it to be used again + * + * This function resets the buffer, allowing it to be re-used. + */ + void resetBuffer() { + StreamBase<T>::m_size = -1; + StreamBase<T>::m_position = 0; + StreamBase<T>::m_error.assign(""); + StreamBase<T>::m_status = Ok; + buffer.readPos = buffer.start; + buffer.avail = 0; + finishedWritingToBuffer = false; + } + /** + * @brief Sets the minimum size of the buffer + */ + void setMinBufSize(int32_t s) { + buffer.makeSpace(s); + } + BufferedStream<T>(); +public: + int32_t read(const T*& start, int32_t min, int32_t max); + int64_t reset(int64_t pos); + virtual int64_t skip(int64_t ntoskip); +}; + + +/** Abstract class for a buffered stream of bytes */ +typedef BufferedStream<signed char> BufferedInputStream; + +/** Abstract class for a buffered stream of Unicode characters */ +typedef BufferedStream<wchar_t> BufferedReader; + + +template <class T> +BufferedStream<T>::BufferedStream() { + finishedWritingToBuffer = false; +} + +template <class T> +void +BufferedStream<T>::writeToBuffer(int32_t ntoread, int32_t maxread) { + int32_t missing = ntoread - buffer.avail; + int32_t nwritten = 0; + while (missing > 0 && nwritten >= 0) { + int32_t space; + space = buffer.makeSpace(missing); + if (maxread >= ntoread && space > maxread) { + space = maxread; + } + T* start = buffer.readPos + buffer.avail; + nwritten = fillBuffer(start, space); + assert(StreamBase<T>::m_status != Eof); + if (nwritten > 0) { + buffer.avail += nwritten; + missing = ntoread - buffer.avail; + } + } + if (nwritten < 0) { + finishedWritingToBuffer = true; + } +} +template <class T> +int32_t +BufferedStream<T>::read(const T*& start, int32_t min, int32_t max) { + if (StreamBase<T>::m_status == Error) return -2; + if (StreamBase<T>::m_status == Eof) return -1; + + // do we need to read data into the buffer? + if (min > max) max = 0; + if (!finishedWritingToBuffer && min > buffer.avail) { + // do we have enough space in the buffer? + writeToBuffer(min, max); + if (StreamBase<T>::m_status == Error) return -2; + } + + int32_t nread = buffer.read(start, max); + + StreamBase<T>::m_position += nread; + if (StreamBase<T>::m_position > StreamBase<T>::m_size + && StreamBase<T>::m_size > 0) { + // error: we read more than was specified in size + // this is an error because all dependent code might have been labouring + // under a misapprehension + StreamBase<T>::m_status = Error; + StreamBase<T>::m_error = "Stream is longer than specified."; + nread = -2; + } else if (StreamBase<T>::m_status == Ok && buffer.avail == 0 + && finishedWritingToBuffer) { + StreamBase<T>::m_status = Eof; + if (StreamBase<T>::m_size == -1) { + StreamBase<T>::m_size = StreamBase<T>::m_position; + } + // save one call to read() by already returning -1 if no data is there + if (nread == 0) nread = -1; + } + return nread; +} +template <class T> +int64_t +BufferedStream<T>::reset(int64_t newpos) { + assert(newpos >= 0); + if (StreamBase<T>::m_status == Error) return -2; + // check to see if we have this position + int64_t d = StreamBase<T>::m_position - newpos; + if (buffer.readPos - d >= buffer.start && -d < buffer.avail) { + StreamBase<T>::m_position -= d; + buffer.avail += (int32_t)d; + buffer.readPos -= d; + StreamBase<T>::m_status = Ok; + } + return StreamBase<T>::m_position; +} +template <class T> +int64_t +BufferedStream<T>::skip(int64_t ntoskip) { + const T *begin; + int32_t nread; + int64_t skipped = 0; + while (ntoskip) { + int32_t step = (int32_t)((ntoskip > buffer.size) ?buffer.size :ntoskip); + nread = read(begin, 1, step); + if (nread <= 0) { + return skipped; + } + ntoskip -= nread; + skipped += nread; + } + return skipped; +} + +} // end namespace Strigi + +#endif Property changes on: branches/lucene2_3_2/src/core/CLucene/util/_bufferedstream.h ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/lucene2_3_2/src/core/CLucene/util/_streambase.h (from rev 2905, branches/lucene2_3_2/src/core/CLucene/util/streambase.h) =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/_streambase.h (rev 0) +++ branches/lucene2_3_2/src/core/CLucene/util/_streambase.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -0,0 +1,212 @@ + +#ifndef STRIGI_STREAMBASE_H +#define STRIGI_STREAMBASE_H + +#include <stdio.h> +#include <string> + +#define INT32MAX 0x7FFFFFFFL + +namespace jstreams { + +/** Used to indicate the current status of a Stream */ +enum StreamStatus { + Ok /**< Stream is capable of being read from */, + Eof /**< The end of the Stream has been reached */, + Error /**< An error occurred. Use error() to find out more information */ +}; + +// java mapping: long=int64, int=int32, byte=uint8_t +/** + * The base of all Streams. Do not inherit directly from this class, + * but from (an instance of) StreamBase + * + * This class contains all the non-virtual StreamBase methods + * that don't depend on a specific Stream type + * + * Developer comment: This is needed because of win32 compilation. + * When we want to access a function outside a lib, we have to export them, + * but we can't export the template class because this would be somewhat + * stupid / does not work by design :) + * Because of this I've introduced this StreamBaseBase class + */ +class StreamBaseBase { //krazy:exclude=dpointer +protected: + /** The size of the stream (-1 if unknown) */ + int64_t m_size; + /** The position of the stream */ + int64_t m_position; + /** + * @brief String representation of the last error, or + * an empty string otherwise + */ + std::string m_error; + /** The status of the stream - see StreamStatus */ + StreamStatus m_status; +public: + /** + * @brief Constructor: initialises everything to sane defaults + **/ + StreamBaseBase() :m_size(-1), m_position(0), m_status(Ok) {} + /** + * @brief Destructor + **/ + virtual ~StreamBaseBase() {} + /** + * @brief Return a string representation of the last error. + * If no error has occurred, an empty string is returned. + **/ + const char* error() const { return m_error.c_str(); } + /** + * @brief Return the status of the stream. + **/ + StreamStatus status() const { return m_status; } + /** + * @brief Get the current position in the stream. + * The value obtained from this function can be used to reset the stream. + **/ + int64_t position() const { return m_position; } + /** + * @brief Return the size of the stream. + * + * The size of the stream is always known if the end of the stream + * has been reached. In all other cases, this may return -1 to + * indicate the size of the stream is unknown. + * + * @return the size of the stream, if it is known, or -1 if the size + * of the stream is unknown + **/ + int64_t size() const { return m_size; } +}; + +/** + * @brief Base class for stream read access to a data source. + * + * This class is based on the interface java.io.InputStream. It provides + * a uniform interface for accessing streamed resources. + * + * The main difference with the Java equivalent is a performance improvement. + * When reading data, data is not copied into a buffer provided by the caller, + * but a pointer to the read data is provided. This makes this interface + * especially useful for deriving from it and implementing filters or + * transformers. + */ +template <class T> +class StreamBase : public StreamBaseBase { +public: + StreamBase() { } + virtual ~StreamBase(){} + /** + * @brief Reads items from the stream and sets @p start to point to + * the first item that was read. + * + * Note: unless stated otherwise in the documentation for that method, + * this pointer will no longer be valid after calling another method of + * this class. The pointer will also no longer be valid after the class + * is destroyed. + * + * The functions inherited from StreamBaseBase do not invalidate the pointer. + * + * At least @p min items will be read from the stream, unless an error occurs + * or the end of the stream is reached. Under no circumstances will more than + * @p max items be read. + * + * If the end of the stream is reached before @p min items are read, the + * read is still considered successful and the number of items read will + * be returned. + * + * @param start pointer passed by reference that will be set to point to + * the retrieved array of items. If the end of the stream + * is encountered or an error occurs, the value of @p start + * is undefined + * @param min the minimal number of items to read from the stream. This + * value should be larger than 0. If it is 0 or smaller, the + * result is undefined + * @param max the maximal number of items to read from the stream. + * If this value is smaller than @p min, there is no limit on + * the number of items that can be read + * @return the number of items that were read. @c -1 is returned if + * end of the stream has already been reached. @c -2 is returned + * if an error has occurred + **/ + virtual int32_t read(const T*& start, int32_t min, int32_t max) = 0; + /** + * @brief Skip @p ntoskip items. + * + * If an error occurs, or the end of the stream is encountered, fewer + * than @p ntoskip items may be skipped. This can be checked by comparing + * the return value to @p ntoskip. + * + * Calling this function invalidates the data pointer that was obtained from + * StreamBase::read. + * + * @param ntoskip the number of items that should be skipped + * @return the number of items skipped + **/ + virtual int64_t skip(int64_t ntoskip); + /** + * @brief Repositions this stream to a given position. + * + * A call to StreamBase::reset is only guaranteed to be successful when + * the requested position lies within the segment of a stream + * corresponding to a valid pointer obtained from StreamBase::read. + * In this case, the pointer will not be invalidated. + * + * Calling this function invalidates the data pointer that was obtained from + * StreamBase::read unless the conditions outlined above apply. + * + * To read n items, leaving the stream at the same position as before, you + * can do the following: + * @code + * int64_t start = stream.position(); + * if ( stream.read(data, min, max) > 0 ) { + * stream.reset(start); + * // The data pointer is still valid here + * } + * @endcode + * + * @param pos the position in the stream you want to go to, relative to + * the start of the stream + * @return the new position in the stream + **/ + virtual int64_t reset(int64_t pos) = 0; +}; + + +/** Abstract class for a stream of bytes */ +typedef StreamBase<char> InputStream; + +/** Abstract class for a stream of Unicode characters */ +typedef StreamBase<wchar_t> Reader; + + +template <class T> +int64_t +StreamBase<T>::skip(int64_t ntoskip) { + const T* begin; + int32_t nread; + int64_t skipped = 0; + while (ntoskip > 0) { + // make sure we do not overflow uint32_t + int32_t maxstep = (int32_t)((ntoskip > 10000000) + ?10000000 :ntoskip); + // the default implementation is to simply read the data that we want + // to skip + nread = read(begin, 1, maxstep); + if (nread < -1 ) { + // an error occurred + return nread; + } else if (nread < 1) { + // the end of the stream was encountered + ntoskip = 0; + } else { + skipped += nread; + ntoskip -= nread; + } + } + return skipped; +} + +} // end namespace Strigi + +#endif Property changes on: branches/lucene2_3_2/src/core/CLucene/util/_streambase.h ___________________________________________________________________ Added: svn:mergeinfo + Added: branches/lucene2_3_2/src/core/CLucene/util/_streambuffer.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/_streambuffer.h (rev 0) +++ branches/lucene2_3_2/src/core/CLucene/util/_streambuffer.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -0,0 +1,162 @@ + +#ifndef STRIGI_STREAMBUFFER_H +#define STRIGI_STREAMBUFFER_H + +#include <cstdlib> +#include <cstring> + +namespace jstreams { + +/** + * @internal + * @brief Provides a buffer for the use of BufferedStream + */ +template <class T> +class StreamBuffer { +private: +public: + /** + * @internal + * @brief Pointer to the start of the buffer. + */ + T* start; + /** + * @internal + * @brief Size of the buffer. + * + * Size of the memory pointed to by @p start, + * in multiples of sizeof(T) + */ + int32_t size; + /** + * @internal + * @brief Pointer to the current position the buffer. + */ + T* readPos; + /** + * @internal + * @brief The amount of data available in the buffer. + * + * The size of the used memory in the buffer, starting + * from @p readPos. @p readPos + @p avail must be + * greater than @p start + @p size. + */ + int32_t avail; + + /** + * @internal + * @brief Constructor: initialises members to sane defaults. + */ + StreamBuffer(); + /** + * @internal + * @brief Destructor: frees the memory used by the buffer. + */ + ~StreamBuffer(); + /** + * @internal + * @brief Sets the size of the buffer, allocating the necessary memory + * + * @param size the size that the buffer should be, in multiples + * of sizeof(T) + */ + void setSize(int32_t size); + /** + * @internal + * @brief Read data from the buffer + * + * Sets @p start to point to the data, starting + * at the item of data following the last item + * of data read. + * + * @param start pointer passed by reference. It will + * be set to point to the data read from the buffer + * @param max the maximum amount of data to read from + * the buffer + * @return the size of the data pointed to by @p start + * (always less than or equal to @p max) + */ + int32_t read(const T*& start, int32_t max=0); + + /** + * @internal + * @brief Prepares the buffer for a new write. + * + * This function invalidates any pointers + * previously obtained from read. + * + * @return the number of available places + **/ + int32_t makeSpace(int32_t needed); +}; + +template <class T> +StreamBuffer<T>::StreamBuffer() { + readPos = start = 0; + size = avail = 0; +} +template <class T> +StreamBuffer<T>::~StreamBuffer() { + std::free(start); +} +template <class T> +void +StreamBuffer<T>::setSize(int32_t size) { + // store pointer information + int32_t offset = readPos - start; + + // allocate memory in the buffer + start = (T*)std::realloc(start, size*sizeof(T)); + this->size = size; + + // restore pointer information + readPos = start + offset; +} +template <class T> +int32_t +StreamBuffer<T>::makeSpace(int32_t needed) { + // determine how much space is available for writing + int32_t space = size - (readPos - start) - avail; + if (space >= needed) { + // there's enough space + return space; + } + + if (avail) { + if (readPos != start) { +// printf("moving\n"); + // move data to the start of the buffer + std::memmove(start, readPos, avail*sizeof(T)); + space += readPos - start; + readPos = start; + } + } else { + // we may start writing at the start of the buffer + readPos = start; + space = size; + } + if (space >= needed) { + // there's enough space now + return space; + } + + // still not enough space, we have to allocate more +// printf("resize %i %i %i %i %i\n", avail, needed, space, size + needed - space, size); + setSize(size + needed - space); + return needed; +} +template <class T> +int32_t +StreamBuffer<T>::read(const T*& start, int32_t max) { + start = readPos; + if (max <= 0 || max > avail) { + max = avail; + } + readPos += max; + avail -= max; + return max; +} + +} // end namespace Strigi + +#endif Deleted: branches/lucene2_3_2/src/core/CLucene/util/bufferedstream.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/bufferedstream.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/util/bufferedstream.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -1,140 +0,0 @@ -/*------------------------------------------------------------------------------ -* Copyright (C) 2003-2006 Jos van den Oever -* -* Distributable under the terms of either the Apache License (Version 2.0) or -* the GNU Lesser General Public License, as specified in the COPYING file. -------------------------------------------------------------------------------*/ -/* This file is part of Strigi Desktop Search - * - * Copyright (C) 2006 Jos van den Oever <jo...@va...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifndef BUFFEREDSTREAM_H -#define BUFFEREDSTREAM_H - -#include "streambase.h" -#include "inputstreambuffer.h" -#include <cassert> - -namespace jstreams { - -template <class T> -class CLUCENE_EXPORT BufferedInputStream : public StreamBase<T> { -private: - bool finishedWritingToBuffer; - InputStreamBuffer<T> buffer; - - void writeToBuffer(int32_t ntoread){ - int32_t missing = ntoread - buffer.avail; - int32_t nwritten = 0; - while (missing > 0 && nwritten >= 0) { - int32_t space; - space = buffer.makeSpace(missing); - T* start = buffer.readPos + buffer.avail; - nwritten = fillBuffer(start, space); - assert(StreamBase<T>::status != Eof); - if (nwritten > 0) { - buffer.avail += nwritten; - missing = ntoread - buffer.avail; - } - } - if (nwritten < 0) { - finishedWritingToBuffer = true; - } - } -protected: - /** - * This function must be implemented by the subclasses. - * It should write a maximum of @p space characters at the buffer - * position pointed to by @p start. If no more data is avaiable due to - * end of file, -1 should be returned. If an error occurs, the status - * should be set to Error, an error message should be set and the function - * must return -1. - **/ - virtual int32_t fillBuffer(T* start, int32_t space) = 0; - // this function might be useful if you want to reuse a bufferedstream - void resetBuffer() {printf("implement 'resetBuffer'\n");} - BufferedInputStream<T>(){ - finishedWritingToBuffer = false; - } -public: - int32_t read(const T*& start, int32_t min, int32_t max){ - if (StreamBase<T>::status == Error) return -2; - if (StreamBase<T>::status == Eof) return -1; - - // do we need to read data into the buffer? - if (!finishedWritingToBuffer && min > buffer.avail) { - // do we have enough space in the buffer? - writeToBuffer(min); - if (StreamBase<T>::status == Error) return -2; - } - - int32_t nread = buffer.read(start, max); - - BufferedInputStream<T>::position += nread; - if (BufferedInputStream<T>::position > BufferedInputStream<T>::size - && BufferedInputStream<T>::size > 0) { - // error: we read more than was specified in size - // this is an error because all dependent code might have been labouring - // under a misapprehension - BufferedInputStream<T>::status = Error; - BufferedInputStream<T>::error = "Stream is longer than specified."; - nread = -2; - } else if (BufferedInputStream<T>::status == Ok && buffer.avail == 0 - && finishedWritingToBuffer) { - BufferedInputStream<T>::status = Eof; - if (BufferedInputStream<T>::size == -1) { - BufferedInputStream<T>::size = BufferedInputStream<T>::position; - } - // save one call to read() by already returning -1 if no data is there - if (nread == 0) nread = -1; - } - return nread; - } - int64_t reset(int64_t newpos){ - if (StreamBase<T>::status == Error) return -2; - // check to see if we have this position - int64_t d = BufferedInputStream<T>::position - newpos; - if (buffer.readPos - d >= buffer.start && -d < buffer.avail) { - BufferedInputStream<T>::position -= d; - buffer.avail += (int32_t)d; - buffer.readPos -= d; - StreamBase<T>::status = Ok; - } - return StreamBase<T>::position; - } - virtual int64_t skip(int64_t ntoskip){ - const T *begin; - int32_t nread; - int64_t skipped = 0; - while (ntoskip) { - int32_t step = (int32_t)((ntoskip > buffer.size) ?buffer.size :ntoskip); - nread = read(begin, 1, step); - if (nread <= 0) { - return skipped; - } - ntoskip -= nread; - skipped += nread; - } - return skipped; - } -}; - - -} - -#endif Deleted: branches/lucene2_3_2/src/core/CLucene/util/fileinputstream.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/fileinputstream.cpp 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/util/fileinputstream.cpp 2008-10-02 14:17:48 UTC (rev 2907) @@ -1,102 +0,0 @@ -/*------------------------------------------------------------------------------ -* Copyright (C) 2003-2006 Jos van den Oever -* -* Distributable under the terms of either the Apache License (Version 2.0) or -* the GNU Lesser General Public License, as specified in the COPYING file. -------------------------------------------------------------------------------*/ -/* This file is part of Strigi Desktop Search - * - * Copyright (C) 2006 Jos van den Oever <jo...@va...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#include "jstreamsconfig.h" -#include "fileinputstream.h" -#include <cerrno> -#include <cstring> - -#ifdef _CL_HAVE_STRING_H - #include <string.h> -#endif - -namespace jstreams { - -FileInputStream::FileInputStream(const char *filepath, int32_t buffersize) { - // try to open the file for reading - file = fopen(filepath, "rb"); - this->filepath = filepath; - if (file == 0) { - // handle error - error = "Could not read file '"; - error += filepath; - error += "': "; - error += strerror(errno); - status = Error; - return; - } - // determine file size. if the stream is not seekable, the size will be -1 - fseek(file, 0, SEEK_END); - size = ftell(file); - fseek(file, 0, SEEK_SET); - - // if the file has size 0, make sure that it's really empty - // this is useful for filesystems like /proc that report files as size 0 - // for files that do contain content - if (size == 0) { - char dummy[1]; - size_t n = fread(dummy, 1, 1, file); - if (n == 1) { - size = -1; - fseek(file, 0, SEEK_SET); - } else { - fclose(file); - file = 0; - return; - } - } - - // allocate memory in the buffer - int32_t bufsize = (size <= buffersize) ?size+1 :buffersize; - mark(bufsize); -} -FileInputStream::~FileInputStream() { - if (file) { - if (fclose(file)) { - // handle error - error = "Could not close file '" + filepath + "'."; - } - } -} -int32_t -FileInputStream::fillBuffer(char* start, int32_t space) { - if (file == 0) return -1; - // read into the buffer - int32_t nwritten = fread(start, 1, space, file); - // check the file stream status - if (ferror(file)) { - error = "Could not read from file '" + filepath + "'."; - fclose(file); - file = 0; - status = Error; - return -1; - } - if (feof(file)) { - fclose(file); - file = 0; - } - return nwritten; -} -} Deleted: branches/lucene2_3_2/src/core/CLucene/util/fileinputstream.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/fileinputstream.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/util/fileinputstream.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -1,49 +0,0 @@ -/*------------------------------------------------------------------------------ -* Copyright (C) 2003-2006 Jos van den Oever -* -* Distributable under the terms of either the Apache License (Version 2.0) or -* the GNU Lesser General Public License, as specified in the COPYING file. -------------------------------------------------------------------------------*/ -/* This file is part of Strigi Desktop Search - * - * Copyright (C) 2006 Jos van den Oever <jo...@va...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifndef FILEINPUTSTREAM_H -#define FILEINPUTSTREAM_H - -#include <stdio.h> -#include "bufferedstream.h" - -namespace jstreams { - -class CLUCENE_EXPORT FileInputStream : public BufferedInputStream<char> { -private: - FILE *file; - std::string filepath; - -public: - LUCENE_STATIC_CONSTANT(int32_t, defaultBufferSize=1048576); - FileInputStream(const char *filepath, int32_t buffersize=defaultBufferSize); - ~FileInputStream(); - int32_t fillBuffer(char* start, int32_t space); -}; - -} // end namespace jstreams - -#endif - Deleted: branches/lucene2_3_2/src/core/CLucene/util/inputstreambuffer.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/inputstreambuffer.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/util/inputstreambuffer.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -1,113 +0,0 @@ -/*------------------------------------------------------------------------------ -* Copyright (C) 2003-2006 Jos van den Oever -* -* Distributable under the terms of either the Apache License (Version 2.0) or -* the GNU Lesser General Public License, as specified in the COPYING file. -------------------------------------------------------------------------------*/ -/* This file is part of Strigi Desktop Search - * - * Copyright (C) 2006 Jos van den Oever <jo...@va...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifndef INPUTSTREAMBUFFER_H -#define INPUTSTREAMBUFFER_H - -#include <stdlib.h> - -namespace jstreams { - -template <class T> -class CLUCENE_EXPORT InputStreamBuffer { -private: -public: - T* start; - int32_t size; - T* readPos; - int32_t avail; - - InputStreamBuffer(){ - readPos = start = 0; - size = avail = 0; - } - ~InputStreamBuffer(){ - free(start); - } - void setSize(int32_t size){ - // store pointer information - int32_t offset = (int32_t)(readPos - start); - - // allocate memory in the buffer - if ( start == 0 ) - start = (T*)malloc(size*sizeof(T)); - else - start = (T*)realloc(start, size*sizeof(T)); - this->size = size; - - // restore pointer information - readPos = start + offset; - } - int32_t read(const T*& start, int32_t max=0){ - start = readPos; - if (max <= 0 || max > avail) { - max = avail; - } - readPos += max; - avail -= max; - return max; - } - - /** - * This function prepares the buffer for a new write. - * returns the number of available places. - **/ - int32_t makeSpace(int32_t needed){ - // determine how much space is available for writing - int32_t space = size - ((int32_t)(readPos - start)) - avail; - if (space >= needed) { - // there's enough space - return space; - } - - if (avail) { - if (readPos != start) { - // printf("moving\n"); - // move data to the start of the buffer - memmove(start, readPos, avail*sizeof(T)); - space += (int32_t)(readPos - start); - readPos = start; - } - } else { - // we may start writing at the start of the buffer - readPos = start; - space = size; - } - if (space >= needed) { - // there's enough space now - return space; - } - - // still not enough space, we have to allocate more - // printf("resize %i %i %i %i %i\n", avail, needed, space, size + needed - space, size); - setSize(size + needed - space); - return needed; - } -}; - - -} // end namespace jstreams - -#endif Deleted: branches/lucene2_3_2/src/core/CLucene/util/jstreamsconfig.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/jstreamsconfig.h 2008-09-30 14:54:57 UTC (rev 2906) +++ branches/lucene2_3_2/src/core/CLucene/util/jstreamsconfig.h 2008-10-02 14:17:48 UTC (rev 2907) @@ -1,9 +0,0 @@ -/*------------------------------------------------------------------------------ -* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team -* -* Distributable under the terms of either the Apache License (Version 2.0) or -* the GNU Lesser General Public License, as specified in the COPYING file. -------------------------------------------------------------------------------*/ - -//this is just a compatibility header for jstreams -#inclu... [truncated message content] |
From: <ust...@us...> - 2008-09-30 14:55:21
|
Revision: 2906 http://clucene.svn.sourceforge.net/clucene/?rev=2906&view=rev Author: ustramooner Date: 2008-09-30 14:54:57 +0000 (Tue, 30 Sep 2008) Log Message: ----------- don't build static libraries by default. this is probably not necessary by default. Modified Paths: -------------- branches/lucene2_3_2/CMakeLists.txt branches/lucene2_3_2/src/contribs/CMakeLists.txt branches/lucene2_3_2/src/core/CMakeLists.txt branches/lucene2_3_2/src/shared/CMakeLists.txt Modified: branches/lucene2_3_2/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/CMakeLists.txt 2008-09-27 11:05:20 UTC (rev 2905) +++ branches/lucene2_3_2/CMakeLists.txt 2008-09-30 14:54:57 UTC (rev 2906) @@ -59,6 +59,9 @@ OPTION(ENABLE_PACKAGING "create build scripts for creating clucene packages" OFF) +OPTION(BUILD_STATIC_LIBRARIES + "create targets for building static libraries" + OFF) OPTION(LUCENE_SYS_INCLUDES "location for non-system independent files. defaults to CMAKE_INSTALL_PREFIX. see INSTALL documentation for further information." Modified: branches/lucene2_3_2/src/contribs/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/contribs/CMakeLists.txt 2008-09-27 11:05:20 UTC (rev 2905) +++ branches/lucene2_3_2/src/contribs/CMakeLists.txt 2008-09-30 14:54:57 UTC (rev 2906) @@ -37,7 +37,6 @@ ./CLucene/jstreams/fileinputstream.cpp ./CLucene/jstreams/subinputstream.cpp ./CLucene/jstreams/tarinputstream.cpp - ./CLucene/jstreams/zipinputstream.cpp ./CLucene/highlighter/Encoder.cpp ./CLucene/highlighter/Formatter.cpp @@ -104,6 +103,7 @@ SET ( clucene_contribs_Files ${clucene_contribs_Files} ./CLucene/jstreams/gzipcompressstream.cpp ./CLucene/jstreams/gzipinputstream.cpp + ./CLucene/jstreams/zipinputstream.cpp ) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) SET ( clucene-contrib-libs "${clucene-contrib-libs} ${ZLIB_LIBRARIES}" ) @@ -130,8 +130,8 @@ #create the libraries INCLUDE_DIRECTORIES( ${clucene_SOURCE_DIR}/src/core ) -INCLUDE_DIRECTORIES( ${clucene_SOURCE_DIR}/src/contribs ) -INCLUDE_DIRECTORIES( ${clucene_BINARY_DIR}/src/contribs ) +INCLUDE_DIRECTORIES( ${clucene_SOURCE_DIR}/src/contribs-lib ) +INCLUDE_DIRECTORIES( ${clucene_BINARY_DIR}/src/contribs-lib ) add_library(clucene-contribs SHARED ${clucene_contribs_Files} ${clucene_shared_Files} ${HEADERS} @@ -140,11 +140,6 @@ TARGET_LINK_LIBRARIES(clucene-contribs clucene-shared) ENDIF ( NOT USE_SHARED_OBJECT_FILES ) -add_library(clucene-contribs-static STATIC - ${clucene_contribs_Files} ${clucene_shared_Files} ${HEADERS} -) - - #set properties on the libraries SET_TARGET_PROPERTIES(clucene-contribs PROPERTIES VERSION ${CLUCENE_VERSION} @@ -152,8 +147,14 @@ COMPILE_DEFINITIONS_DEBUG _DEBUG ) -SET_TARGET_PROPERTIES(clucene-contribs-static PROPERTIES - VERSION ${CLUCENE_VERSION} - SOVERSION ${CLUCENE_SOVERSION} - COMPILE_DEFINITIONS_DEBUG _DEBUG -) +IF ( BUILD_STATIC_LIBRARIES ) + add_library(clucene-contribs-static STATIC + ${clucene_contribs_Files} ${clucene_shared_Files} ${HEADERS} + ) + + SET_TARGET_PROPERTIES(clucene-contribs-static PROPERTIES + VERSION ${CLUCENE_VERSION} + SOVERSION ${CLUCENE_SOVERSION} + COMPILE_DEFINITIONS_DEBUG _DEBUG + ) +ENDIF ( BUILD_STATIC_LIBRARIES ) Modified: branches/lucene2_3_2/src/core/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/core/CMakeLists.txt 2008-09-27 11:05:20 UTC (rev 2905) +++ branches/lucene2_3_2/src/core/CMakeLists.txt 2008-09-30 14:54:57 UTC (rev 2906) @@ -27,7 +27,7 @@ ./CLucene/util/fileinputstream.cpp ./CLucene/util/MD5Digester.cpp ./CLucene/util/StringIntern.cpp - ./CLucene/util/subinputstream.cpp +# ./CLucene/util/subinputstream.cpp ./CLucene/util/BitSet.cpp ./CLucene/queryParser/Lexer.cpp ./CLucene/queryParser/MultiFieldQueryParser.cpp @@ -138,10 +138,6 @@ ${clucene_core_Files} ${clucene_shared_Files} ${HEADERS} ) -add_library(clucene-core-static STATIC - ${clucene_core_Files} ${clucene_shared_Files} ${HEADERS} -) - #set properties on the libraries SET_TARGET_PROPERTIES(clucene-core PROPERTIES VERSION ${CLUCENE_VERSION} @@ -154,12 +150,24 @@ TARGET_LINK_LIBRARIES(clucene-core clucene-shared) ENDIF ( NOT USE_SHARED_OBJECT_FILES ) -SET_TARGET_PROPERTIES(clucene-core-static PROPERTIES - VERSION ${CLUCENE_VERSION} - SOVERSION ${CLUCENE_SOVERSION} - COMPILE_DEFINITIONS_DEBUG _DEBUG -) +IF ( BUILD_STATIC_LIBRARIES ) + add_library(clucene-core-static STATIC + ${clucene_core_Files} ${clucene_shared_Files} ${HEADERS} + ) + + SET_TARGET_PROPERTIES(clucene-core-static PROPERTIES + VERSION ${CLUCENE_VERSION} + SOVERSION ${CLUCENE_SOVERSION} + COMPILE_DEFINITIONS_DEBUG _DEBUG + ) + + #and install library + install(TARGETS clucene-core-static + DESTINATION lib + COMPONENT runtime ) +ENDIF ( BUILD_STATIC_LIBRARIES ) + #install public headers. FOREACH(file ${HEADERS}) get_filename_component(apath ${file} PATH) @@ -209,10 +217,8 @@ COMPONENT development) ENDIF ( LUCENE_SYS_INCLUDES ) -#and install libraries + +#and install library install(TARGETS clucene-core DESTINATION lib COMPONENT runtime ) -install(TARGETS clucene-core-static - DESTINATION lib - COMPONENT runtime ) Modified: branches/lucene2_3_2/src/shared/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/shared/CMakeLists.txt 2008-09-27 11:05:20 UTC (rev 2905) +++ branches/lucene2_3_2/src/shared/CMakeLists.txt 2008-09-30 14:54:57 UTC (rev 2906) @@ -291,9 +291,6 @@ add_library(clucene-shared SHARED ${clucene_shared_Files} ${HEADERS} ) -add_library(clucene-shared-static STATIC - ${clucene_shared_Files} ${HEADERS} -) #set properties on the libraries SET_TARGET_PROPERTIES(clucene-shared PROPERTIES @@ -301,15 +298,23 @@ SOVERSION ${CLUCENE_SOVERSION} COMPILE_DEFINITIONS_DEBUG _DEBUG ) -SET_TARGET_PROPERTIES(clucene-shared-static PROPERTIES - VERSION ${CLUCENE_VERSION} - SOVERSION ${CLUCENE_SOVERSION} - COMPILE_DEFINITIONS_DEBUG _DEBUG -) install(TARGETS clucene-shared DESTINATION lib COMPONENT development ) -install(TARGETS clucene-shared-static - DESTINATION lib - COMPONENT runtime ) + + +IF ( BUILD_STATIC_LIBRARIES ) + add_library(clucene-shared-static STATIC + ${clucene_shared_Files} ${HEADERS} + ) + + SET_TARGET_PROPERTIES(clucene-shared-static PROPERTIES + VERSION ${CLUCENE_VERSION} + SOVERSION ${CLUCENE_SOVERSION} + COMPILE_DEFINITIONS_DEBUG _DEBUG + ) + install(TARGETS clucene-shared-static + DESTINATION lib + COMPONENT runtime ) +ENDIF ( BUILD_STATIC_LIBRARIES ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 11:05:25
|
Revision: 2905 http://clucene.svn.sourceforge.net/clucene/?rev=2905&view=rev Author: ustramooner Date: 2008-09-27 11:05:20 +0000 (Sat, 27 Sep 2008) Log Message: ----------- some refactoring fileSize needs check for -1 now... Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/document/FieldSelector.cpp branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp branches/lucene2_3_2/src/core/CLucene/store/IndexInput.h Added Paths: ----------- branches/lucene2_3_2/src/core/CLucene/store/_IndexInput.h Modified: branches/lucene2_3_2/src/core/CLucene/document/FieldSelector.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/document/FieldSelector.cpp 2008-09-27 11:02:44 UTC (rev 2904) +++ branches/lucene2_3_2/src/core/CLucene/document/FieldSelector.cpp 2008-09-27 11:05:20 UTC (rev 2905) @@ -5,7 +5,7 @@ * the GNU Lesser General Public License, as specified in the COPYING file. ------------------------------------------------------------------------------*/ #include "CLucene/_ApiHeader.h" - + #include "_FieldSelector.h" CL_NS_DEF(document) @@ -16,7 +16,7 @@ LoadFirstFieldSelector::~LoadFirstFieldSelector(){ } -FieldSelectorResult LoadFirstFieldSelector::accept(const TCHAR* fieldName) { - return LOAD_AND_BREAK; +FieldSelector::FieldSelectorResult LoadFirstFieldSelector::accept(const TCHAR* fieldName) { + return LOAD_AND_BREAK; } CL_NS_END Modified: branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp 2008-09-27 11:02:44 UTC (rev 2904) +++ branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp 2008-09-27 11:05:20 UTC (rev 2905) @@ -129,6 +129,8 @@ //Store the file length handle->_length = fileSize(handle->fhandle); + if ( handle->_length == -1 ) + _CLTHROWA( CL_ERR_IO,"fileStat error" ); handle->_fpos = 0; this->_pos = 0; } Modified: branches/lucene2_3_2/src/core/CLucene/store/IndexInput.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/store/IndexInput.h 2008-09-27 11:02:44 UTC (rev 2904) +++ branches/lucene2_3_2/src/core/CLucene/store/IndexInput.h 2008-09-27 11:05:20 UTC (rev 2905) @@ -9,8 +9,6 @@ #include "CLucene/LuceneThreads.h" -#include "CLucene/util/bufferedstream.h" - CL_NS_DEF(store) /** Abstract base class for input from a file in a {@link lucene::store::Directory}. A @@ -169,20 +167,5 @@ */ virtual void seekInternal(const int64_t pos) = 0; }; - - /** - * JStream InputStream which reads from an IndexInput. This class is - * used by the FieldReader to create binary fields. You can then use - * a GZipInputStream to read compressed data or any of the other - * JStream stream types. - * - */ - class CLUCENE_EXPORT IndexInputStream: public jstreams::BufferedInputStream<char>{ - IndexInput* input; - public: - IndexInputStream(IndexInput* input); - ~IndexInputStream(); - int32_t fillBuffer(char* start, int32_t space); - }; CL_NS_END #endif Added: branches/lucene2_3_2/src/core/CLucene/store/_IndexInput.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/store/_IndexInput.h (rev 0) +++ branches/lucene2_3_2/src/core/CLucene/store/_IndexInput.h 2008-09-27 11:05:20 UTC (rev 2905) @@ -0,0 +1,31 @@ +/*------------------------------------------------------------------------------ +* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team +* +* Distributable under the terms of either the Apache License (Version 2.0) or +* the GNU Lesser General Public License, as specified in the COPYING file. +------------------------------------------------------------------------------*/ +#ifndef _lucene_store_Internal_IndexInput_ +#define _lucene_store_Internal_IndexInput_ + +#include "CLucene/LuceneThreads.h" +#include "CLucene/util/_bufferedstream.h" + +CL_NS_DEF(store) + + /** + * JStream InputStream which reads from an IndexInput. This class is + * used by the FieldReader to create binary fields. You can then use + * a GZipInputStream to read compressed data or any of the other + * JStream stream types. + * todo: should we really use Buffered? isn't the underlying stream buffered enough? + */ + class IndexInputStream: public jstreams::BufferedInputStream{ + IndexInput* input; + public: + IndexInputStream(IndexInput* input); + ~IndexInputStream(); + int32_t fillBuffer(_stg_byte_t* start, int32_t space); + }; + +CL_NS_END +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 11:02:49
|
Revision: 2904 http://clucene.svn.sourceforge.net/clucene/?rev=2904&view=rev Author: ustramooner Date: 2008-09-27 11:02:44 +0000 (Sat, 27 Sep 2008) Log Message: ----------- added term unordered(hash based) compare. we might use it in document writer to speed things up a bit... Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/Term.cpp branches/lucene2_3_2/src/core/CLucene/index/Term.h branches/lucene2_3_2/src/core/CLucene/index/_Term.h Modified: branches/lucene2_3_2/src/core/CLucene/index/Term.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/Term.cpp 2008-09-27 10:44:04 UTC (rev 2903) +++ branches/lucene2_3_2/src/core/CLucene/index/Term.cpp 2008-09-27 11:02:44 UTC (rev 2904) @@ -224,6 +224,18 @@ return _tcscmp(_field,other->_field); } +int32_t Term::hashedCompareTo(Term* other) { + size_t hc1 = this->hashCode(); + size_t hc2 = other->hashCode(); + + if ( hc1 == hc2 ) + return compareTo(other); + else if ( hc1 > hc2 ) + return -1; + else + return 1; +} + TCHAR* Term::toString() const{ //Func - Forms the contents of Field and term in some kind of tuple notation // <field:text> Modified: branches/lucene2_3_2/src/core/CLucene/index/Term.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/Term.h 2008-09-27 10:44:04 UTC (rev 2903) +++ branches/lucene2_3_2/src/core/CLucene/index/Term.h 2008-09-27 11:02:44 UTC (rev 2904) @@ -94,6 +94,15 @@ The ordering of terms is first by field, then by text.*/ int32_t compareTo(const Term* other) const; + + /** Compares two terms, returning a negative integer if this + term belongs before the argument, zero if this term is equal to the + argument, and a positive integer if this term belongs after the argument. + + The ordering of terms is purely on the hashCode, so is not a logical ordering, but is repeatable. + Note: can't be const because call the to hashCode is not const + */ + int32_t hashedCompareTo(Term* other); bool equals(const Term* other) const; Modified: branches/lucene2_3_2/src/core/CLucene/index/_Term.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/_Term.h 2008-09-27 10:44:04 UTC (rev 2903) +++ branches/lucene2_3_2/src/core/CLucene/index/_Term.h 2008-09-27 11:02:44 UTC (rev 2904) @@ -33,5 +33,16 @@ } }; +class Term_UnorderedCompare:LUCENE_BASE, public CL_NS(util)::Compare::_base //<Term*> +{ +public: + bool operator()( Term* t1, Term* t2 ) const{ + return ( t1->hashedCompareTo(t2) < 0 ); + } + size_t operator()( Term* t ) const{ + return t->hashCode(); + } +}; + CL_NS_END #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 10:44:05
|
Revision: 2903 http://clucene.svn.sourceforge.net/clucene/?rev=2903&view=rev Author: ustramooner Date: 2008-09-27 10:44:04 +0000 (Sat, 27 Sep 2008) Log Message: ----------- moved FieldSelectorResult into FieldSelector so that it's more obvious what the enum is referring to and to avoid clashes with similar names Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/document/_FieldSelector.h Modified: branches/lucene2_3_2/src/core/CLucene/document/_FieldSelector.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/document/_FieldSelector.h 2008-09-27 10:38:39 UTC (rev 2902) +++ branches/lucene2_3_2/src/core/CLucene/document/_FieldSelector.h 2008-09-27 10:44:04 UTC (rev 2903) @@ -9,63 +9,6 @@ CL_NS_DEF(document) - -/** -* Provides information about what should be done with this Field -* -**/ -enum FieldSelectorResult { - /** - * Load this {@link Field} every time the {@link Document} is loaded, reading in the data as it is encounterd. - * {@link Document#getField(String)} and {@link Document#getFieldable(String)} should not return null. - *<p/> - * {@link Document#add(Fieldable)} should be called by the Reader. - */ - LOAD = 0, - - /** - * Lazily load this {@link Field}. This means the {@link Field} is valid, but it may not actually contain its data until - * invoked. {@link Document#getField(String)} SHOULD NOT BE USED. {@link Document#getFieldable(String)} is safe to use and should - * return a valid instance of a {@link Fieldable}. - *<p/> - * {@link Document#add(Fieldable)} should be called by the Reader. - */ - LAZY_LOAD = 1, - - /** - * Do not load the {@link Field}. {@link Document#getField(String)} and {@link Document#getFieldable(String)} should return null. - * {@link Document#add(Fieldable)} is not called. - * <p/> - * {@link Document#add(Fieldable)} should not be called by the Reader. - */ - NO_LOAD = 2, - - /** - * Load this field as in the {@link #LOAD} case, but immediately return from {@link Field} loading for the {@link Document}. Thus, the - * Document may not have its complete set of Fields. {@link Document#getField(String)} and {@link Document#getFieldable(String)} should - * both be valid for this {@link Field} - * <p/> - * {@link Document#add(Fieldable)} should be called by the Reader. - */ - LOAD_AND_BREAK = 3, - - /** - * Behaves much like {@link #LOAD} but does not uncompress any compressed data. This is used for internal purposes. - * {@link Document#getField(String)} and {@link Document#getFieldable(String)} should not return null. - * <p/> - * {@link Document#add(Fieldable)} should be called by the Reader. - */ - LOAD_FOR_MERGE = 4, - - /** Expert: Load the size of this {@link Field} rather than its value. - * Size is measured as number of bytes required to store the field == bytes for a binary or any compressed value, and 2*chars for a String value. - * The size is stored as a binary value, represented as an int in a byte[], with the higher order byte first in [0] - */ - SIZE = 5, - - /** Expert: Like {@link #SIZE} but immediately break from the field loading loop, i.e., stop loading further fields, after the size is loaded */ - SIZE_AND_BREAK = 6 -}; /** * Similar to a {@link java.io.FileFilter}, the FieldSelector allows one to make decisions about @@ -73,7 +16,65 @@ * **/ class FieldSelector :LUCENE_BASE { -public: +public: + + + /** + * Provides information about what should be done with this Field + * + **/ + enum FieldSelectorResult { + /** + * Load this {@link Field} every time the {@link Document} is loaded, reading in the data as it is encounterd. + * {@link Document#getField(String)} and {@link Document#getFieldable(String)} should not return null. + *<p/> + * {@link Document#add(Fieldable)} should be called by the Reader. + */ + LOAD = 0, + + /** + * Lazily load this {@link Field}. This means the {@link Field} is valid, but it may not actually contain its data until + * invoked. {@link Document#getField(String)} SHOULD NOT BE USED. {@link Document#getFieldable(String)} is safe to use and should + * return a valid instance of a {@link Fieldable}. + *<p/> + * {@link Document#add(Fieldable)} should be called by the Reader. + */ + LAZY_LOAD = 1, + + /** + * Do not load the {@link Field}. {@link Document#getField(String)} and {@link Document#getFieldable(String)} should return null. + * {@link Document#add(Fieldable)} is not called. + * <p/> + * {@link Document#add(Fieldable)} should not be called by the Reader. + */ + NO_LOAD = 2, + + /** + * Load this field as in the {@link #LOAD} case, but immediately return from {@link Field} loading for the {@link Document}. Thus, the + * Document may not have its complete set of Fields. {@link Document#getField(String)} and {@link Document#getFieldable(String)} should + * both be valid for this {@link Field} + * <p/> + * {@link Document#add(Fieldable)} should be called by the Reader. + */ + LOAD_AND_BREAK = 3, + + /** + * Behaves much like {@link #LOAD} but does not uncompress any compressed data. This is used for internal purposes. + * {@link Document#getField(String)} and {@link Document#getFieldable(String)} should not return null. + * <p/> + * {@link Document#add(Fieldable)} should be called by the Reader. + */ + LOAD_FOR_MERGE = 4, + + /** Expert: Load the size of this {@link Field} rather than its value. + * Size is measured as number of bytes required to store the field == bytes for a binary or any compressed value, and 2*chars for a String value. + * The size is stored as a binary value, represented as an int in a byte[], with the higher order byte first in [0] + */ + SIZE = 5, + + /** Expert: Like {@link #SIZE} but immediately break from the field loading loop, i.e., stop loading further fields, after the size is loaded */ + SIZE_AND_BREAK = 6 + }; ~FieldSelector(); @@ -83,7 +84,8 @@ * @return an instance of {@link FieldSelectorResult} * if the {@link Field} named <code>fieldName</code> should be loaded. */ - virtual FieldSelectorResult accept(const TCHAR* fieldName) = 0; + virtual FieldSelectorResult accept(const TCHAR* fieldName) = 0; + }; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 10:38:42
|
Revision: 2902 http://clucene.svn.sourceforge.net/clucene/?rev=2902&view=rev Author: ustramooner Date: 2008-09-27 10:38:39 +0000 (Sat, 27 Sep 2008) Log Message: ----------- signed comparison warnings removed fixed a bit of documentation Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/SegmentMerger.cpp branches/lucene2_3_2/src/core/CLucene/index/SegmentReader.cpp branches/lucene2_3_2/src/core/CLucene/index/SegmentTermDocs.cpp Modified: branches/lucene2_3_2/src/core/CLucene/index/SegmentMerger.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/SegmentMerger.cpp 2008-09-27 09:55:18 UTC (rev 2901) +++ branches/lucene2_3_2/src/core/CLucene/index/SegmentMerger.cpp 2008-09-27 10:38:39 UTC (rev 2902) @@ -140,7 +140,7 @@ { //msvc6 scope fix // Field norm files - for (int32_t i = 0; i < fieldInfos->size(); i++) { + for (size_t i = 0; i < fieldInfos->size(); i++) { FieldInfo* fi = fieldInfos->fieldInfo(i); if (fi->isIndexed && !fi->omitNorms) { TCHAR tbuf[10]; @@ -632,7 +632,7 @@ IndexOutput* output = NULL; //iterate through all the Field Infos instances - for (int32_t i = 0; i < fieldInfos->size(); i++) { + for (size_t i = 0; i < fieldInfos->size(); i++) { //Get the i-th FieldInfo FieldInfo* fi = fieldInfos->fieldInfo(i); //Is this Field indexed? Modified: branches/lucene2_3_2/src/core/CLucene/index/SegmentReader.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/SegmentReader.cpp 2008-09-27 09:55:18 UTC (rev 2901) +++ branches/lucene2_3_2/src/core/CLucene/index/SegmentReader.cpp 2008-09-27 10:38:39 UTC (rev 2902) @@ -412,7 +412,7 @@ //iterate through the field infos FieldInfo* fi; - for (int32_t i = 0; i < fieldInfos->size(); ++i) { + for (size_t i = 0; i < fieldInfos->size(); ++i) { //Get the field info for the i-th field fi = fieldInfos->fieldInfo(i); //Check if the field has been indexed @@ -454,7 +454,7 @@ } bool SegmentReader::document(int32_t n, Document* doc) { - //Func - Returns a document identified by n + //Func - writes the fields of document n into doc //Pre - n >=0 and identifies the document n //Post - if the document has been deleted then an exception has been thrown // otherwise a reference to the found document has been returned @@ -727,7 +727,7 @@ int32_t max = maxDoc(); //Iterate through all the fields - for (int32_t i = 0; i < fieldInfos->size(); i++) { + for (size_t i = 0; i < fieldInfos->size(); i++) { //Get the FieldInfo for the i-th field FieldInfo* fi = fieldInfos->fieldInfo(i); //Check if the field is indexed Modified: branches/lucene2_3_2/src/core/CLucene/index/SegmentTermDocs.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/SegmentTermDocs.cpp 2008-09-27 09:55:18 UTC (rev 2901) +++ branches/lucene2_3_2/src/core/CLucene/index/SegmentTermDocs.cpp 2008-09-27 10:38:39 UTC (rev 2902) @@ -9,6 +9,7 @@ #include "CLucene/store/IndexInput.h" #include "Term.h" +#include <assert.h> CL_NS_DEF(index) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 09:55:29
|
Revision: 2901 http://clucene.svn.sourceforge.net/clucene/?rev=2901&view=rev Author: ustramooner Date: 2008-09-27 09:55:18 +0000 (Sat, 27 Sep 2008) Log Message: ----------- refactored multireader to allow reuse of internal multi implementation. i have a class i?\194?\180m working on that needs it Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/MultiReader.cpp branches/lucene2_3_2/src/core/CLucene/index/MultiReader.h Added Paths: ----------- branches/lucene2_3_2/src/core/CLucene/index/_MultiReader.h Modified: branches/lucene2_3_2/src/core/CLucene/index/MultiReader.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/MultiReader.cpp 2008-09-27 09:50:21 UTC (rev 2900) +++ branches/lucene2_3_2/src/core/CLucene/index/MultiReader.cpp 2008-09-27 09:55:18 UTC (rev 2901) @@ -6,6 +6,7 @@ ------------------------------------------------------------------------------*/ #include "CLucene/_ApiHeader.h" #include "MultiReader.h" +#include "_MultiReader.h" #include "IndexReader.h" #include "CLucene/document/Document.h" @@ -20,134 +21,13 @@ CL_NS_USE(util) CL_NS_DEF(index) -/** An IndexReader which reads multiple indexes, appending their content. -*/ -class MultiTermDocs:public virtual TermDocs { -private: -protected: - TermDocs** readerTermDocs; - IndexReader** subReaders; - int32_t subReadersLength; - const int32_t* starts; - Term* term; - int32_t base; - int32_t pointer; - - TermDocs* current; // == segTermDocs[pointer] -public: - MultiTermDocs(); - MultiTermDocs(IndexReader** subReaders, const int32_t* s); - virtual ~MultiTermDocs(); - - int32_t doc() const; - int32_t freq() const; - - void seek(TermEnum* termEnum); - void seek(Term* tterm); - bool next(); - - /** Optimized implementation. */ - int32_t read(int32_t* docs, int32_t* freqs, int32_t length); - - /** As yet unoptimized implementation. */ - bool skipTo(const int32_t target); - - void close(); - - virtual TermPositions* __asTermPositions(); -protected: - virtual TermDocs* termDocs(const IndexReader* reader) const; -private: - TermDocs* termDocs(const int32_t i) const; - -}; - - -//MultiTermEnum represents the enumeration of all terms of all readers -class MultiTermEnum:public TermEnum { -private: - SegmentMergeQueue* queue; - - Term* _term; - int32_t _docFreq; -public: - //Constructor - //Opens all enumerations of all readers - MultiTermEnum(IndexReader** subReaders, const int32_t* starts, const Term* t); - - //Destructor - ~MultiTermEnum(); - - //Move the current term to the next in the set of enumerations - bool next(); - - //Returns a pointer to the current term of the set of enumerations - Term* term(); - Term* term(bool pointer); - - //Returns the document frequency of the current term in the set - int32_t docFreq() const; - - //Closes the set of enumerations in the queue - void close(); - - - const char* getObjectName(){ return MultiTermEnum::getClassName(); } - static const char* getClassName(){ return "MultiTermEnum"; } -}; - - -#if _MSC_VER - #pragma warning(disable : 4250) -#endif -class MultiTermPositions:public MultiTermDocs,public TermPositions { -public: - MultiTermPositions(IndexReader** subReaders, const int32_t* s); - ~MultiTermPositions() {}; - int32_t nextPosition(); - - /** - * Not implemented. - * @throws UnsupportedOperationException - */ - int32_t getPayloadLength() const { - _CLTHROWA(CL_ERR_UnsupportedOperation,"UnsupportedOperationException: MultiTermPositions::getPayloadLength"); - } - - /** - * Not implemented. - * @throws UnsupportedOperationException - */ - uint8_t* getPayload(uint8_t* data, int32_t offset) { - _CLTHROWA(CL_ERR_UnsupportedOperation,"UnsupportedOperationException: MultiTermPositions::getPayload"); - } - - /** - * - * @return false - */ - // TODO: Remove warning after API has been finalized - bool isPayloadAvailable() const { - return false; - } - - virtual TermDocs* __asTermDocs(); - virtual TermPositions* __asTermPositions(); -protected: - TermDocs* termDocs(const IndexReader* reader) const; -}; - - - class MultiReader::Internal: LUCENE_BASE{ public: bool _hasDeletions; - IndexReader** subReaders; - int32_t subReadersLength; - int32_t* starts; // 1st docno for each segment uint8_t* ones; + MultiReader* _this; CL_NS(util)::CLHashtable<const TCHAR*,uint8_t*, CL_NS(util)::Compare::TChar, @@ -157,64 +37,60 @@ int32_t _maxDoc; int32_t _numDocs; - Internal(): + Internal(IndexReader** subReaders, MultiReader* _this): normsCache(true, true) - { - } - - void initialize(IndexReader** subReaders){ - - this->subReadersLength = 0; - this->subReaders = subReaders; - - //count the subReaders size - if ( subReaders != NULL ){ - while ( subReaders[subReadersLength] != NULL ){ - subReadersLength++; - } - } + { + this->_this = _this; + _this->subReadersLength = 0; + _this->subReaders = subReaders; + + //count the subReaders size + if ( _this->subReaders != NULL ){ + while ( _this->subReaders[_this->subReadersLength] != NULL ) + _this->subReadersLength++; + } + + _maxDoc = 0; _numDocs = -1; ones = NULL; - starts = _CL_NEWARRAY(int32_t,subReadersLength + 1); // build starts array - for (int32_t i = 0; i < subReadersLength; i++) { - starts[i] = _maxDoc; + _this->starts = _CL_NEWARRAY(int32_t, _this->subReadersLength + 1); // build starts array + for (int32_t i = 0; i < _this->subReadersLength; i++) { + _this->starts[i] = _maxDoc; // compute maxDocs - _maxDoc += subReaders[i]->maxDoc(); - if (subReaders[i]->hasDeletions()) + _maxDoc += _this->subReaders[i]->maxDoc(); + if (_this->subReaders[i]->hasDeletions()) _hasDeletions = true; } - starts[subReadersLength] = _maxDoc; + _this->starts[_this->subReadersLength] = _maxDoc; } ~Internal(){ _CLDELETE_ARRAY(ones); - _CLDELETE_ARRAY(starts); + _CLDELETE_ARRAY(_this->starts); //Iterate through the subReaders and destroy each reader - if (subReaders && subReadersLength > 0) { - for (int32_t i = 0; i < subReadersLength; i++) { - _CLDELETE(subReaders[i]); + if (_this->subReaders && _this->subReadersLength > 0) { + for (int32_t i = 0; i < _this->subReadersLength; i++) { + _CLDELETE(_this->subReaders[i]); } } //Destroy the subReaders array - _CLDELETE_ARRAY(subReaders); + _CLDELETE_ARRAY(_this->subReaders); } }; MultiReader::MultiReader(IndexReader** subReaders): IndexReader(subReaders == NULL || subReaders[0] == NULL ? NULL : subReaders[0]->getDirectory()) { - this->internal = _CLNEW Internal; - this->internal->initialize(subReaders); + this->internal = _CLNEW Internal(subReaders, this); } MultiReader::MultiReader(Directory* directory, SegmentInfos* sis, IndexReader** subReaders): IndexReader(directory, sis, false) { - this->internal = _CLNEW Internal; - this->internal->initialize(subReaders); + this->internal = _CLNEW Internal(subReaders, this); } @@ -229,12 +105,12 @@ bool MultiReader::getTermFreqVectors(int32_t n, Array<TermFreqVector*>& result){ int32_t i = readerIndex(n); // find segment num - return internal->subReaders[i]->getTermFreqVectors(n - internal->starts[i], result); // dispatch to segment + return subReaders[i]->getTermFreqVectors(n - starts[i], result); // dispatch to segment } TermFreqVector* MultiReader::getTermFreqVector(int32_t n, const TCHAR* field){ int32_t i = readerIndex(n); // find segment num - return internal->subReaders[i]->getTermFreqVector(n - internal->starts[i], field); + return subReaders[i]->getTermFreqVector(n - starts[i], field); } @@ -242,8 +118,8 @@ SCOPED_LOCK_MUTEX(THIS_LOCK) if (internal->_numDocs == -1) { // check cache int32_t n = 0; // cache miss--recompute - for (int32_t i = 0; i < internal->subReadersLength; i++) - n += internal->subReaders[i]->numDocs(); // sum from readers + for (int32_t i = 0; i < subReadersLength; i++) + n += subReaders[i]->numDocs(); // sum from readers internal->_numDocs = n; } return internal->_numDocs; @@ -255,12 +131,12 @@ bool MultiReader::document(int32_t n, CL_NS(document)::Document* doc){ int32_t i = readerIndex(n); // find segment num - return internal->subReaders[i]->document(n - internal->starts[i],doc); // dispatch to segment reader + return subReaders[i]->document(n - starts[i],doc); // dispatch to segment reader } bool MultiReader::isDeleted(const int32_t n) { int32_t i = readerIndex(n); // find segment num - return internal->subReaders[i]->isDeleted(n - internal->starts[i]); // dispatch to segment reader + return subReaders[i]->isDeleted(n - starts[i]); // dispatch to segment reader } bool MultiReader::hasDeletions() const{ @@ -279,8 +155,8 @@ return fakeNorms(); bytes = _CL_NEWARRAY(uint8_t,maxDoc()); - for (int32_t i = 0; i < internal->subReadersLength; i++) - internal->subReaders[i]->norms(field, bytes + internal->starts[i]); + for (int32_t i = 0; i < subReadersLength; i++) + subReaders[i]->norms(field, bytes + starts[i]); //Unfortunately the data in the normCache can get corrupted, since it's being loaded with string //keys that may be deleted while still in use by the map. To prevent this field is duplicated @@ -303,62 +179,62 @@ memcpy(result,bytes,len * sizeof(int32_t)); } - for (int32_t i = 0; i < internal->subReadersLength; i++) // read from segments - internal->subReaders[i]->norms(field, result + internal->starts[i]); + for (int32_t i = 0; i < subReadersLength; i++) // read from segments + subReaders[i]->norms(field, result + starts[i]); } void MultiReader::doSetNorm(int32_t n, const TCHAR* field, uint8_t value){ internal->normsCache.remove(field); // clear cache int32_t i = readerIndex(n); // find segment num - internal->subReaders[i]->setNorm(n-internal->starts[i], field, value); // dispatch + subReaders[i]->setNorm(n-starts[i], field, value); // dispatch } TermEnum* MultiReader::terms() const { - return _CLNEW MultiTermEnum(internal->subReaders, internal->starts, NULL); + return _CLNEW MultiTermEnum(subReaders, starts, NULL); } TermEnum* MultiReader::terms(const Term* term) const { - return _CLNEW MultiTermEnum(internal->subReaders, internal->starts, term); + return _CLNEW MultiTermEnum(subReaders, starts, term); } int32_t MultiReader::docFreq(const Term* t) const { int32_t total = 0; // sum freqs in Multi - for (int32_t i = 0; i < internal->subReadersLength; i++) - total += internal->subReaders[i]->docFreq(t); + for (int32_t i = 0; i < subReadersLength; i++) + total += subReaders[i]->docFreq(t); return total; } TermDocs* MultiReader::termDocs() const { - TermDocs* ret = _CLNEW MultiTermDocs(internal->subReaders, internal->starts); + TermDocs* ret = _CLNEW MultiTermDocs(subReaders, starts); return ret; } TermPositions* MultiReader::termPositions() const { - TermPositions* ret = (TermPositions*)_CLNEW MultiTermPositions(internal->subReaders, internal->starts); + TermPositions* ret = (TermPositions*)_CLNEW MultiTermPositions(subReaders, starts); return ret; } void MultiReader::doDelete(const int32_t n) { internal->_numDocs = -1; // invalidate cache int32_t i = readerIndex(n); // find segment num - internal->subReaders[i]->deleteDocument(n - internal->starts[i]); // dispatch to segment reader + subReaders[i]->deleteDocument(n - starts[i]); // dispatch to segment reader internal->_hasDeletions = true; } int32_t MultiReader::readerIndex(const int32_t n) const { // find reader for doc n: int32_t lo = 0; // search starts array - int32_t hi = internal->subReadersLength - 1; // for first element less + int32_t hi = subReadersLength - 1; // for first element less // than n, return its index while (hi >= lo) { int32_t mid = (lo + hi) >> 1; - int32_t midValue = internal->starts[mid]; + int32_t midValue = starts[mid]; if (n < midValue) hi = mid - 1; else if (n > midValue) lo = mid + 1; else{ // found a match - while (mid+1 < internal->subReadersLength && internal->starts[mid+1] == midValue) { + while (mid+1 < subReadersLength && starts[mid+1] == midValue) { mid++; // scan to last match } return mid; @@ -368,8 +244,8 @@ } bool MultiReader::hasNorms(const TCHAR* field) { - for (int i = 0; i < internal->subReadersLength; i++) { - if (internal->subReaders[i]->hasNorms(field)) + for (int i = 0; i < subReadersLength; i++) { + if (subReaders[i]->hasNorms(field)) return true; } return false; @@ -381,20 +257,20 @@ } void MultiReader::doUndeleteAll(){ - for (int32_t i = 0; i < internal->subReadersLength; i++) - internal->subReaders[i]->undeleteAll(); + for (int32_t i = 0; i < subReadersLength; i++) + subReaders[i]->undeleteAll(); internal->_hasDeletions = false; internal->_numDocs = -1; } void MultiReader::doCommit() { - for (int32_t i = 0; i < internal->subReadersLength; i++) - internal->subReaders[i]->commit(); + for (int32_t i = 0; i < subReadersLength; i++) + subReaders[i]->commit(); } void MultiReader::doClose() { SCOPED_LOCK_MUTEX(THIS_LOCK) - for (int32_t i = 0; i < internal->subReadersLength; i++){ - internal->subReaders[i]->close(); + for (int32_t i = 0; i < subReadersLength; i++){ + subReaders[i]->close(); } } @@ -402,8 +278,8 @@ void MultiReader::getFieldNames(FieldOption fldOption, StringArrayWithDeletor& retarray){ StringArrayWithDeletor temp; CLHashList<TCHAR*> hashList; - for (int32_t i = 0; i < internal->subReadersLength; i++) { - IndexReader* reader = internal->subReaders[i]; + for (int32_t i = 0; i < subReadersLength; i++) { + IndexReader* reader = subReaders[i]; reader->getFieldNames(fldOption, temp); //create a unique list of names. @@ -620,8 +496,7 @@ } TermDocs* MultiTermDocs::termDocs(const IndexReader* reader) const { - TermDocs* ret = reader->termDocs(); - return ret; + return reader->termDocs(); } TermDocs* MultiTermDocs::termDocs(const int32_t i) const { Modified: branches/lucene2_3_2/src/core/CLucene/index/MultiReader.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/MultiReader.h 2008-09-27 09:50:21 UTC (rev 2900) +++ branches/lucene2_3_2/src/core/CLucene/index/MultiReader.h 2008-09-27 09:55:18 UTC (rev 2901) @@ -24,6 +24,10 @@ bool hasNorms(const TCHAR* field); uint8_t* fakeNorms(); protected: + IndexReader** subReaders; + int32_t subReadersLength; + int32_t* starts; // 1st docno for each segment + void doSetNorm(int32_t n, const TCHAR* field, uint8_t value); void doUndeleteAll(); void doCommit(); Added: branches/lucene2_3_2/src/core/CLucene/index/_MultiReader.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/_MultiReader.h (rev 0) +++ branches/lucene2_3_2/src/core/CLucene/index/_MultiReader.h 2008-09-27 09:55:18 UTC (rev 2901) @@ -0,0 +1,133 @@ +/*------------------------------------------------------------------------------ +* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team +* +* Distributable under the terms of either the Apache License (Version 2.0) or +* the GNU Lesser General Public License, as specified in the COPYING file. +------------------------------------------------------------------------------*/ +#ifndef _lucene_index_internal_MultiReader_ +#define _lucene_index_internal_MultiReader_ + +#include "Terms.h" +#include "CLucene/util/PriorityQueue.h" +#include "_SegmentMergeInfo.h" +#include "_SegmentMergeQueue.h" + +CL_NS_DEF(index) + +/** An IndexReader which reads multiple indexes, appending their content. +*/ +class MultiTermDocs:public virtual TermDocs { +protected: + TermDocs** readerTermDocs; + + IndexReader** subReaders; + int32_t subReadersLength; + const int32_t* starts; + Term* term; + + int32_t base; + int32_t pointer; + + TermDocs* current; // == segTermDocs[pointer] + TermDocs* termDocs(const int32_t i) const; //< internal use only + virtual TermDocs* termDocs(const IndexReader* reader) const; +public: + MultiTermDocs(); + MultiTermDocs(IndexReader** subReaders, const int32_t* s); + virtual ~MultiTermDocs(); + + int32_t doc() const; + int32_t freq() const; + + void seek(TermEnum* termEnum); + void seek(Term* tterm); + bool next(); + + /** Optimized implementation. */ + int32_t read(int32_t* docs, int32_t* freqs, int32_t length); + + /** As yet unoptimized implementation. */ + bool skipTo(const int32_t target); + + void close(); + + virtual TermPositions* __asTermPositions(); +}; + + +//MultiTermEnum represents the enumeration of all terms of all readers +class MultiTermEnum:public TermEnum { +private: + SegmentMergeQueue* queue; + + Term* _term; + int32_t _docFreq; +public: + //Constructor + //Opens all enumerations of all readers + MultiTermEnum(IndexReader** subReaders, const int32_t* starts, const Term* t); + + //Destructor + ~MultiTermEnum(); + + //Move the current term to the next in the set of enumerations + bool next(); + + //Returns a pointer to the current term of the set of enumerations + Term* term(); + Term* term(bool pointer); + + //Returns the document frequency of the current term in the set + int32_t docFreq() const; + + //Closes the set of enumerations in the queue + void close(); + + + const char* getObjectName(){ return MultiTermEnum::getClassName(); } + static const char* getClassName(){ return "MultiTermEnum"; } +}; + + +#if _MSC_VER + #pragma warning(disable : 4250) +#endif +class MultiTermPositions:public MultiTermDocs,public TermPositions { +protected: + TermDocs* termDocs(const IndexReader* reader) const; +public: + MultiTermPositions(IndexReader** subReaders, const int32_t* s); + ~MultiTermPositions() {}; + int32_t nextPosition(); + + /** + * Not implemented. + * @throws UnsupportedOperationException + */ + int32_t getPayloadLength() const { + _CLTHROWA(CL_ERR_UnsupportedOperation,"UnsupportedOperationException: MultiTermPositions::getPayloadLength"); + } + + /** + * Not implemented. + * @throws UnsupportedOperationException + */ + uint8_t* getPayload(uint8_t* data, int32_t offset) { + _CLTHROWA(CL_ERR_UnsupportedOperation,"UnsupportedOperationException: MultiTermPositions::getPayload"); + } + + /** + * + * @return false + */ + // TODO: Remove warning after API has been finalized + bool isPayloadAvailable() const { + return false; + } + + virtual TermDocs* __asTermDocs(); + virtual TermPositions* __asTermPositions(); +}; +CL_NS_END + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 09:50:31
|
Revision: 2900 http://clucene.svn.sourceforge.net/clucene/?rev=2900&view=rev Author: ustramooner Date: 2008-09-27 09:50:21 +0000 (Sat, 27 Sep 2008) Log Message: ----------- removed linking against static shared library. this is a corner case requirement, in my opinion Modified Paths: -------------- branches/lucene2_3_2/CMakeLists.txt branches/lucene2_3_2/src/contribs/CMakeLists.txt branches/lucene2_3_2/src/core/CMakeLists.txt branches/lucene2_3_2/src/demo/CMakeLists.txt branches/lucene2_3_2/src/shared/CLucene/CLSharedMonolithic.cpp branches/lucene2_3_2/src/test/CMakeLists.txt Modified: branches/lucene2_3_2/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/CMakeLists.txt 2008-09-27 09:47:28 UTC (rev 2899) +++ branches/lucene2_3_2/CMakeLists.txt 2008-09-27 09:50:21 UTC (rev 2900) @@ -75,10 +75,6 @@ "enable various projects that test alternative build switches" ${ENABLE_COMPILE_TESTS_VALUE}) -OPTION(USE_STATIC_SHARED_LIBRARY - "Link libraries and executables against the static linked clucene-shared library instead of shared" - OFF) - #check flags... INCLUDE (TestCXXAcceptsFlag) IF ( CMAKE_COMPILER_IS_GNUCC ) Modified: branches/lucene2_3_2/src/contribs/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/contribs/CMakeLists.txt 2008-09-27 09:47:28 UTC (rev 2899) +++ branches/lucene2_3_2/src/contribs/CMakeLists.txt 2008-09-27 09:50:21 UTC (rev 2900) @@ -137,11 +137,7 @@ ${clucene_contribs_Files} ${clucene_shared_Files} ${HEADERS} ) IF ( NOT USE_SHARED_OBJECT_FILES ) - IF ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(clucene-contribs clucene-shared-static) - ELSE ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(clucene-contribs clucene-shared) - ENDIF ( USE_STATIC_SHARED_LIBRARY ) + TARGET_LINK_LIBRARIES(clucene-contribs clucene-shared) ENDIF ( NOT USE_SHARED_OBJECT_FILES ) add_library(clucene-contribs-static STATIC Modified: branches/lucene2_3_2/src/core/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/core/CMakeLists.txt 2008-09-27 09:47:28 UTC (rev 2899) +++ branches/lucene2_3_2/src/core/CMakeLists.txt 2008-09-27 09:50:21 UTC (rev 2900) @@ -19,6 +19,7 @@ SET(clucene_core_Files ./CLucene/StdHeader.cpp + ./CLucene/debug/error.cpp ./CLucene/util/ThreadLocal.cpp ./CLucene/util/Reader.cpp ./CLucene/util/Equators.cpp @@ -26,6 +27,7 @@ ./CLucene/util/fileinputstream.cpp ./CLucene/util/MD5Digester.cpp ./CLucene/util/StringIntern.cpp + ./CLucene/util/subinputstream.cpp ./CLucene/util/BitSet.cpp ./CLucene/queryParser/Lexer.cpp ./CLucene/queryParser/MultiFieldQueryParser.cpp @@ -149,11 +151,7 @@ #link the clucene-core library against the releavent clucene-shared library (if we aren't using the object files) IF ( NOT USE_SHARED_OBJECT_FILES ) - IF ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(clucene-core clucene-shared-static} ) - ELSE ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(clucene-core clucene-shared ${CMAKE_THREAD_LIBS_INIT}) - ENDIF ( USE_STATIC_SHARED_LIBRARY ) + TARGET_LINK_LIBRARIES(clucene-core clucene-shared) ENDIF ( NOT USE_SHARED_OBJECT_FILES ) SET_TARGET_PROPERTIES(clucene-core-static PROPERTIES Modified: branches/lucene2_3_2/src/demo/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/demo/CMakeLists.txt 2008-09-27 09:47:28 UTC (rev 2899) +++ branches/lucene2_3_2/src/demo/CMakeLists.txt 2008-09-27 09:50:21 UTC (rev 2900) @@ -21,8 +21,4 @@ ${demo_HEADERS} ) -IF ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(cl_demo clucene-core clucene-shared-static) -ELSE ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(cl_demo clucene-core clucene-shared) -ENDIF ( USE_STATIC_SHARED_LIBRARY ) +TARGET_LINK_LIBRARIES(cl_demo clucene-core clucene-shared) Modified: branches/lucene2_3_2/src/shared/CLucene/CLSharedMonolithic.cpp =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/CLSharedMonolithic.cpp 2008-09-27 09:47:28 UTC (rev 2899) +++ branches/lucene2_3_2/src/shared/CLucene/CLSharedMonolithic.cpp 2008-09-27 09:50:21 UTC (rev 2900) @@ -21,7 +21,6 @@ #include "CLucene/config/threads.cpp" #include "CLucene/config/utf8.cpp" #include "CLucene/debug/condition.cpp" -#include "CLucene/debug/error.cpp" #include "CLucene/util/Misc.cpp" #include "CLucene/util/dirent.cpp" #include "CLucene/util/StringBuffer.cpp" Modified: branches/lucene2_3_2/src/test/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/test/CMakeLists.txt 2008-09-27 09:47:28 UTC (rev 2899) +++ branches/lucene2_3_2/src/test/CMakeLists.txt 2008-09-27 09:50:21 UTC (rev 2900) @@ -51,11 +51,7 @@ #link the executable against the releavent clucene-shared library (if we aren't using the object files) IF ( NOT USE_SHARED_OBJECT_FILES ) - IF ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(cl_test clucene-core clucene-shared-static) - ELSE ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(cl_test clucene-core clucene-shared) - ENDIF ( USE_STATIC_SHARED_LIBRARY ) + TARGET_LINK_LIBRARIES(cl_test clucene-core clucene-shared) ENDIF ( NOT USE_SHARED_OBJECT_FILES ) ############################ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 09:47:39
|
Revision: 2899 http://clucene.svn.sourceforge.net/clucene/?rev=2899&view=rev Author: ustramooner Date: 2008-09-27 09:47:28 +0000 (Sat, 27 Sep 2008) Log Message: ----------- moved CLuceneError out of shared and into core. makes it easier for linking, since you only need to link to core. Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/CLMonolithic.cpp branches/lucene2_3_2/src/core/CLucene/StdHeader.h branches/lucene2_3_2/src/shared/CLucene/SharedHeader.h branches/lucene2_3_2/src/shared/CLucene/util/Misc.cpp branches/lucene2_3_2/src/shared/CLucene/util/StringBuffer.cpp branches/lucene2_3_2/src/shared/CMakeLists.txt Added Paths: ----------- branches/lucene2_3_2/src/core/CLucene/debug/error.cpp branches/lucene2_3_2/src/core/CLucene/debug/error.h Removed Paths: ------------- branches/lucene2_3_2/src/shared/CLucene/debug/error.cpp branches/lucene2_3_2/src/shared/CLucene/debug/error.h Modified: branches/lucene2_3_2/src/core/CLucene/CLMonolithic.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/CLMonolithic.cpp 2008-09-27 09:36:09 UTC (rev 2898) +++ branches/lucene2_3_2/src/core/CLucene/CLMonolithic.cpp 2008-09-27 09:47:28 UTC (rev 2899) @@ -11,6 +11,7 @@ * note: when creating a project add either this file, or all the other .cpp files, not both! */ #include "CLucene/StdHeader.cpp" +#include "CLucene/debug/error.cpp" #include "CLucene/analysis/Analyzers.cpp" #include "CLucene/analysis/AnalysisHeader.cpp" #include "CLucene/analysis/standard/StandardAnalyzer.cpp" Modified: branches/lucene2_3_2/src/core/CLucene/StdHeader.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/StdHeader.h 2008-09-27 09:36:09 UTC (rev 2898) +++ branches/lucene2_3_2/src/core/CLucene/StdHeader.h 2008-09-27 09:47:28 UTC (rev 2899) @@ -19,6 +19,9 @@ //shared header #include "CLucene/SharedHeader.h" +//error handling macros/functions +#include "CLucene/debug/error.h" + //todo: would be good to deprecate this... it's ugly #define StringArrayWithDeletor CL_NS(util)::CLVector<TCHAR*, CL_NS(util)::Deletor::tcArray > #define StringArray std::vector<TCHAR*> Copied: branches/lucene2_3_2/src/core/CLucene/debug/error.cpp (from rev 2892, branches/lucene2_3_2/src/shared/CLucene/debug/error.cpp) =================================================================== --- branches/lucene2_3_2/src/core/CLucene/debug/error.cpp (rev 0) +++ branches/lucene2_3_2/src/core/CLucene/debug/error.cpp 2008-09-27 09:47:28 UTC (rev 2899) @@ -0,0 +1,74 @@ +/*------------------------------------------------------------------------------ +* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team +* +* Distributable under the terms of either the Apache License (Version 2.0) or +* the GNU Lesser General Public License, as specified in the COPYING file. +------------------------------------------------------------------------------*/ +#include "CLucene/_SharedHeader.h" +#include "error.h" +#include "CLucene/util/Misc.h" +CL_NS_USE(util) + + +#ifdef _LUCENE_DISABLE_EXCEPTIONS + #ifdef _LUCENE_PRAGMA_WARNINGS + #pragma message ("==================Lucene exceptions are disabled==================") + #else + #warning "==================Lucene exceptions are disabled==================" + #endif +#else + CLuceneError::CLuceneError(int num, const char* str, bool ownstr) + { + error_number = num; + _awhat=STRDUP_AtoA(str); + _twhat=NULL; + if ( ownstr ) + _CLDELETE_CaARRAY(str); + } + + CLuceneError::CLuceneError(const CLuceneError& clone) + { + this->error_number = clone.error_number; + this->_awhat = NULL; + this->_twhat = NULL; + + if ( clone._awhat != NULL ) + this->_awhat = STRDUP_AtoA(clone._awhat); + if ( clone._twhat != NULL ) + this->_twhat = STRDUP_TtoT(clone._twhat); + } + CLuceneError::~CLuceneError() throw(){ + _CLDELETE_CARRAY(_twhat); + _CLDELETE_CaARRAY(_awhat); + } + char* CLuceneError::what(){ +#ifdef _ASCII + if ( _twhat != NULL ) + return _twhat; +#endif + if ( _awhat == NULL ) + _awhat = STRDUP_TtoA(_twhat); + return _awhat; + } + TCHAR* CLuceneError::twhat(){ +#ifdef _ASCII + if ( _awhat != NULL ) + return _awhat; +#endif + if ( _twhat == NULL ) + _twhat = STRDUP_AtoT(_awhat); + return _twhat; + } + +#ifndef _ASCII + CLuceneError::CLuceneError(int num, const TCHAR* str, bool ownstr) + { + error_number = num; + _awhat=NULL; + _twhat=STRDUP_TtoT(str); + if ( ownstr ) + _CLDELETE_CARRAY(str); + } +#endif + +#endif //_LUCENE_DISABLE_EXCEPTIONS Property changes on: branches/lucene2_3_2/src/core/CLucene/debug/error.cpp ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/lucene2_3_2/src/core/CLucene/debug/error.h (from rev 2892, branches/lucene2_3_2/src/shared/CLucene/debug/error.h) =================================================================== --- branches/lucene2_3_2/src/core/CLucene/debug/error.h (rev 0) +++ branches/lucene2_3_2/src/core/CLucene/debug/error.h 2008-09-27 09:47:28 UTC (rev 2899) @@ -0,0 +1,87 @@ +/*------------------------------------------------------------------------------ +* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team +* +* Distributable under the terms of either the Apache License (Version 2.0) or +* the GNU Lesser General Public License, as specified in the COPYING file. +------------------------------------------------------------------------------*/ +#ifndef _lucene_debug_error_ +#define _lucene_debug_error_ + + +#define CL_ERR_UNKNOWN -1 +#define CL_ERR_IO 1 +#define CL_ERR_NullPointer 2 +#define CL_ERR_Runtime 3 +#define CL_ERR_IllegalArgument 4 +#define CL_ERR_Parse 5 +#define CL_ERR_TokenMgr 6 +#define CL_ERR_UnsupportedOperation 7 +#define CL_ERR_InvalidState 8 +#define CL_ERR_IndexOutOfBounds 9 +#define CL_ERR_TooManyClauses 10 +#define CL_ERR_RAMTransaction 11 +#define CL_ERR_InvalidCast 12 +#define CL_ERR_IllegalState 13 // Sub-error: AlreadyClosed +#define CL_ERR_UnknownOperator 14 +#define CL_ERR_ConcurrentModification 15 +#define CL_ERR_CorruptIndex 16 + + + +//////////////////////////////////////////////////////// +//error try/throw/catch definitions +//////////////////////////////////////////////////////// +#ifdef _CL_DISABLE_NATIVE_EXCEPTIONS + #include <setjmp.h> + + /* + #define try struct pj_exception_state_t pj_x_except__; int pj_x_code__; \ + if(1){ \ + pj_push_exception_handler_(&pj_x_except__); \ + pj_x_code__ = pj_setjmp(pj_x_except__.state); \ + if (pj_x_code__ == 0) + #define _CLCATCHEND pj_pop_exception_handler_(); \ + } else {} + #define _CLCATCH else if (pj_x_code__ == (id)) _CLCATCHEND + #define _CLCATCHANY else _CLCATCHEND + #define _RETHROW pj_throw_exception_(pj_x_code__) + + #define _CLFINALLY(x) else{x _RETHROW}_CLCATCHEND x + #define _CLTHROWA(number) pj_throw_exception_(number) + #define _CLTHROWT(number) pj_throw_exception_(number) + #define _THROWA_DEL(number) _CLDELETE_CaARRAY(str); pj_throw_exception_(number) + #define _THROWT_DEL(number) _CLDELETE_CARRAY(str); pj_throw_exception_(number) + + */ +#else + class CLUCENE_EXPORT CLuceneError + { + int error_number; + char* _awhat; + TCHAR* _twhat; + public: + CLuceneError(const CLuceneError& clone); + CLuceneError(int num, const char* str, bool ownstr); +#ifdef _UCS2 + CLuceneError(int num, const TCHAR* str, bool ownstr); +#endif + int number(){return error_number;} + char* what(); + TCHAR* twhat(); + ~CLuceneError() throw(); + }; + + //#define _THROWS //does nothing + #define _TRY try + #define _CLFINALLY(x) catch(...){ x; throw; } x //note: code x is not run if return is called + #define _CLTHROWA(number, str) throw CLuceneError(number, str,false) + #define _CLTHROWT(number, str) throw CLuceneError(number, str,false) + #define _CLTHROWA_DEL(number, str) throw CLuceneError(number, str,true) //throw a string ensures the value is deleted + #define _CLTHROWT_DEL(number, str) throw CLuceneError(number, str,true) //throw a string ensures the value is deleted + + +#endif //_LUCENE_DISABLE_EXCEPTIONS +// +//////////////////////////////////////////////////////// + +#endif Property changes on: branches/lucene2_3_2/src/core/CLucene/debug/error.h ___________________________________________________________________ Added: svn:mergeinfo + Modified: branches/lucene2_3_2/src/shared/CLucene/SharedHeader.h =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/SharedHeader.h 2008-09-27 09:36:09 UTC (rev 2898) +++ branches/lucene2_3_2/src/shared/CLucene/SharedHeader.h 2008-09-27 09:47:28 UTC (rev 2899) @@ -86,6 +86,9 @@ #define CL_STRUCT_DEF(sub,clazz) namespace lucene { namespace sub{ struct clazz; } } #define CL_CLASS_DEF(sub,clazz) namespace lucene { namespace sub{ class clazz; } } #define CL_CLASS_DEF2(sub,sub2, clazz) namespace lucene { namespace sub{ namespace sub2{ class clazz; } } } + + #define CL_TEMPATE_DEF(sub, clazz, typedefs) namespace lucene { namespace sub{ template<typedefs> class clazz; }} + #define CL_TYPE_DEF(sub, clazz, def) namespace lucene { namespace sub{ typedef def clazz; }} #else #define CL_NS_DEF(sub) #define CL_NS_DEF2(sub, sub2) @@ -190,9 +193,6 @@ #include "CLucene/debug/lucenebase.h" //////////////////////////////////////////////////////// -//error handling macros/functions -#include "CLucene/debug/error.h" - //memory handling macros/functions #include "CLucene/debug/mem.h" Deleted: branches/lucene2_3_2/src/shared/CLucene/debug/error.cpp =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/debug/error.cpp 2008-09-27 09:36:09 UTC (rev 2898) +++ branches/lucene2_3_2/src/shared/CLucene/debug/error.cpp 2008-09-27 09:47:28 UTC (rev 2899) @@ -1,73 +0,0 @@ -/*------------------------------------------------------------------------------ -* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team -* -* Distributable under the terms of either the Apache License (Version 2.0) or -* the GNU Lesser General Public License, as specified in the COPYING file. -------------------------------------------------------------------------------*/ -#include "CLucene/_SharedHeader.h" -#include "CLucene/util/Misc.h" -CL_NS_USE(util) - - -#ifdef _LUCENE_DISABLE_EXCEPTIONS - #ifdef _LUCENE_PRAGMA_WARNINGS - #pragma message ("==================Lucene exceptions are disabled==================") - #else - #warning "==================Lucene exceptions are disabled==================" - #endif -#else - CLuceneError::CLuceneError(int num, const char* str, bool ownstr) - { - error_number = num; - _awhat=STRDUP_AtoA(str); - _twhat=NULL; - if ( ownstr ) - _CLDELETE_CaARRAY(str); - } - - CLuceneError::CLuceneError(const CLuceneError& clone) - { - this->error_number = clone.error_number; - this->_awhat = NULL; - this->_twhat = NULL; - - if ( clone._awhat != NULL ) - this->_awhat = STRDUP_AtoA(clone._awhat); - if ( clone._twhat != NULL ) - this->_twhat = STRDUP_TtoT(clone._twhat); - } - CLuceneError::~CLuceneError() throw(){ - _CLDELETE_CARRAY(_twhat); - _CLDELETE_CaARRAY(_awhat); - } - char* CLuceneError::what(){ -#ifdef _ASCII - if ( _twhat != NULL ) - return _twhat; -#endif - if ( _awhat == NULL ) - _awhat = STRDUP_TtoA(_twhat); - return _awhat; - } - TCHAR* CLuceneError::twhat(){ -#ifdef _ASCII - if ( _awhat != NULL ) - return _awhat; -#endif - if ( _twhat == NULL ) - _twhat = STRDUP_AtoT(_awhat); - return _twhat; - } - -#ifndef _ASCII - CLuceneError::CLuceneError(int num, const TCHAR* str, bool ownstr) - { - error_number = num; - _awhat=NULL; - _twhat=STRDUP_TtoT(str); - if ( ownstr ) - _CLDELETE_CARRAY(str); - } -#endif - -#endif //_LUCENE_DISABLE_EXCEPTIONS Deleted: branches/lucene2_3_2/src/shared/CLucene/debug/error.h =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/debug/error.h 2008-09-27 09:36:09 UTC (rev 2898) +++ branches/lucene2_3_2/src/shared/CLucene/debug/error.h 2008-09-27 09:47:28 UTC (rev 2899) @@ -1,86 +0,0 @@ -/*------------------------------------------------------------------------------ -* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team -* -* Distributable under the terms of either the Apache License (Version 2.0) or -* the GNU Lesser General Public License, as specified in the COPYING file. -------------------------------------------------------------------------------*/ -#ifndef _lucene_debug_error_ -#define _lucene_debug_error_ - - -#define CL_ERR_UNKNOWN -1 -#define CL_ERR_IO 1 -#define CL_ERR_NullPointer 2 -#define CL_ERR_Runtime 3 -#define CL_ERR_IllegalArgument 4 -#define CL_ERR_Parse 5 -#define CL_ERR_TokenMgr 6 -#define CL_ERR_UnsupportedOperation 7 -#define CL_ERR_InvalidState 8 -#define CL_ERR_IndexOutOfBounds 9 -#define CL_ERR_TooManyClauses 10 -#define CL_ERR_RAMTransaction 11 -#define CL_ERR_InvalidCast 12 -#define CL_ERR_IllegalState 13 // Sub-error: AlreadyClosed -#define CL_ERR_UnknownOperator 14 -#define CL_ERR_ConcurrentModification 15 -#define CL_ERR_CorruptIndex 16 - - - -//////////////////////////////////////////////////////// -//error try/throw/catch definitions -//////////////////////////////////////////////////////// -#ifdef _CL_DISABLE_NATIVE_EXCEPTIONS - #include <setjmp.h> - /* - #define try struct pj_exception_state_t pj_x_except__; int pj_x_code__; \ - if(1){ \ - pj_push_exception_handler_(&pj_x_except__); \ - pj_x_code__ = pj_setjmp(pj_x_except__.state); \ - if (pj_x_code__ == 0) - #define _CLCATCHEND pj_pop_exception_handler_(); \ - } else {} - #define _CLCATCH else if (pj_x_code__ == (id)) _CLCATCHEND - #define _CLCATCHANY else _CLCATCHEND - #define _RETHROW pj_throw_exception_(pj_x_code__) - - #define _CLFINALLY(x) else{x _RETHROW}_CLCATCHEND x - #define _CLTHROWA(number) pj_throw_exception_(number) - #define _CLTHROWT(number) pj_throw_exception_(number) - #define _THROWA_DEL(number) _CLDELETE_CaARRAY(str); pj_throw_exception_(number) - #define _THROWT_DEL(number) _CLDELETE_CARRAY(str); pj_throw_exception_(number) - - */ -#else - class CLUCENE_SHARED_EXPORT CLuceneError - { - int error_number; - char* _awhat; - TCHAR* _twhat; - public: - CLuceneError(const CLuceneError& clone); - CLuceneError(int num, const char* str, bool ownstr); -#ifdef _UCS2 - CLuceneError(int num, const TCHAR* str, bool ownstr); -#endif - int number(){return error_number;} - char* what(); - TCHAR* twhat(); - ~CLuceneError() throw(); - }; - - //#define _THROWS //does nothing - #define _TRY try - #define _CLFINALLY(x) catch(...){ x; throw; } x //note: code x is not run if return is called - #define _CLTHROWA(number, str) throw CLuceneError(number, str,false) - #define _CLTHROWT(number, str) throw CLuceneError(number, str,false) - #define _CLTHROWA_DEL(number, str) throw CLuceneError(number, str,true) //throw a string ensures the value is deleted - #define _CLTHROWT_DEL(number, str) throw CLuceneError(number, str,true) //throw a string ensures the value is deleted - - -#endif //_LUCENE_DISABLE_EXCEPTIONS -// -//////////////////////////////////////////////////////// - -#endif Modified: branches/lucene2_3_2/src/shared/CLucene/util/Misc.cpp =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/util/Misc.cpp 2008-09-27 09:36:09 UTC (rev 2898) +++ branches/lucene2_3_2/src/shared/CLucene/util/Misc.cpp 2008-09-27 09:47:28 UTC (rev 2899) @@ -51,13 +51,11 @@ return hashCode; } -//ok, these are the exceptions, but these never -//exist on non-msvc platform, so lets put it here int64_t Misc::filelength(int filehandle) { struct cl_stat_t info; if (fileHandleStat(filehandle, &info) == -1) - _CLTHROWA( CL_ERR_IO,"fileStat error" ); + return -1; return info.st_size; } @@ -125,7 +123,7 @@ #else struct timeval tstruct; if (gettimeofday(&tstruct, NULL) < 0) { - _CLTHROWA(CL_ERR_Runtime,"Error in gettimeofday call."); + return 0; } return (((uint64_t) tstruct.tv_sec) * 1000) + tstruct.tv_usec / 1000; Modified: branches/lucene2_3_2/src/shared/CLucene/util/StringBuffer.cpp =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/util/StringBuffer.cpp 2008-09-27 09:36:09 UTC (rev 2898) +++ branches/lucene2_3_2/src/shared/CLucene/util/StringBuffer.cpp 2008-09-27 09:47:28 UTC (rev 2899) @@ -7,6 +7,7 @@ #include "CLucene/_ApiHeader.h" #include "StringBuffer.h" #include "Misc.h" +#include <assert.h> CL_NS_DEF(util) @@ -157,8 +158,7 @@ //using sprintf("%f" was not reliable on other plaforms... we use a custom float convertor //bvk: also, using sprintf and %f seems excessivelly slow - if(digits>8) - _CLTHROWA(CL_ERR_IllegalArgument,"Too many digits..."); + assert(digits <= 8); //the maximum number of characters that int64 will hold is 23. so we need 23*2+2 TCHAR buf[48]; //the buffer to hold @@ -304,8 +304,7 @@ //More aggressive growth strategy to offset smaller default buffer size: if ( !bufferOwner ){ - if ( bufferLength<minLength ) - _CLTHROWA(CL_ERR_IllegalArgument,"[StringBuffer::grow] un-owned buffer could not be grown"); + assert(bufferLength>=minLength); return; } Modified: branches/lucene2_3_2/src/shared/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/shared/CMakeLists.txt 2008-09-27 09:36:09 UTC (rev 2898) +++ branches/lucene2_3_2/src/shared/CMakeLists.txt 2008-09-27 09:47:28 UTC (rev 2899) @@ -266,8 +266,7 @@ SET(${result} ${rel}/CLucene/SharedHeader.cpp - ${rel}/CLucene/debug/error.cpp - ${rel}/CLucene/config/gunichartables.cpp + ${rel}/CLucene/config/gunichartables.cpp ${rel}/CLucene/config/repl_tcslwr.cpp ${rel}/CLucene/config/repl_tcstoll.cpp ${rel}/CLucene/config/repl_tcscasecmp.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 09:36:17
|
Revision: 2898 http://clucene.svn.sourceforge.net/clucene/?rev=2898&view=rev Author: ustramooner Date: 2008-09-27 09:36:09 +0000 (Sat, 27 Sep 2008) Log Message: ----------- signed comparison warnings removed Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/DocumentWriter.cpp Modified: branches/lucene2_3_2/src/core/CLucene/index/DocumentWriter.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/DocumentWriter.cpp 2008-09-27 09:34:20 UTC (rev 2897) +++ branches/lucene2_3_2/src/core/CLucene/index/DocumentWriter.cpp 2008-09-27 09:36:09 UTC (rev 2898) @@ -177,7 +177,7 @@ } { //msvc6 scope fix - for ( int32_t i=0;i<fieldInfos->size();i++ ) + for ( size_t i=0;i<fieldInfos->size();i++ ) fieldLengths[i] = 0; } //msvc6 scope fix invertDocument(doc); @@ -269,7 +269,7 @@ if(field->isStoreOffsetWithTermVector()){ TermVectorOffsetInfo tio; tio.setStartOffset(offset); - tio.setEndOffset(offset + dataLen); + tio.setEndOffset( (int32_t)(offset + dataLen)); addPosition(fieldName, charBuf, position++, &tio ); }else addPosition(fieldName, charBuf, position++, NULL); @@ -536,7 +536,7 @@ void DocumentWriter::writeNorms(const char* segment) { char fn[CL_MAX_PATH]; - for(int32_t n = 0; n < fieldInfos->size(); n++){ + for(size_t n = 0; n < fieldInfos->size(); n++){ FieldInfo* fi = fieldInfos->fieldInfo(n); if(fi->isIndexed && !fi->omitNorms){ float_t norm = fieldBoosts[n] * similarity->lengthNorm(fi->name, fieldLengths[n]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 09:34:25
|
Revision: 2897 http://clucene.svn.sourceforge.net/clucene/?rev=2897&view=rev Author: ustramooner Date: 2008-09-27 09:34:20 +0000 (Sat, 27 Sep 2008) Log Message: ----------- threading test and a test suite for it. macros for creating threads also provided Modified Paths: -------------- branches/lucene2_3_2/src/shared/CLucene/LuceneThreads.h branches/lucene2_3_2/src/shared/CLucene/config/_threads.h branches/lucene2_3_2/src/shared/CLucene/config/threads.cpp branches/lucene2_3_2/src/test/index/TestReuters.cpp Modified: branches/lucene2_3_2/src/shared/CLucene/LuceneThreads.h =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/LuceneThreads.h 2008-09-27 09:31:56 UTC (rev 2896) +++ branches/lucene2_3_2/src/shared/CLucene/LuceneThreads.h 2008-09-27 09:34:20 UTC (rev 2897) @@ -18,14 +18,19 @@ #define STATIC_DEFINE_MUTEX(x) #define _LUCENE_CURRTHREADID 1 #define _LUCENE_THREADID_TYPE char + #define _LUCENE_THREAD_FUNC(name, argName) int name(void* argName) + #define _LUCENE_THREAD_CREATE(value, func, arg) func(arg) + #define _LUCENE_THREAD_JOIN(value) //nothing to do... #else #if defined(_LUCENE_DONTIMPLEMENT_THREADMUTEX) //do nothing #else - #if defined(_CL_HAVE_PTHREAD) + #if defined(_CL_HAVE_PTHREAD) #define _LUCENE_THREADID_TYPE pthread_t - class CLUCENE_SHARED_EXPORT mutex_thread + #define _LUCENE_THREAD_FUNC(name, argName) void* name(void* argName) //< use this macro to correctly define the thread start routine + typedef void* (luceneThreadStartRoutine)(void* lpThreadParameter ); + class CLUCENE_SHARED_EXPORT mutex_thread { private: struct Internal; @@ -37,11 +42,15 @@ void lock(); void unlock(); static _LUCENE_THREADID_TYPE _GetCurrentThreadId(); + static _LUCENE_THREADID_TYPE CreateThread(luceneThreadStartRoutine* func, void* arg); + static void JoinThread(_LUCENE_THREADID_TYPE id); }; #elif defined(_CL_HAVE_WIN32_THREADS) #define _LUCENE_THREADID_TYPE uint64_t - class CLUCENE_SHARED_EXPORT mutex_thread + #define _LUCENE_THREAD_FUNC(name, argName) void __stdcall name(void* argName) //< use this macro to correctly define the thread start routine + typedef void (__stdcall luceneThreadStartRoutine)(void* lpThreadParameter ); + class CLUCENE_SHARED_EXPORT mutex_thread { private: struct Internal; @@ -53,14 +62,17 @@ void lock(); void unlock(); static _LUCENE_THREADID_TYPE _GetCurrentThreadId(); + static _LUCENE_THREADID_TYPE CreateThread(luceneThreadStartRoutine* func, void* arg); + static void JoinThread(_LUCENE_THREADID_TYPE id); }; - #else #error A valid thread library was not found #endif //mutex types + #define _LUCENE_THREAD_CREATE(func, arg) mutex_thread::CreateThread(func,arg) + #define _LUCENE_THREAD_JOIN(id) mutex_thread::JoinThread(id) #define _LUCENE_CURRTHREADID mutex_thread::_GetCurrentThreadId() #define _LUCENE_THREADMUTEX CL_NS(util)::mutex_thread #endif //don't implement Modified: branches/lucene2_3_2/src/shared/CLucene/config/_threads.h =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/config/_threads.h 2008-09-27 09:31:56 UTC (rev 2896) +++ branches/lucene2_3_2/src/shared/CLucene/config/_threads.h 2008-09-27 09:34:20 UTC (rev 2897) @@ -25,11 +25,24 @@ void * LockSemaphore; _cl_dword_t SpinCount; }; + + __declspec(dllimport) void __stdcall InitializeCriticalSection(CRITICAL_SECTION *); __declspec(dllimport) void __stdcall EnterCriticalSection(CRITICAL_SECTION *); __declspec(dllimport) void __stdcall LeaveCriticalSection(CRITICAL_SECTION *); __declspec(dllimport) void __stdcall DeleteCriticalSection(CRITICAL_SECTION *); __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(); + + typedef struct _SECURITY_ATTRIBUTES + { + _cl_dword_t nLength; + void* lpSecurityDescriptor; + bool bInheritHandle; + } SECURITY_ATTRIBUTES; + __declspec(dllimport) _cl_dword_t __stdcall WaitForSingleObject( void* hHandle, _cl_dword_t dwMilliseconds ); + void* _beginthread( void( __stdcall *start_address )( void * ), unsigned stack_size, void *arglist ); + + } #endif //_WINBASE_ #elif defined(_CL_HAVE_PTHREAD) @@ -72,6 +85,7 @@ }; // min_buckets = 2 ^^ N, 0 < N bool operator()( pthread_t t1, pthread_t t2 ) const{ + //pthread_equal should be used, but it returns only non-zero if equal, so we can't use it for order compare return t1 < t2; } }; Modified: branches/lucene2_3_2/src/shared/CLucene/config/threads.cpp =================================================================== --- branches/lucene2_3_2/src/shared/CLucene/config/threads.cpp 2008-09-27 09:31:56 UTC (rev 2896) +++ branches/lucene2_3_2/src/shared/CLucene/config/threads.cpp 2008-09-27 09:34:20 UTC (rev 2897) @@ -7,6 +7,7 @@ #include "CLucene/_SharedHeader.h" #include "CLucene/LuceneThreads.h" #include "_threads.h" +#include <assert.h> CL_NS_DEF(util) @@ -57,9 +58,20 @@ _LUCENE_THREADID_TYPE mutex_thread::_GetCurrentThreadId(){ return GetCurrentThreadId(); } + + _LUCENE_THREADID_TYPE mutex_thread::CreateThread(luceneThreadStartRoutine* func, void* arg){ + return (_LUCENE_THREADID_TYPE) ::_beginthread (func, 0, arg); + } + void mutex_thread::JoinThread(_LUCENE_THREADID_TYPE id){ + WaitForSingleObject((void*)id, 0xFFFFFFFF); + } #elif defined(_CL_HAVE_PTHREAD) + #ifndef _REENTRANT + #error ACK! You need to compile with _REENTRANT defined since this uses threads + #endif + #ifdef _CL_HAVE_PTHREAD_MUTEX_RECURSIVE bool mutex_pthread_attr_initd=false; pthread_mutexattr_t mutex_thread_attr; @@ -126,6 +138,15 @@ _LUCENE_THREADID_TYPE mutex_thread::_GetCurrentThreadId(){ return pthread_self(); } + + _LUCENE_THREADID_TYPE mutex_thread::CreateThread(luceneThreadStartRoutine* func, void* arg){ + _LUCENE_THREADID_TYPE ret; + assert(pthread_create(&ret, NULL, func, arg) == 0 ); + return ret; + } + void mutex_thread::JoinThread(_LUCENE_THREADID_TYPE id){ + pthread_join(id, NULL); + } void mutex_thread::lock() { Modified: branches/lucene2_3_2/src/test/index/TestReuters.cpp =================================================================== --- branches/lucene2_3_2/src/test/index/TestReuters.cpp 2008-09-27 09:31:56 UTC (rev 2896) +++ branches/lucene2_3_2/src/test/index/TestReuters.cpp 2008-09-27 09:34:20 UTC (rev 2897) @@ -1,6 +1,7 @@ #include "test.h" #include "CLucene/util/dirent.h" #include "CLucene/util/Reader.h" +#include "CLucene/LuceneThreads.h" #ifdef _CL_HAVE_SYS_STAT_H #include <sys/stat.h> @@ -267,7 +268,68 @@ _CLDELETE(reader1); _CLDELETE(reader2); } + + #define threadsCount 10 + + StandardAnalyzer threadAnalyzer; + void threadSearch(IndexSearcher* searcher, const TCHAR* qry){ + Query* q = NULL; + Hits* h = NULL; + try{ + q = QueryParser::parse(qry , _T("contents"), &threadAnalyzer); + if ( q != NULL ){ + h = searcher->search( q ); + + if ( h->length() > 0 ){ + //check for explanation memory leaks... + Explanation expl1; + searcher->explain(q, h->id(0), &expl1); + TCHAR* tmp = expl1.toString(); + _CLDELETE_CARRAY(tmp); + if ( h->length() > 1 ){ //do a second one just in case + Explanation expl2; + searcher->explain(q, h->id(1), &expl2); + tmp = expl2.toString(); + _CLDELETE_CARRAY(tmp); + } + } + } + }_CLFINALLY( + _CLDELETE(h); + _CLDELETE(q); + ); + } + _LUCENE_THREAD_FUNC(threadedSearcherTest, arg){ + IndexSearcher* searcher = (IndexSearcher*)arg; + printf("thread started :-)...\n"); + + for ( int i=0;i<100;i++ ){ + threadSearch(searcher, _T("test") ); + threadSearch(searcher, _T("reuters") ); + threadSearch(searcher, _T("data") ); + } + printf ("done...\n"); + } + + void testThreaded(CuTest* tc){ + CLUCENE_ASSERT(reuters_ready); + IndexSearcher searcher(reuters_origdirectory); + + //read using multiple threads... + _LUCENE_THREADID_TYPE threads[threadsCount]; + + int i; + for ( i=0;i<threadsCount;i++ ) + threads[i] = _LUCENE_THREAD_CREATE(&threadedSearcherTest, &searcher); + + CL_NS(util)::Misc::sleep(3000); + for ( i=0;i<threadsCount;i++ ) + _LUCENE_THREAD_JOIN(threads[i]); + + searcher.close(); + } + CuSuite *testreuters(void) { CuSuite *suite = CuSuiteNew(_T("CLucene Reuters Test")); @@ -279,6 +341,10 @@ SUITE_ADD_TEST(suite, testReuters); //SUITE_ADD_TEST(suite, testByteForByte); this test rarely works currently, use more robust by section test... SUITE_ADD_TEST(suite, testBySection); + + //we still do this, but it'll be slow because the 'threads' will be run serially. + + SUITE_ADD_TEST(suite, testThreaded); return suite; } // EOF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 09:32:02
|
Revision: 2896 http://clucene.svn.sourceforge.net/clucene/?rev=2896&view=rev Author: ustramooner Date: 2008-09-27 09:31:56 +0000 (Sat, 27 Sep 2008) Log Message: ----------- dist-test.sh improvements Modified Paths: -------------- branches/lucene2_3_2/dist-test.sh Modified: branches/lucene2_3_2/dist-test.sh =================================================================== --- branches/lucene2_3_2/dist-test.sh 2008-09-27 09:31:29 UTC (rev 2895) +++ branches/lucene2_3_2/dist-test.sh 2008-09-27 09:31:56 UTC (rev 2896) @@ -82,7 +82,8 @@ if [ $t_env == 1 ]; then - mkdir $TMP 2>/dev/null + rm -fdr $TMP 2>/dev/null + mkdir $TMP #create header file for testing of symbols in headers. echo "#include \"CLucene/StdHeader.h"\" >$TMP/pub-headers.cpp @@ -98,7 +99,7 @@ #move headers somewhere to compile mkdir -p "$TMP/$DH" 2>/dev/null - ln -s "`cd "$DN" && pwd`" "$TMP/${H:3}" 2>/dev/null + ln -s "`cd "$DN" && pwd`/$BH" "$TMP/${H:3}" 2>/dev/null #create pub-headers.cpp echo "#include \"${H:7}\"" >>$TMP/pub-headers.cpp @@ -179,7 +180,7 @@ #test if headers can compile together by themselves: if [ $t_c_all == 1 ]; then - g++ -I$TMP/src -I$TMP/src/shared -I$TMP/src/core $TMP/pub-headers.cpp + g++ -I$TMP/src -I$TMP/src/shared -I$TMP/src/core $TMP/pub-headers.cpp -I./src/shared fi if [ $t_inline == 1 ]; then This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-27 09:31:35
|
Revision: 2895 http://clucene.svn.sourceforge.net/clucene/?rev=2895&view=rev Author: ustramooner Date: 2008-09-27 09:31:29 +0000 (Sat, 27 Sep 2008) Log Message: ----------- mmap improvement - config for using mmap by default Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/CLConfig.h branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp branches/lucene2_3_2/src/core/CLucene/store/MMapInput.cpp Modified: branches/lucene2_3_2/src/core/CLucene/CLConfig.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/CLConfig.h 2008-09-16 17:54:00 UTC (rev 2894) +++ branches/lucene2_3_2/src/core/CLucene/CLConfig.h 2008-09-27 09:31:29 UTC (rev 2895) @@ -48,10 +48,16 @@ //#define _UCS2 // //define this to enable mmap support in the fsdirectory IndexInput -//todo: only available for windows so far...need to add MMapInput.cpp to project //EXPERIMENTAL //#define LUCENE_FS_MMAP // +//define to true to actually use it (not just enable it) +#ifdef LUCENE_FS_MMAP + #define LUCENE_USE_MMAP true //yes, use if it's turned on. +#else + #define LUCENE_USE_MMAP false +#endif +// //LOCK_DIR implementation: //define this to set an exact directory for the lock dir (not recommended) //all other methods of getting the temporary directory will be ignored Modified: branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp 2008-09-16 17:54:00 UTC (rev 2894) +++ branches/lucene2_3_2/src/core/CLucene/store/FSDirectory.cpp 2008-09-27 09:31:29 UTC (rev 2895) @@ -307,7 +307,7 @@ directory(_CL_NEWARRAY(char,CL_MAX_PATH)), lockDir(_CL_NEWARRAY(char,CL_MAX_PATH)), refCount(0), - useMMap(false) + useMMap(LUCENE_USE_MMAP) { _realpath(path,directory);//set a realpath so that if we change directory, we can still function if ( !directory || !*directory ){ Modified: branches/lucene2_3_2/src/core/CLucene/store/MMapInput.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/store/MMapInput.cpp 2008-09-16 17:54:00 UTC (rev 2894) +++ branches/lucene2_3_2/src/core/CLucene/store/MMapInput.cpp 2008-09-27 09:31:29 UTC (rev 2895) @@ -116,7 +116,7 @@ _cl_dword_t err = GetLastError(); if ( err == ERROR_FILE_NOT_FOUND ) _CLTHROWA(CL_ERR_IO, "File does not exist"); - else if ( err == EACCES ) + else if ( err == ERROR_ACCESS_DENIED ) _CLTHROWA(ERROR_ACCESS_DENIED, "File Access denied"); else if ( err == ERROR_TOO_MANY_OPEN_FILES ) _CLTHROWA(CL_ERR_IO, "Too many open files"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-15 15:19:43
|
Revision: 2893 http://clucene.svn.sourceforge.net/clucene/?rev=2893&view=rev Author: ustramooner Date: 2008-09-15 15:19:20 +0000 (Mon, 15 Sep 2008) Log Message: ----------- fixes for SunOS's compiler. Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/document/Field.cpp branches/lucene2_3_2/src/core/CLucene/index/TermInfosReader.cpp branches/lucene2_3_2/src/core/CLucene/util/ThreadLocal.cpp Modified: branches/lucene2_3_2/src/core/CLucene/document/Field.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/document/Field.cpp 2008-09-10 15:28:58 UTC (rev 2892) +++ branches/lucene2_3_2/src/core/CLucene/document/Field.cpp 2008-09-15 15:19:20 UTC (rev 2893) @@ -44,7 +44,7 @@ } -Field::Field(const TCHAR* Name, const TCHAR* Value, int _config, bool duplicateValue): +Field::Field(const TCHAR* Name, const TCHAR* Value, int _config, const bool duplicateValue): /*_internal(new Internal),*/ lazy(false) { CND_PRECONDITION(Name != NULL, "Name cannot be NULL"); Modified: branches/lucene2_3_2/src/core/CLucene/index/TermInfosReader.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/TermInfosReader.cpp 2008-09-10 15:28:58 UTC (rev 2892) +++ branches/lucene2_3_2/src/core/CLucene/index/TermInfosReader.cpp 2008-09-15 15:19:20 UTC (rev 2893) @@ -25,7 +25,7 @@ CL_NS_DEF(index) - TermInfosReader::TermInfosReader(Directory* dir, const char* seg, FieldInfos* fis, int32_t readBufferSize): + TermInfosReader::TermInfosReader(Directory* dir, const char* seg, FieldInfos* fis, const int32_t readBufferSize): directory (dir),fieldInfos (fis), indexTerms(NULL), indexInfos(NULL), indexPointers(NULL), indexDivisor(1) { //Func - Constructor. @@ -115,8 +115,6 @@ if ( indexTerms[i].__cl_refcount != 1 ){ CND_PRECONDITION(indexTerms[i].__cl_refcount==1,"TermInfosReader term was references more than internally"); } - // _CLDECDELETE(indexTerms[i]); - //_CLDELETE(indexInfos[i]); } #endif //Delete the arrays Modified: branches/lucene2_3_2/src/core/CLucene/util/ThreadLocal.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/ThreadLocal.cpp 2008-09-10 15:28:58 UTC (rev 2892) +++ branches/lucene2_3_2/src/core/CLucene/util/ThreadLocal.cpp 2008-09-15 15:19:20 UTC (rev 2893) @@ -13,7 +13,7 @@ //todo: using http://en.wikipedia.org/wiki/Thread-local_storage#Pthreads_implementation //would work better... but lots of testing would be needed first... -typedef CL_NS(util)::CLMultiMap<_LUCENE_THREADID_TYPE, _ThreadLocal*, +typedef CL_NS(util)::CLMultiMap<const _LUCENE_THREADID_TYPE, _ThreadLocal*, CL_NS(util)::CLuceneThreadIdCompare, CL_NS(util)::Deletor::ConstNullVal<_LUCENE_THREADID_TYPE>, CL_NS(util)::Deletor::ConstNullVal<_ThreadLocal*> > ThreadLocalsType; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-10 15:29:02
|
Revision: 2892 http://clucene.svn.sourceforge.net/clucene/?rev=2892&view=rev Author: ustramooner Date: 2008-09-10 15:28:58 +0000 (Wed, 10 Sep 2008) Log Message: ----------- link pthread library Modified Paths: -------------- branches/lucene2_3_2/CMakeLists.txt branches/lucene2_3_2/src/core/CMakeLists.txt branches/lucene2_3_2/src/test/CMakeLists.txt Modified: branches/lucene2_3_2/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/CMakeLists.txt 2008-09-10 15:18:33 UTC (rev 2891) +++ branches/lucene2_3_2/CMakeLists.txt 2008-09-10 15:28:58 UTC (rev 2892) @@ -31,6 +31,7 @@ #define options... Include (CLuceneDocs) +Include (FindThreads) IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING Modified: branches/lucene2_3_2/src/core/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/core/CMakeLists.txt 2008-09-10 15:18:33 UTC (rev 2891) +++ branches/lucene2_3_2/src/core/CMakeLists.txt 2008-09-10 15:28:58 UTC (rev 2892) @@ -150,9 +150,9 @@ #link the clucene-core library against the releavent clucene-shared library (if we aren't using the object files) IF ( NOT USE_SHARED_OBJECT_FILES ) IF ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(clucene-core clucene-shared-static) + TARGET_LINK_LIBRARIES(clucene-core clucene-shared-static} ) ELSE ( USE_STATIC_SHARED_LIBRARY ) - TARGET_LINK_LIBRARIES(clucene-core clucene-shared) + TARGET_LINK_LIBRARIES(clucene-core clucene-shared ${CMAKE_THREAD_LIBS_INIT}) ENDIF ( USE_STATIC_SHARED_LIBRARY ) ENDIF ( NOT USE_SHARED_OBJECT_FILES ) Modified: branches/lucene2_3_2/src/test/CMakeLists.txt =================================================================== --- branches/lucene2_3_2/src/test/CMakeLists.txt 2008-09-10 15:18:33 UTC (rev 2891) +++ branches/lucene2_3_2/src/test/CMakeLists.txt 2008-09-10 15:28:58 UTC (rev 2892) @@ -73,7 +73,7 @@ SET (TESTS_CXX_FLAGS ) -SET (TESTS_EXE_LINKER_FLAGS "") +SET (TESTS_EXE_LINKER_FLAGS "${CMAKE_THREAD_LIBS_INIT}") IF ( GccFlagG ) SET(TESTS_CXX_FLAGS "${TESTS_CXX_FLAGS} -g") ENDIF ( GccFlagG ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-10 15:20:11
|
Revision: 2891 http://clucene.svn.sourceforge.net/clucene/?rev=2891&view=rev Author: ustramooner Date: 2008-09-10 15:18:33 +0000 (Wed, 10 Sep 2008) Log Message: ----------- msvc6 doesn't have all these switches Modified Paths: -------------- branches/lucene2_3_2/cmake/DefineOptions.cmake Modified: branches/lucene2_3_2/cmake/DefineOptions.cmake =================================================================== --- branches/lucene2_3_2/cmake/DefineOptions.cmake 2008-09-10 12:02:24 UTC (rev 2890) +++ branches/lucene2_3_2/cmake/DefineOptions.cmake 2008-09-10 15:18:33 UTC (rev 2891) @@ -28,13 +28,15 @@ ADD_DEFINITIONS(-D__LARGE64_FILES) ENDIF(CYGWIN) + # calm mdown msvc IF(MSVC) - # calm mdown msvc - #ADD_DEFINITIONS(-wd4251) # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' - #ADD_DEFINITIONS(-wd4275) # non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' - #ADD_DEFINITIONS(-wd4309) # 'conversion' : truncation of constant value - #ADD_DEFINITIONS(-wd4503) # decorated name length exceeded - ADD_DEFINITIONS(-wd4786) # identifier was truncated to '255' characters in the debug information + IF ( NOT MSVC60 ) + #ADD_DEFINITIONS(-wd4251) # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' + #ADD_DEFINITIONS(-wd4275) # non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' + #ADD_DEFINITIONS(-wd4309) # 'conversion' : truncation of constant value + #ADD_DEFINITIONS(-wd4503) # decorated name length exceeded + #ADD_DEFINITIONS(-wd4786) # identifier was truncated to '255' characters in the debug information + ENDIF ( NOT MSVC60 ) ENDIF(MSVC) ENDMACRO (DEFINE_OPTIONS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-10 12:02:31
|
Revision: 2890 http://clucene.svn.sourceforge.net/clucene/?rev=2890&view=rev Author: ustramooner Date: 2008-09-10 12:02:24 +0000 (Wed, 10 Sep 2008) Log Message: ----------- visual studio 6 for loop fix Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/SegmentInfos.cpp Modified: branches/lucene2_3_2/src/core/CLucene/index/SegmentInfos.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/SegmentInfos.cpp 2008-09-09 17:31:31 UTC (rev 2889) +++ branches/lucene2_3_2/src/core/CLucene/index/SegmentInfos.cpp 2008-09-10 12:02:24 UTC (rev 2890) @@ -316,9 +316,9 @@ } // Next we look for any == 0. These cases were // pre-LOCKLESS and must be checked in directory: - for(size_t i=0;i<normGenLen;i++) { - if (normGen[i] == CHECK_DIR) { - if (hasSeparateNorms(i)) { + for(size_t j=0;j<normGenLen;j++) { + if (normGen[j] == CHECK_DIR) { + if (hasSeparateNorms(j)) { return true; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-09 17:31:33
|
Revision: 2889 http://clucene.svn.sourceforge.net/clucene/?rev=2889&view=rev Author: ustramooner Date: 2008-09-09 17:31:31 +0000 (Tue, 09 Sep 2008) Log Message: ----------- export inline Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/util/Equators.h Modified: branches/lucene2_3_2/src/core/CLucene/util/Equators.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/Equators.h 2008-09-09 17:23:29 UTC (rev 2888) +++ branches/lucene2_3_2/src/core/CLucene/util/Equators.h 2008-09-09 17:31:31 UTC (rev 2889) @@ -61,7 +61,7 @@ // Comparors //////////////////////////////////////////////////////////////////////////////// /** @internal */ -class CLUCENE_EXPORT Comparable:LUCENE_BASE{ +class CLUCENE_INLINE_EXPORT Comparable:LUCENE_BASE{ public: virtual ~Comparable(){ } @@ -72,7 +72,7 @@ /** @internal */ class CLUCENE_INLINE_EXPORT Compare{ public: - class CLUCENE_EXPORT _base + class CLUCENE_INLINE_EXPORT _base { // traits class for hash containers public: enum @@ -86,7 +86,7 @@ } }; - class CLUCENE_EXPORT Int32:public _base, public Comparable{ + class CLUCENE_INLINE_EXPORT Int32:public _base, public Comparable{ int32_t value; public: int32_t getValue() const; @@ -98,7 +98,7 @@ }; - class CLUCENE_EXPORT Float:public Comparable{ + class CLUCENE_INLINE_EXPORT Float:public Comparable{ float_t value; public: float_t getValue() const; @@ -107,7 +107,7 @@ }; - class CLUCENE_EXPORT Char: public _base //<char*> + class CLUCENE_INLINE_EXPORT Char: public _base //<char*> { public: bool operator()( const char* val1, const char* val2 ) const; @@ -115,7 +115,7 @@ }; #ifdef _UCS2 - class CLUCENE_EXPORT WChar: public _base //<wchar_t*> + class CLUCENE_INLINE_EXPORT WChar: public _base //<wchar_t*> { public: bool operator()( const wchar_t* val1, const wchar_t* val2 ) const; @@ -123,7 +123,7 @@ }; #endif - class CLUCENE_EXPORT TChar: public _base, public Comparable{ + class CLUCENE_INLINE_EXPORT TChar: public _base, public Comparable{ const TCHAR* s; public: const TCHAR* getValue() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-09 17:23:33
|
Revision: 2888 http://clucene.svn.sourceforge.net/clucene/?rev=2888&view=rev Author: ustramooner Date: 2008-09-09 17:23:29 +0000 (Tue, 09 Sep 2008) Log Message: ----------- turn off inline keyword. this doesn't work in cygwin or gcc. the code wasn't actually inline - the implementation was in the cpp file Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/document/Field.cpp branches/lucene2_3_2/src/core/CLucene/document/Field.h Modified: branches/lucene2_3_2/src/core/CLucene/document/Field.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/document/Field.cpp 2008-09-09 17:22:15 UTC (rev 2887) +++ branches/lucene2_3_2/src/core/CLucene/document/Field.cpp 2008-09-09 17:23:29 UTC (rev 2888) @@ -170,7 +170,7 @@ void Field::setBoost(const float_t boost) { this->boost = boost; } float_t Field::getBoost() const { return boost; } -inline void Field::setConfig(const uint32_t x){ +void Field::setConfig(const uint32_t x){ uint32_t newConfig=0; //set storage settings Modified: branches/lucene2_3_2/src/core/CLucene/document/Field.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/document/Field.h 2008-09-09 17:22:15 UTC (rev 2887) +++ branches/lucene2_3_2/src/core/CLucene/document/Field.h 2008-09-09 17:23:29 UTC (rev 2888) @@ -312,9 +312,9 @@ * For example, to use term vectors with positions and offsets do: * object->setConfig(TERMVECTOR_WITH_POSITIONS | TERMVECTOR_WITH_OFFSETS); */ - inline void setConfig(const uint32_t _config); + void setConfig(const uint32_t _config); - inline void _resetValue(); + void _resetValue(); void* fieldsData; ValueType valueType; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-09 17:22:32
|
Revision: 2887 http://clucene.svn.sourceforge.net/clucene/?rev=2887&view=rev Author: ustramooner Date: 2008-09-09 17:22:15 +0000 (Tue, 09 Sep 2008) Log Message: ----------- give KeywordAnalyzer a constructor. was causing warnings in cygwin Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.cpp branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.h Modified: branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.cpp 2008-09-09 17:14:43 UTC (rev 2886) +++ branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.cpp 2008-09-09 17:22:15 UTC (rev 2887) @@ -472,6 +472,7 @@ } +KeywordAnalyzer::KeywordAnalyzer(){} KeywordAnalyzer::~KeywordAnalyzer(){} TokenStream* KeywordAnalyzer::tokenStream(const TCHAR* fieldName, CL_NS(util)::Reader* reader){ return _CLNEW KeywordTokenizer(reader); Modified: branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.h 2008-09-09 17:14:43 UTC (rev 2886) +++ branches/lucene2_3_2/src/core/CLucene/analysis/Analyzers.h 2008-09-09 17:22:15 UTC (rev 2887) @@ -364,9 +364,10 @@ */ class CLUCENE_EXPORT KeywordAnalyzer: public Analyzer { public: + KeywordAnalyzer(); + virtual ~KeywordAnalyzer(); TokenStream* tokenStream(const TCHAR* fieldName, CL_NS(util)::Reader* reader); TokenStream* reusableTokenStream(const TCHAR* fieldName, CL_NS(util)::Reader* reader); - virtual ~KeywordAnalyzer(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-09 17:14:46
|
Revision: 2886 http://clucene.svn.sourceforge.net/clucene/?rev=2886&view=rev Author: ustramooner Date: 2008-09-09 17:14:43 +0000 (Tue, 09 Sep 2008) Log Message: ----------- gcc fixes: java bytes are actually signed (strangely), causing a compile warning when assigning -1 value. it's an error to pass the class name in the header. Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/_FieldsReader.h branches/lucene2_3_2/src/core/CLucene/index/_SegmentInfos.h Modified: branches/lucene2_3_2/src/core/CLucene/index/_FieldsReader.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/_FieldsReader.h 2008-09-08 10:10:36 UTC (rev 2885) +++ branches/lucene2_3_2/src/core/CLucene/index/_FieldsReader.h 2008-09-09 17:14:43 UTC (rev 2886) @@ -78,7 +78,7 @@ * contiguous range of length numDocs starting with * startDocID. Returns the IndexInput (the fieldStream), * already seeked to the starting point for startDocID.*/ - CL_NS(store)::IndexInput* FieldsReader::rawDocs(int32_t* lengths, const int32_t startDocID, const int32_t numDocs); + CL_NS(store)::IndexInput* rawDocs(int32_t* lengths, const int32_t startDocID, const int32_t numDocs); private: /** Modified: branches/lucene2_3_2/src/core/CLucene/index/_SegmentInfos.h =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/_SegmentInfos.h 2008-09-08 10:10:36 UTC (rev 2885) +++ branches/lucene2_3_2/src/core/CLucene/index/_SegmentInfos.h 2008-09-09 17:14:43 UTC (rev 2886) @@ -48,7 +48,7 @@ size_t normGenLen; // To keep the length of array normGen - uint8_t isCompoundFile; // NO if it is not; YES if it is; CHECK_DIR if it's + int8_t isCompoundFile; // NO if it is not; YES if it is; CHECK_DIR if it's // pre-2.1 (ie, must check file system to see // if <name>.cfs and <name>.nrm exist) @@ -174,7 +174,7 @@ /** We consider another SegmentInfo instance equal if it * has the same dir and same name. */ - bool SegmentInfo::equals(SegmentInfo* obj); + bool equals(SegmentInfo* obj); ///Gets the Directory where the segment resides CL_NS(store)::Directory* getDir() const{ return dir; } //todo: since dir is public, consider removing this function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ust...@us...> - 2008-09-08 10:10:43
|
Revision: 2885 http://clucene.svn.sourceforge.net/clucene/?rev=2885&view=rev Author: ustramooner Date: 2008-09-08 10:10:36 +0000 (Mon, 08 Sep 2008) Log Message: ----------- Rustem Alimov patch for error on double-close Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.cpp Modified: branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.cpp 2008-08-29 10:59:36 UTC (rev 2884) +++ branches/lucene2_3_2/src/core/CLucene/index/IndexModifier.cpp 2008-09-08 10:10:36 UTC (rev 2885) @@ -191,6 +191,8 @@ } void IndexModifier::close() { + if (!open) + return; SCOPED_LOCK_MUTEX(directory->THIS_LOCK) if (indexWriter != NULL) { indexWriter->close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |