Xpace
indexlist_impl.h
Go to the documentation of this file.
1 
2 /**************************************************************
3  **
4  ** @file index/indexlist_impl.h
5  **
6  ** Copyright (C) 2012 Xpace, LLC. All rights reserved
7  **
8  ** www.xpace.net
9  **
10  **************************************************************/
11 
12 #ifndef XPACE_INDEXLIST_IMPL_H
13 #define XPACE_INDEXLIST_IMPL_H
14 
15 #include <QtCore/QCache>
16 
17 #include "base/config.h"
18 
19 #include "index/indexlist.h"
20 
21 namespace Xpace
22 {
23  struct loadIndexPools;
24 
25  class indexListImpl : public ConfigImpl
26  {
27  public:
29  ();
30 
31  // open an already-existing index list,
32  // or create one with this configuration
34  (const Configuration& config, // if reading, config from ii file goes here
35  bool overwrite);
36 
38  ();
39 
40  // how many indexes
42  ()
43  const;
44 
46  (uint indexNum)
47  const;
48 
50  (const String& tag,
51  size_t pos)
52  const;
53 
54  // get an index by name
56  (const String& indexName,
57  uint* indexNum,
59  const Index& openIndex
60  (const String& indexName,
61  uint* indexNum,
63  const;
64 
65  // get an index by number
67  (uint indexNum,
69  const Index& openIndex
70  (uint indexNum,
72  const;
73 
74  // add a named index; return index number
76  (Index&);
77 
78  // add an index by number
79  void addIndex
80  (uint indexNum,
81  Index&);
82 
83  #ifdef XPACE_SCURSOR_H
84  // bulk index from SCursor
85  bool build
86  (SCursor*,
88  Index::WriteStatus* = 0);
89  #endif
90 
91  #ifdef XPACE_TABLE_H
92  // bulk index from TableCursor
93  bool build
94  (Table*,
96  Index::WriteStatus* = 0);
97  #endif
98 
99  // write in current state
100  bool write
101  (Index::WriteStatus* = 0);
102 
103  bool range
104  (const Configuration& /*rangeConfig*/,
105  Index::WriteStatus* /*status*/)
106  {
107  // TODO
108  return false;
109  }
110 
111  // merge index lists
112  static
113  bool merge
114  (const Configuration& /*config*/,
115  const std::vector<IndexList*>& /*indexLists*/,
116  Index::WriteStatus* = 0)
117  {
118  // TODO
119  return false;
120  }
121 
122  struct indexDesc
123  {
127  };
128 
129  // ref-count
130  void ref
131  ();
132  bool unref
133  ();
134 
135  static size_t HashTableBytes;
136 
137  private:
138  QAtomicInt ref_count;
139 
141  (const indexListImpl&);
142  indexListImpl& operator=
143  (const indexListImpl&);
144 
145  Index& find_index
146  (size_t indexNum,
147  Configuration config)
148  const;
149 
150  mutable File index_file;
151  mutable File index_list_file;
152 
153  uint64 doc_count;
154 
155  mutable std::vector<Index> index_list;
156  mutable std::vector<Configuration> config_list;
157  std::map<String, size_t> name_list;
158  std::map<String, std::vector<size_t> > field_list;
159 
160  struct index_list_header
161  {
162  index_list_header
163  ()
164  {
165  };
166  index_list_header
167  (uint16 vers,
168  uint16 rel,
169  uint64 first,
170  uint64 count) :
171  version(vers),
172  relative(rel),
173  firstDoc(first),
174  docCount(count)
175  {
176  };
177 
178  uint16 version;
179  uint16 relative; // bool; refs are relative to this list, not database
180  uint64 firstDoc;
181  uint64 docCount;
182  };
183 
184  std::vector<indexDesc> index_desc_list;
185 
186  loadIndexPools* load_index_pools;
187  };
188 }
189 
190 #endif
bool write(Index::WriteStatus *=0)
uint getCount() const
unsigned int uint
Definition: types.h:75
static size_t HashTableBytes
Each high-level Xpace object has a Configuration.
Definition: config.h:29
const Configuration & getIndexConfig(uint indexNum) const
A string, Unicode UTF-16 and reference-counted.
Definition: types.h:269
uint getIndexByField(const String &tag, size_t pos) const
unsigned long long uint64
Definition: types.h:87
uint64 Position
Definition: file.h:40
uint addIndex(Index &)
static bool merge(const Configuration &, const std::vector< IndexList * > &, Index::WriteStatus *=0)
write this index; could take a while status callback
Definition: index.h:97
bool range(const Configuration &, Index::WriteStatus *)
unsigned short uint16
Definition: types.h:83
Xpace project main namespace
Definition: datetime.h:18
Index & openIndex(const String &indexName, uint *indexNum, Configuration=Configuration())
An index.
Definition: index.h:24

current as of Wed Jun 10 2026 12:00:05