+ new indexer code

This commit is contained in:
kelson42 2012-04-06 21:48:43 +00:00
parent 5726006d5b
commit 31b3308937
3 changed files with 12 additions and 10 deletions

View File

@ -7,8 +7,7 @@ kiwix_index_SOURCES= \
../common/unaccent.cpp \ ../common/unaccent.cpp \
../common/kiwix/indexer.cpp \ ../common/kiwix/indexer.cpp \
../common/kiwix/reader.cpp \ ../common/kiwix/reader.cpp \
../common/kiwix/xapianIndexer.cpp \ ../common/kiwix/xapianIndexer.cpp
../common/kiwix/cluceneIndexer.cpp
include_HEADERS= \ include_HEADERS= \
../common/kiwix/xapian/myhtmlparse.h \ ../common/kiwix/xapian/myhtmlparse.h \
../common/kiwix/xapian/namedentities.h \ ../common/kiwix/xapian/namedentities.h \
@ -16,8 +15,7 @@ include_HEADERS= \
../common/unaccent.h \ ../common/unaccent.h \
../common/kiwix/indexer.h \ ../common/kiwix/indexer.h \
../common/kiwix/reader.h \ ../common/kiwix/reader.h \
../common/kiwix/xapianIndexer.h \ ../common/kiwix/xapianIndexer.h
../common/kiwix/cluceneIndexer.h
kiwix_index_CXXFLAGS=$(LIBXAPIAN_CFLAGS) $(LIBCLUCENE_CFLAGS) $(LIBICU_CFLAGS) $(LIBZIM_CFLAGS) -I../common/ kiwix_index_CXXFLAGS=$(LIBXAPIAN_CFLAGS) $(LIBCLUCENE_CFLAGS) $(LIBICU_CFLAGS) $(LIBZIM_CFLAGS) -I../common/
kiwix_index_LDFLAGS=$(LIBXAPIAN_LDFLAGS) $(LIBCLUCENE_LDFLAGS) $(LIBICU_LDFLAGS) $(LIBZIM_LDFLAGS) kiwix_index_LDFLAGS=$(LIBXAPIAN_LDFLAGS) $(LIBCLUCENE_LDFLAGS) $(LIBICU_LDFLAGS) $(LIBZIM_LDFLAGS)
kiwix_index_LDADD=../zimlib/src/.libs/libzim.a kiwix_index_LDADD=../zimlib/src/.libs/libzim.a

View File

@ -23,7 +23,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
#else #else
#include <kiwix/cluceneIndexer.h> //#include <kiwix/cluceneIndexer.h>
#endif #endif
enum supportedBackend { XAPIAN, CLUCENE }; enum supportedBackend { XAPIAN, CLUCENE };
@ -95,10 +95,10 @@ int main(int argc, char **argv) {
try { try {
if (backend == CLUCENE) { if (backend == CLUCENE) {
#ifndef _WIN32 #ifndef _WIN32
indexer = new kiwix::CluceneIndexer(zimFilePath, indexPath); //indexer = new kiwix::CluceneIndexer(zimFilePath, indexPath);
#endif #endif
} else { } else {
indexer = new kiwix::XapianIndexer(zimFilePath, indexPath); indexer = new kiwix::XapianIndexer();
} }
} catch (...) { } catch (...) {
cerr << "Unable to index '" << zimFilePath << "'." << endl; cerr << "Unable to index '" << zimFilePath << "'." << endl;
@ -107,11 +107,12 @@ int main(int argc, char **argv) {
/* Start the indexing */ /* Start the indexing */
if (indexer != NULL) { if (indexer != NULL) {
indexer->start(); indexer->start(zimFilePath, indexPath);
while (indexer->isRunning()) { while (indexer->isRunning()) {
if (verboseFlag)
cout << indexer->getProgression() << "% of all the articles indexed..." << endl;
sleep(1); sleep(1);
} }
//while (indexer->indexNextPercent(verboseFlag)) {};
delete indexer; delete indexer;
} else { } else {
cerr << "Unable instanciate the Kiwix indexer." << endl; cerr << "Unable instanciate the Kiwix indexer." << endl;

View File

@ -181,7 +181,10 @@ int main(int argc, char **argv) {
} }
if (indexer != NULL) { if (indexer != NULL) {
while (indexer->indexNextPercent(verboseFlag)) {}; indexer->start();
while (indexer->isRunning()) {
sleep(1);
}
delete indexer; delete indexer;
} else { } else {
cerr << "Unable instanciate the Kiwix indexer." << endl; cerr << "Unable instanciate the Kiwix indexer." << endl;