libdballe 9.6
summary_xapian.h
1#ifndef DBALLE_DB_SUMMARY_XAPIAN_H
2#define DBALLE_DB_SUMMARY_XAPIAN_H
3
4#include <dballe/core/fwd.h>
5#include <dballe/db/summary.h>
6#include <xapian.h>
7
8namespace dballe {
9namespace db {
10
16{
17 virtual ~XapianDB() {}
18
19 virtual Xapian::Database& reader() = 0;
20 virtual Xapian::WritableDatabase& writer() = 0;
21 virtual void commit() = 0;
22 virtual void clear() = 0;
23};
24
28template<typename Station>
29class BaseSummaryXapian: public BaseSummary<Station>
30{
31 std::unique_ptr<XapianDB> db;
32
33public:
35 BaseSummaryXapian(const std::string& pathname);
37
38 bool stations(std::function<bool(const Station&)>) const override;
39 bool reports(std::function<bool(const std::string&)>) const override;
40 bool levels(std::function<bool(const Level&)>) const override;
41 bool tranges(std::function<bool(const Trange&)>) const override;
42 bool varcodes(std::function<bool(const wreport::Varcode&)>) const override;
43
44 Datetime datetime_min() const override;
45 Datetime datetime_max() const override;
46 unsigned data_count() const override;
47
48 void clear() override;
49 void add(const Station& station, const summary::VarDesc& vd, const dballe::DatetimeRange& dtrange, size_t count) override;
50 void commit() override;
51
52 bool iter(std::function<bool(const Station&, const summary::VarDesc&, const DatetimeRange&, size_t)>) const override;
53 bool iter_filtered(const dballe::Query& query, std::function<bool(const Station&, const summary::VarDesc&, const DatetimeRange&, size_t)>) const override;
54
56 void to_json(core::JSONWriter& writer) const override;
57
58 DBALLE_TEST_ONLY void dump(FILE* out) const override;
59};
60
65
70
71extern template class BaseSummaryXapian<dballe::Station>;
72extern template class BaseSummaryXapian<dballe::DBStation>;
73
74}
75}
76
77#endif
Query used to filter DB-All.e data.
Definition: query.h:15
JSON serializer.
Definition: json.h:30
High level objects for working with DB-All.e DB summaries.
Definition: summary_xapian.h:30
void commit() override
Write changes to disk.
void add(const Station &station, const summary::VarDesc &vd, const dballe::DatetimeRange &dtrange, size_t count) override
Add an entry to the summary.
void to_json(core::JSONWriter &writer) const override
Serialize to JSON.
bool iter(std::function< bool(const Station &, const summary::VarDesc &, const DatetimeRange &, size_t)>) const override
Iterate the contents of this summary. There is no guarantee on sorting order.
void clear() override
Completely empty the summary.
bool iter_filtered(const dballe::Query &query, std::function< bool(const Station &, const summary::VarDesc &, const DatetimeRange &, size_t)>) const override
Iterate the contents of this summary. There is no guarantee on sorting order.
Datetime datetime_min() const override
Recompute reports, levels, tranges, and varcodes.
High level objects for working with DB-All.e DB summaries.
Definition: summary.h:45
uint16_t Varcode
Range of datetimes.
Definition: types.h:295
Date and time.
Definition: types.h:165
Vertical level or layer.
Definition: types.h:625
Station information.
Definition: types.h:794
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:687
Abstract interface for accessing Xapian databases, with read locking only when needed.
Definition: summary_xapian.h:16
Description of a variable, independent of where and when it was measured.
Definition: summary.h:18