|
From: <ust...@us...> - 2009-04-16 16:25:51
|
Revision: 2991
http://clucene.svn.sourceforge.net/clucene/?rev=2991&view=rev
Author: ustramooner
Date: 2009-04-16 16:25:40 +0000 (Thu, 16 Apr 2009)
Log Message:
-----------
various fixes for Itamar's code. rollback Token code, potential problems there... fix some deprecation stuff
Modified Paths:
--------------
branches/lucene2_3_2/src/core/CLucene/analysis/AnalysisHeader.cpp
branches/lucene2_3_2/src/core/CLucene/index/MultiLevelSkipListReader.cpp
branches/lucene2_3_2/src/core/CLucene/index/_TermVector.h
branches/lucene2_3_2/src/core/CLucene/search/PhraseQuery.cpp
branches/lucene2_3_2/src/core/CLucene/search/PhraseQuery.h
branches/lucene2_3_2/src/core/CLucene/util/Equators.cpp
branches/lucene2_3_2/src/core/CLucene/util/Equators.h
branches/lucene2_3_2/src/shared/CLucene/LuceneThreads.h
Modified: branches/lucene2_3_2/src/core/CLucene/analysis/AnalysisHeader.cpp
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/analysis/AnalysisHeader.cpp 2009-04-13 05:33:02 UTC (rev 2990)
+++ branches/lucene2_3_2/src/core/CLucene/analysis/AnalysisHeader.cpp 2009-04-16 16:25:40 UTC (rev 2991)
@@ -67,8 +67,7 @@
Token::~Token(){
#ifndef LUCENE_TOKEN_WORD_LENGTH
- //free(_termText);
- delete[] _termText;
+ free(_termText);
#endif
_CLLDELETE(payload);
}
@@ -148,16 +147,13 @@
if(bufferTextLen>=size)
return;
#ifndef LUCENE_TOKEN_WORD_LENGTH
- if ( _termText == NULL )
- //_termText = (TCHAR*)malloc( size * sizeof(TCHAR) );
- _termText = new TCHAR[size * sizeof(TCHAR)];
- else{
- // ISH: Use new/delete[] instead of realloc, since a copy is being made anyway and there's no
- // need to preserve the current content
- //_termText = (TCHAR*)realloc( _termText, size * sizeof(TCHAR) );
- TCHAR* __termText = new TCHAR[size * sizeof(TCHAR)];
- delete[] _termText;
- _termText = __termText;
+ if ( _termText == NULL ){
+ _termText = (TCHAR*)malloc( size * sizeof(TCHAR) );
+ _termText[0] = NULL;
+ }else{
+ //use realloc. growBuffer is public, therefore could be called
+ //without a subsequent call to overwriting the memory
+ _termText = (TCHAR*)realloc( _termText, size * sizeof(TCHAR) );
}
bufferTextLen = size;
#else
Modified: branches/lucene2_3_2/src/core/CLucene/index/MultiLevelSkipListReader.cpp
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/index/MultiLevelSkipListReader.cpp 2009-04-13 05:33:02 UTC (rev 2990)
+++ branches/lucene2_3_2/src/core/CLucene/index/MultiLevelSkipListReader.cpp 2009-04-16 16:25:40 UTC (rev 2991)
@@ -223,4 +223,4 @@
return _CLNEW SkipBuffer(*this);
}
-CL_NS_END
\ No newline at end of file
+CL_NS_END
Modified: branches/lucene2_3_2/src/core/CLucene/index/_TermVector.h
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/index/_TermVector.h 2009-04-13 05:33:02 UTC (rev 2990)
+++ branches/lucene2_3_2/src/core/CLucene/index/_TermVector.h 2009-04-16 16:25:40 UTC (rev 2991)
@@ -204,8 +204,8 @@
CL_NS(store)::IndexInput* tvf;
int64_t _size; // TODO: size_t ?
- // The docID offset where our docs begin in the index
- // file. This will be 0 if we have our own private file.
+ // The docID offset where our docs begin in the index
+ // file. This will be 0 if we have our own private file.
int32_t docStoreOffset;
int32_t tvdFormat;
@@ -231,12 +231,12 @@
public:
void get(const int32_t docNum, const TCHAR* field, TermVectorMapper* mapper);
- /**
- * Retrieve the term vector for the given document and field
- * @param docNum The document number to retrieve the vector for
- * @param field The field within the document to retrieve
- * @return The TermFreqVector for the document and field or null if there is no termVector for this field.
- * @throws IOException if there is an error reading the term vector files
+ /**
+ * Retrieve the term vector for the given document and field
+ * @param docNum The document number to retrieve the vector for
+ * @param field The field within the document to retrieve
+ * @return The TermFreqVector for the document and field or null if there is no termVector for this field.
+ * @throws IOException if there is an error reading the term vector files
*/
TermFreqVector* get(const int32_t docNum, const TCHAR* field);
@@ -253,19 +253,19 @@
void get(const int32_t docNumber, TermVectorMapper* mapper);
private:
- CL_NS(util)::ObjectArray<SegmentTermVector>* readTermVectors(const int32_t docNum,
- const TCHAR** fields, const int64_t* tvfPointers, const int32_t len);
-
- void readTermVectors(const TCHAR** fields, const int64_t* tvfPointers,
- const int32_t len, TermVectorMapper* mapper);
+ CL_NS(util)::ObjectArray<SegmentTermVector>* readTermVectors(const int32_t docNum,
+ const TCHAR** fields, const int64_t* tvfPointers, const int32_t len);
- /**
- *
- * @param field The field to read in
- * @param tvfPointer The pointer within the tvf file where we should start reading
- * @param mapper The mapper used to map the TermVector
- * @return The TermVector located at that position
- * @throws IOException
+ void readTermVectors(const TCHAR** fields, const int64_t* tvfPointers,
+ const int32_t len, TermVectorMapper* mapper);
+
+ /**
+ *
+ * @param field The field to read in
+ * @param tvfPointer The pointer within the tvf file where we should start reading
+ * @param mapper The mapper used to map the TermVector
+ * @return The TermVector located at that position
+ * @throws IOException
*/
void readTermVector(const TCHAR* field, const int64_t tvfPointer, TermVectorMapper* mapper);
@@ -429,4 +429,4 @@
};
CL_NS_END
-#endif
\ No newline at end of file
+#endif
Modified: branches/lucene2_3_2/src/core/CLucene/search/PhraseQuery.cpp
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/search/PhraseQuery.cpp 2009-04-13 05:33:02 UTC (rev 2990)
+++ branches/lucene2_3_2/src/core/CLucene/search/PhraseQuery.cpp 2009-04-16 16:25:40 UTC (rev 2991)
@@ -183,7 +183,7 @@
positions->push_back(position);
}
- void PhraseQuery::getPositions(Array<int32_t>& result) const{
+ void PhraseQuery::getPositions(ValueArray<int32_t>& result) const{
result.length = positions->size();
result.values = _CL_NEWARRAY(int32_t,result.length);
for(size_t i = 0; i < result.length; i++){
@@ -353,7 +353,7 @@
Scorer* ret = NULL;
- Array<int32_t> positions;
+ ValueArray<int32_t> positions;
_this->getPositions(positions);
int32_t slop = _this->getSlop();
if ( slop != 0)
Modified: branches/lucene2_3_2/src/core/CLucene/search/PhraseQuery.h
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/search/PhraseQuery.h 2009-04-13 05:33:02 UTC (rev 2990)
+++ branches/lucene2_3_2/src/core/CLucene/search/PhraseQuery.h 2009-04-16 16:25:40 UTC (rev 2991)
@@ -102,7 +102,7 @@
/**
* Returns the relative positions of terms in this phrase.
*/
- void getPositions(CL_NS(util)::Array<int32_t>& result) const;
+ void getPositions(CL_NS(util)::ValueArray<int32_t>& result) const;
const TCHAR* getFieldName() const{ return field; }
/** Prints a user-readable version of this query. */
Modified: branches/lucene2_3_2/src/core/CLucene/util/Equators.cpp
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/util/Equators.cpp 2009-04-13 05:33:02 UTC (rev 2990)
+++ branches/lucene2_3_2/src/core/CLucene/util/Equators.cpp 2009-04-16 16:25:40 UTC (rev 2991)
@@ -89,7 +89,23 @@
size_t Compare::Char::operator()( const char* val1) const{
return CL_NS(util)::Misc::ahashCode(val1);
}
+const char* Compare::Char::getValue() const{ return s; }
+Compare::Char::Char(){
+ s=NULL;
+}
+ Compare::Char::Char(const char* str){
+ this->s = str;
+}
+int32_t Compare::Char::compareTo(void* o){
+ try{
+ Char* os = (Char*)o;
+ return strcmp(s,os->s);
+ }catch(...){
+ _CLTHROWA(CL_ERR_Runtime,"Couldnt compare types");
+ }
+}
+
#ifdef _UCS2
bool Compare::WChar::operator()( const wchar_t* val1, const wchar_t* val2 ) const{
if ( val1==val2)
@@ -100,17 +116,16 @@
size_t Compare::WChar::operator()( const wchar_t* val1) const{
return CL_NS(util)::Misc::whashCode(val1);
}
-#endif
-const TCHAR* Compare::TChar::getValue() const{ return s; }
+const wchar_t* Compare::WChar::getValue() const{ return s; }
-Compare::TChar::TChar(){
+Compare::WChar::WChar(){
s=NULL;
}
- Compare::TChar::TChar(const TCHAR* str){
+ Compare::WChar::WChar(const wchar_t* str){
this->s = str;
}
-int32_t Compare::TChar::compareTo(void* o){
+int32_t Compare::WChar::compareTo(void* o){
try{
TChar* os = (TChar*)o;
return _tcscmp(s,os->s);
@@ -120,14 +135,7 @@
}
-bool Compare::TChar::operator()( const TCHAR* val1, const TCHAR* val2 ) const{
- if ( val1==val2)
- return false;
- bool ret = (_tcscmp( val1,val2 ) < 0);
- return ret;
-}
-size_t Compare::TChar::operator()( const TCHAR* val1) const{
- return CL_NS(util)::Misc::thashCode(val1);
-}
+#endif
+
CL_NS_END
Modified: branches/lucene2_3_2/src/core/CLucene/util/Equators.h
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/util/Equators.h 2009-04-13 05:33:02 UTC (rev 2990)
+++ branches/lucene2_3_2/src/core/CLucene/util/Equators.h 2009-04-16 16:25:40 UTC (rev 2991)
@@ -107,34 +107,37 @@
};
- class CLUCENE_INLINE_EXPORT Char: public _base //<char*>
+ class CLUCENE_INLINE_EXPORT Char: public _base, public Comparable //<char*>
{
+ const char* s;
public:
+ const char* getValue() const;
+ Char();
+ Char(const char* str);
+ int32_t compareTo(void* o);
+
bool operator()( const char* val1, const char* val2 ) const;
size_t operator()( const char* val1) const;
};
#ifdef _UCS2
- class CLUCENE_INLINE_EXPORT WChar: public _base //<wchar_t*>
+ class CLUCENE_INLINE_EXPORT WChar: public _base, public Comparable //<wchar_t*>
{
+ const wchar_t* s;
public:
+ const wchar_t* getValue() const;
+ WChar();
+ WChar(const wchar_t* str);
+ int32_t compareTo(void* o);
+
bool operator()( const wchar_t* val1, const wchar_t* val2 ) const;
size_t operator()( const wchar_t* val1) const;
};
+ typedef WChar TChar;
+#else
+ typedef Char TChar;
#endif
- class CLUCENE_INLINE_EXPORT TChar: public _base, public Comparable{
- const TCHAR* s;
- public:
- const TCHAR* getValue() const;
- TChar();
- TChar(const TCHAR* str);
- int32_t compareTo(void* o);
- bool operator()( const TCHAR* val1, const TCHAR* val2 ) const;
- size_t operator()( const TCHAR* val1) const;
- };
-
-
template<typename _cl>
class CLUCENE_INLINE_EXPORT Void:public _base //<const void*,const void*,bool>
{
Modified: branches/lucene2_3_2/src/shared/CLucene/LuceneThreads.h
===================================================================
--- branches/lucene2_3_2/src/shared/CLucene/LuceneThreads.h 2009-04-13 05:33:02 UTC (rev 2990)
+++ branches/lucene2_3_2/src/shared/CLucene/LuceneThreads.h 2009-04-16 16:25:40 UTC (rev 2991)
@@ -36,7 +36,7 @@
{
private:
struct Internal;
- Internal* internal;
+ Internal* _internal;
public:
mutex_thread(const mutex_thread& clone);
mutex_thread();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|