/strigi-0.7.7/libstreamanalyzer/plugins/indexers/clucenengindexer/cluceneindexwriter.h
C Header | 77 lines | 52 code | 6 blank | 19 comment | 0 complexity | d9fe302075cd402c8082deffe5218b89 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 CLUCENEINDEXWRITER_H
21#define CLUCENEINDEXWRITER_H
22
23#include <CLucene.h>
24#include <strigi/strigiconfig.h>
25#include <strigi/indexwriter.h>
26#include <strigi/analysisresult.h>
27#include <strigi/analyzerconfiguration.h>
28
29class CLuceneIndexManager;
30class CLuceneIndexWriter : public Strigi::IndexWriter {
31private:
32 CLuceneIndexManager* manager;
33 int doccount;
34 static const wchar_t* systemlocation();
35
36protected:
37 void startAnalysis(const Strigi::AnalysisResult*);
38 void finishAnalysis(const Strigi::AnalysisResult*);
39 void addText(const Strigi::AnalysisResult*, const char* text, int32_t length);
40 static void addValue(const Strigi::AnalysisResult* idx,
41 Strigi::AnalyzerConfiguration::FieldType type, const TCHAR* name,
42 const TCHAR* value);
43 static void addValue(const Strigi::AnalysisResult* idx,
44 Strigi::AnalyzerConfiguration::FieldType type, const TCHAR* name,
45 const std::string& value);
46 void addValue(const Strigi::AnalysisResult* idx,
47 const Strigi::RegisteredField* field, const std::string& value);
48 void addValue(const Strigi::AnalysisResult*,
49 const Strigi::RegisteredField* fieldname,
50 const unsigned char* data, uint32_t size);
51 void addValue(const Strigi::AnalysisResult*,
52 const Strigi::RegisteredField* fieldname, uint32_t value);
53 void addValue(const Strigi::AnalysisResult*,
54 const Strigi::RegisteredField* fieldname, int32_t value);
55 void addValue(const Strigi::AnalysisResult*,
56 const Strigi::RegisteredField* fieldname, double value);
57 void addTriplet(const std::string& subject,
58 const std::string& predicate, const std::string& object) {}
59 void addValue(const Strigi::AnalysisResult*,
60 const Strigi::RegisteredField* field, const std::string& name,
61 const std::string& value) {}
62 void initWriterData(const Strigi::FieldRegister& f);
63 void releaseWriterData(const Strigi::FieldRegister& f);
64public:
65 explicit CLuceneIndexWriter(CLuceneIndexManager* m);
66 ~CLuceneIndexWriter();
67 void commit();
68
69 void deleteEntries(const std::vector<std::string>& entries);
70 void deleteAllEntries();
71 void deleteEntry(const std::string& entry, lucene::index::IndexWriter* writer, lucene::index::IndexReader* reader);
72
73 static const TCHAR* mapId(const TCHAR* id);
74 static void addMapping(const TCHAR* from, const TCHAR* to);
75};
76
77#endif