29 #ifdef XAPIAN_HAS_GLASS_BACKEND 34 #ifdef XAPIAN_HAS_CHERT_BACKEND 52 #ifdef XAPIAN_HAS_GLASS_BACKEND 69 #if defined XAPIAN_HAS_CHERT_BACKEND || defined XAPIAN_HAS_GLASS_BACKEND 77 *out <<
"Cross-checking document lengths between the postlist and " 78 "termlist tables would use more than 1GB of memory, so " 79 "skipping that check" << endl;
83 doclens.reserve(last_docid + 1);
84 }
catch (
const std::bad_alloc &) {
87 *out <<
"Couldn't allocate enough memory for cross-checking document " 88 "lengths between the postlist and termlist tables, so " 89 "skipping that check" << endl;
90 }
catch (
const std::length_error &) {
93 *out <<
"Couldn't allocate enough elements for cross-checking document " 94 "lengths between the postlist and termlist tables, so " 95 "skipping that check" << endl;
104 if (stat((path +
"/iamchert").c_str(), &sb) == 0) {
105 #ifndef XAPIAN_HAS_CHERT_BACKEND 111 vector<Xapian::termcount> doclens;
131 *out <<
"Database couldn't be opened for reading: " 133 <<
"\nContinuing check anyway" << endl;
137 size_t pre_table_check_errors = errors;
145 static const struct {
char name[9]; } tables[] = {
153 for (
auto t : tables) {
154 const char *
name = t.name;
156 *out << name <<
":\n";
157 if (strcmp(name,
"record") != 0 && strcmp(name,
"postlist") != 0) {
165 if (strcmp(name,
"termlist") == 0) {
166 *out <<
"Not present.\n";
168 *out <<
"Lazily created, and not yet used.\n";
176 doccount, db_last_docid, out);
192 if (stat((path +
"/iamglass").c_str(), &sb) == 0) {
193 #ifndef XAPIAN_HAS_GLASS_BACKEND 199 vector<Xapian::termcount> doclens;
208 *out <<
"Database couldn't be opened for reading: " 210 <<
"\nContinuing check anyway" << endl;
217 string changes_file = path;
218 changes_file +=
"/changes";
219 changes_file +=
str(r);
226 if (db_last_docid < doccount) {
228 *out <<
"last_docid = " << db_last_docid <<
" < doccount = " 243 if (stat((path +
"/iamflint").c_str(), &sb) == 0) {
248 if (stat((path +
"/iambrass").c_str(), &sb) == 0) {
253 if (stat((path +
"/record_DB").c_str(), &sb) == 0) {
259 "Directory does not contain a Xapian database");
272 size_t p = filename.find_last_of(
DIR_SEPS);
278 string dir(filename, 0, p);
281 while (p != filename.size()) {
282 char ch = filename[p++];
283 if (ch ==
'.')
break;
287 #if defined XAPIAN_HAS_CHERT_BACKEND || defined XAPIAN_HAS_GLASS_BACKEND 288 vector<Xapian::termcount> doclens;
296 #ifndef XAPIAN_HAS_GLASS_BACKEND 297 auto msg =
"Glass database support isn't enabled";
318 if (stat((dir +
"/iamflint").c_str(), &sb) == 0) {
322 if (stat((dir +
"/iambrass").c_str(), &sb) == 0) {
326 #ifndef XAPIAN_HAS_CHERT_BACKEND 352 #ifdef XAPIAN_HAS_GLASS_BACKEND 359 if (db_last_docid < doccount) {
361 *out <<
"last_docid = " << db_last_docid <<
" < doccount = " 365 vector<Xapian::termcount> doclens;
371 version_file,
opts, doclens,
395 [&errors, opts, out](
const string& path) {
396 errors += Database::check(path, opts, out);
398 [&errors,
opts, out](
const string& path) {
400 errors += Database::check(path, opts, out);
402 [&errors,
opts, out](
const string& path) {
404 errors += Database::check(path, opts, out);
406 [](
const string&,
const string&) {
407 auto msg =
"Remote database checking not implemented";
410 [](
const string&, unsigned) {
411 auto msg =
"Remote database checking not implemented";
415 auto msg =
"InMemory database checking not implemented";
422 Database::check_(
const string * path_ptr,
int fd,
int opts, std::ostream *out)
430 if (path_ptr == NULL) {
434 const string & path = *path_ptr;
436 if (stat(path.c_str(), &sb) == 0) {
467 string filename = path;
469 filename.resize(filename.size() - 1);
473 if (stat((filename +
".DB").c_str(), &sb) == 0) {
479 auto msg =
"Couldn't find Xapian database or table to check";
Xapian::docid get_lastdocid() const
Virtual methods of Database::Internal.
The Xapian namespace contains public interfaces for the Xapian library.
bool endswith(const std::string &s, char sfx)
static size_t check_stub(const string &stub_path, int opts, std::ostream *out)
void read_and_check()
Read the version file and check it's a version we understand.
XAPIAN_REVISION_TYPE rev
Revision number of a database.
This class is used to access a database, or a group of databases.
DatabaseOpeningError indicates failure to open a database.
uint4 glass_revision_number_t
The revision number of a glass database.
Xapian::doccount get_doccount() const
Virtual methods of Database::Internal.
Constants in the Xapian namespace.
The GlassVersion class manages the revision files.
Helper functions for database handling.
chert_revision_number_t get_revision_number() const
Get an object holding the revision number which the tables are opened at.
static void reserve_doclens(vector< Xapian::termcount > &doclens, Xapian::docid last_docid, ostream *out)
static void check(const std::string &changes_file)
static size_t check_db_fd(int fd, int opts, std::ostream *out, int backend)
Check a single file DB from an fd.
Utility functions for testing files.
Types used by chert backend and the Btree manager.
size_t check_glass_table(const char *tablename, const string &db_dir, int fd, off_t offset_, const GlassVersion &version_file, int opts, vector< Xapian::termcount > &doclens, ostream *out)
unsigned int chert_revision_number_t
A type used to store a revision number for a table.
#define GLASS_TABLE_EXTENSION
Glass table extension.
Xapian::docid get_last_docid() const
int test_if_single_file_db(const struct stat &sb, const string &path, int *fd_ptr)
Probe if a path is a single-file database.
Hierarchy of classes which Xapian can throw as exceptions.
The ChertVersion class manages the "iamchert" file.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Indicates an attempt to use a feature which is unavailable.
API for working with Xapian databases.
string str(int value)
Convert int to std::string.
#define CHERT_MAX_DOCID
The largest docid value supported by chert.
void read_stub_file(const std::string &file, A1 action_auto, A2 action_chert, A3 action_glass, A4 action_remote_prog, A5 action_remote_tcp, A6 action_inmemory)
Open, read and process a stub database file.
const int DBCHECK_FIX
Fix problems.
void read()
Read the version file and check it's a version we understand.
C++ class definition for chert database.
std::string get_description() const
Return a string describing this object.
void create()
Create the version file.
static size_t check_db_table(const string &filename, int opts, std::ostream *out, int backend)
Check a database table.
size_t check_chert_table(const char *tablename, const string &dir, chert_revision_number_t *rev_ptr, int opts, vector< Xapian::termcount > &doclens, Xapian::doccount doccount, Xapian::docid db_last_docid, ostream *out)
static size_t check_db_dir(const string &path, int opts, std::ostream *out)
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
static const struct @3 glass_tables[]
A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree s...
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Various handy helpers which std::string really should provide.
Various assertion macros.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
DatabaseError indicates some sort of database related error.
glass_revision_number_t get_revision() const
bool file_exists(const char *path)
Test if a file exists.
UnimplementedError indicates an attempt to use an unimplemented feature.
Xapian::doccount get_doccount() const