1 /* 2 * Copyright 2010, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Clemens Zeidler <haiku@clemens-zeidler.de> 7 */ 8 #ifndef CLUCENE_DATA_BASE_H 9 #define CLUCENE_DATA_BASE_H 10 11 12 #include <vector> 13 14 #include <Path.h> 15 16 #include "TextDataBase.h" 17 18 #include <CLucene.h> 19 20 21 using namespace lucene::index; 22 using namespace lucene::analysis::standard; 23 24 25 class CLuceneWriteDataBase : public TextWriteDataBase { 26 public: 27 CLuceneWriteDataBase(const BPath& databasePath); 28 ~CLuceneWriteDataBase(); 29 30 status_t InitCheck(); 31 32 status_t AddDocument(const entry_ref& ref); 33 status_t RemoveDocument(const entry_ref& ref); 34 status_t Commit(); 35 36 private: 37 IndexWriter* _OpenIndexWriter(); 38 IndexReader* _OpenIndexReader(); 39 40 bool _RemoveDocuments(std::vector<entry_ref>& docs); 41 bool _RemoveDocument(wchar_t* doc, 42 IndexReader* reader); 43 44 bool _IndexDocument(const entry_ref& ref); 45 46 BPath fDataBasePath; 47 48 BPath fTempPath; 49 50 std::vector<entry_ref> fAddQueue; 51 std::vector<entry_ref> fDeleteQueue; 52 53 StandardAnalyzer fStandardAnalyzer; 54 55 IndexWriter* fIndexWriter; 56 }; 57 58 #endif 59