PageRenderTime 36ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/strigi-0.7.7/libstreamanalyzer/plugins/indexers/cluceneindexer/cluceneindexmanager.h

#
C Header | 78 lines | 49 code | 8 blank | 21 comment | 0 complexity | 911eb20fc97e7d6bba3e4ccf45e7047d MD5 | raw file
Possible License(s): LGPL-2.0
  1. /* This file is part of Strigi Desktop Search
  2. *
  3. * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public License
  16. * along with this library; see the file COPYING.LIB. If not, write to
  17. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef CLUCENEINDEXMANAGER_H
  21. #define CLUCENEINDEXMANAGER_H
  22. #include <strigi/strigiconfig.h>
  23. #include <strigi/indexmanager.h>
  24. #include <strigi/strigi_thread.h>
  25. #include <string>
  26. #include <map>
  27. /**
  28. **/
  29. namespace lucene {
  30. namespace analysis {
  31. class Analyzer;
  32. }
  33. namespace index {
  34. class IndexWriter;
  35. class IndexReader;
  36. }
  37. namespace store {
  38. class Directory;
  39. }
  40. }
  41. class CLuceneIndexReader;
  42. class CLuceneIndexWriter;
  43. class CLuceneIndexManager : public Strigi::IndexManager {
  44. private:
  45. StrigiMutex writelock;
  46. StrigiMutex lock;
  47. std::string dbdir;
  48. std::map<STRIGI_THREAD_TYPE, CLuceneIndexReader*> readers;
  49. CLuceneIndexWriter* writer;
  50. lucene::index::IndexWriter* indexwriter;
  51. lucene::analysis::Analyzer* analyzer;
  52. struct timeval mtime;
  53. static int numberOfManagers;
  54. void openWriter(bool truncate=false);
  55. public:
  56. lucene::store::Directory* directory;
  57. explicit CLuceneIndexManager(const std::string& path);
  58. ~CLuceneIndexManager();
  59. lucene::index::IndexWriter* refWriter();
  60. void derefWriter();
  61. Strigi::IndexReader* indexReader();
  62. Strigi::IndexWriter* indexWriter();
  63. CLuceneIndexReader* luceneReader();
  64. int64_t indexSize();
  65. void deleteIndex();
  66. void closeWriter();
  67. struct timeval indexMTime();
  68. void setIndexMTime();
  69. };
  70. #endif