xapian-core  1.4.21
chert_dbstats.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2009 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef XAPIAN_INCLUDED_CHERT_DBSTATS_H
22 #define XAPIAN_INCLUDED_CHERT_DBSTATS_H
23 
24 #include "chert_types.h"
25 #include "xapian/types.h"
26 
27 #include "internaltypes.h"
28 
29 class ChertPostListTable;
30 
34  void operator=(const ChertDatabaseStats &);
35 
38 
41 
44 
47 
50 
53 
54  public:
56  : total_doclen(0), last_docid(0), doclen_lbound(0), doclen_ubound(0),
57  wdf_ubound(0) { }
58 
60 
62 
64  return doclen_lbound;
65  }
66 
68  return doclen_ubound;
69  }
70 
72 
73  void zero() {
74  total_doclen = 0;
75  last_docid = 0;
76  doclen_lbound = 0;
77  doclen_ubound = 0;
78  wdf_ubound = 0;
79  }
80 
81  void read(ChertPostListTable & postlist_table);
82 
83  void set_last_docid(Xapian::docid did) { last_docid = did; }
84 
86  if (total_doclen == 0 || (doclen && doclen < doclen_lbound))
87  doclen_lbound = doclen;
88  if (doclen > doclen_ubound)
89  doclen_ubound = doclen;
90  total_doclen += doclen;
91  }
92 
94  total_doclen -= doclen;
95  // If the database no longer contains any postings, we can reset
96  // doclen_lbound, doclen_ubound and wdf_ubound.
97  if (total_doclen == 0) {
98  doclen_lbound = 0;
99  doclen_ubound = 0;
100  wdf_ubound = 0;
101  }
102  }
103 
105  if (wdf > wdf_ubound) wdf_ubound = wdf;
106  }
107 
109 
110  void write(ChertPostListTable & postlist_table) const;
111 };
112 
113 #endif // XAPIAN_INCLUDED_CHERT_DBSTATS_H
Xapian::termcount get_wdf_upper_bound() const
Definition: chert_dbstats.h:71
typedefs for Xapian
Xapian::termcount get_doclength_upper_bound() const
Definition: chert_dbstats.h:67
Xapian::termcount doclen_ubound
An upper bound on the greatest document length in this database.
Definition: chert_dbstats.h:49
Xapian::totallength get_total_doclen() const
Definition: chert_dbstats.h:59
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
Definition: types.h:139
void operator=(const ChertDatabaseStats &)
Don&#39;t allow assignment.
Xapian::docid get_next_docid()
Types used by chert backend and the Btree manager.
Xapian::docid get_last_docid() const
Definition: chert_dbstats.h:61
void delete_document(Xapian::termcount doclen)
Definition: chert_dbstats.h:93
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
void read(ChertPostListTable &postlist_table)
Xapian::termcount wdf_ubound
An upper bound on the greatest wdf in this database.
Definition: chert_dbstats.h:52
Xapian::totallength total_doclen
The total of the lengths of all documents in the database.
Definition: chert_dbstats.h:40
Xapian::docid last_docid
Greatest document id ever used in this database.
Definition: chert_dbstats.h:43
Xapian::termcount doclen_lbound
A lower bound on the smallest document length in this database.
Definition: chert_dbstats.h:46
void write(ChertPostListTable &postlist_table) const
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
Chert class for database statistics.
Definition: chert_dbstats.h:32
void set_last_docid(Xapian::docid did)
Definition: chert_dbstats.h:83
Xapian::termcount get_doclength_lower_bound() const
Definition: chert_dbstats.h:63
void add_document(Xapian::termcount doclen)
Definition: chert_dbstats.h:85
void check_wdf(Xapian::termcount wdf)
Types used internally.