root / tags / 1.0.8 / xapian-core / backends / flint / flint_record.cc

Revision 9256, 2.4 kB (checked in by olly, 16 months ago)

common/msvc_posix_wrapper.cc,common/msvc_posix_wrapper.h: Add
msvc_posix_rename() which can rename a file on top of another file.
common/stringutils.h: Add common_prefix_length() function.
backends/flint/: Clean up FlintWritableDatabase? - it now just
inherits from FlintDatabase? which allows several virtual methods
which just forwarded to FlintDatabase? to be dropped. Also, we
now no longer need to pass FlintTable objects to other classes
- they can just find the tables they want via the database pointer.
The never-used "store_termfreqs" flag has been dropped from the
termlist table entries - existing 1.0.x flint databases will be
automatically upgraded to the new version. Opening a database
now calls stat() less, so should be slightly more efficient.
And TermIterator::positionlist_count() now works for the flint
backend.
tests/Makefile.am,tests/api_db.cc,tests/testdata/flint-1.0.2/: New
test flintbackwardcompat2 which tests that we can open a flint
database from 1.0.2.
tests/api_wrdb.cc: New test adddoc4 which checks that termlists
handle an initial term of any valid length correctly.
tests/testdata/flint-1.0.1/postlist.DB: Mark as a binary file in
SVN.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* flint_record.cc: Records in flint databases
2 *
3 * ----START-LICENCE----
4 * Copyright 1999,2000,2001 BrightStation PLC
5 * Copyright 2002 Ananova Ltd
6 * Copyright 2002,2003,2004,2005 Olly Betts
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 * USA
22 * -----END-LICENCE-----
23 */
24
25#include <config.h>
26#include "flint_record.h"
27#include "flint_utils.h"
28#include "utils.h"
29#include <xapian/error.h>
30#include "omassert.h"
31#include "omdebug.h"
32
33using std::string;
34
35string
36FlintRecordTable::get_record(Xapian::docid did) const
37{
38    DEBUGCALL(DB, string, "FlintRecordTable::get_record", did);
39    string tag;
40
41    if (!get_exact_entry(flint_docid_to_key(did), tag)) {
42        throw Xapian::DocNotFoundError("Document " + om_tostring(did) + " not found.");
43    }
44
45    RETURN(tag);
46}
47
48
49Xapian::doccount
50FlintRecordTable::get_doccount() const
51{   
52    DEBUGCALL(DB, Xapian::doccount, "FlintRecordTable::get_doccount", "");
53    // Check that we can't overflow (the unsigned test is actually too
54    // strict as we can typically assign an unsigned short to a signed long,
55    // but this shouldn't actually matter here).
56    CASSERT(sizeof(Xapian::doccount) >= sizeof(flint_tablesize_t));
57    CASSERT_TYPE_UNSIGNED(Xapian::doccount);
58    CASSERT_TYPE_UNSIGNED(flint_tablesize_t);
59    RETURN(get_entry_count());
60}
61
62void
63FlintRecordTable::replace_record(const string & data, Xapian::docid did)
64{
65    DEBUGCALL(DB, void, "FlintRecordTable::replace_record", data << ", " << did);
66    add(flint_docid_to_key(did), data);
67}
68
69void
70FlintRecordTable::delete_record(Xapian::docid did)
71{
72    DEBUGCALL(DB, void, "FlintRecordTable::delete_record", did);
73    if (!del(flint_docid_to_key(did)))
74        throw Xapian::DocNotFoundError("Can't delete non-existent document #" + om_tostring(did));
75}
Note: See TracBrowser for help on using the browser.