xapian-core  1.4.26
inmemory_document.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2008,2009,2016 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 #include <config.h>
22 
23 #include "inmemory_document.h"
24 
25 #include "inmemory_database.h"
26 
27 #include "debuglog.h"
28 
29 string
31 {
32  LOGCALL(DB, string, "InMemoryDocument::do_get_value", slot);
33  const InMemoryDatabase * db;
34  db = static_cast<const InMemoryDatabase*>(database.get());
35  if (rare(did > db->valuelists.size()))
36  RETURN(string());
37  map<Xapian::valueno, string> values_ = db->valuelists[did - 1];
38  map<Xapian::valueno, string>::const_iterator i;
39  i = values_.find(slot);
40  if (i == values_.end())
41  RETURN(string());
42  RETURN(i->second);
43 }
44 
45 void
46 InMemoryDocument::do_get_all_values(map<Xapian::valueno, string> &values_) const
47 {
48  LOGCALL_VOID(DB, "InMemoryDocument::do_get_all_values", values_);
49  const InMemoryDatabase * db;
50  db = static_cast<const InMemoryDatabase*>(database.get());
52  if (rare(did > db->valuelists.size())) {
53  values_.clear();
54  return;
55  }
56  values_ = db->valuelists[did - 1];
57 }
58 
59 string
61 {
62  LOGCALL(DB, string, "InMemoryDocument::do_get_data", NO_ARGS);
63  const InMemoryDatabase * db;
64  db = static_cast<const InMemoryDatabase*>(database.get());
66  if (rare(did > db->valuelists.size()))
67  RETURN(string());
68  RETURN(db->doclists[did - 1]);
69 }
#define RETURN(A)
Definition: debuglog.h:493
void do_get_all_values(map< Xapian::valueno, string > &values_) const
Implementation of virtual methods.
Xapian::docid did
The document ID of the document in that database.
Definition: document.h:90
A database held entirely in memory.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
Definition: debuglog.h:488
A document read from a InMemoryDatabase.
#define rare(COND)
Definition: config.h:575
Xapian::Internal::intrusive_ptr< const Xapian::Database::Internal > database
The database this document is in.
Definition: document.h:55
C++ class definition for inmemory database access.
string do_get_value(Xapian::valueno slot) const
Implementation of virtual methods.
vector< std::map< Xapian::valueno, string > > valuelists
static void throw_database_closed()
vector< std::string > doclists
unsigned valueno
The number for a value slot in a document.
Definition: types.h:108
string do_get_data() const
Implementation of virtual methods.
Debug logging macros.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
Definition: debuglog.h:487