Xpace
data_impl.h
Go to the documentation of this file.
1 
2 
3 /**************************************************************
4  **
5  ** @file data/data_impl.h
6  **
7  ** Copyright (C) 2012 Xpace, LLC. All rights reserved
8  **
9  ** www.xpace.net
10  **
11  **************************************************************/
12 
13 #ifndef XPACE_DATA_IMPL_H
14 #define XPACE_DATA_IMPL_H
15 
16 #include <functional>
17 
18 #include "base/types.h"
19 #include "data/data.h"
20 
21 namespace Xpace
22 {
23  // low-level returns
25  {
28  };
29 
30  typedef std::function<int64(int64 val)> NextDocCallback;
31 
32  inline
34  (int64 doc)
35  {
36  return ++doc;
37  }
38 
39  // Implements StatusCallback
40  // combine (e.g.) a search result (nextDoc), a Sink result, and a status callback
41  template <typename STORE>
43  {
44  public:
46  (NextDocCallback nextDoc,
47  typename STORE::Sink* sink,
48  StatusCallback status = defaultStatus) :
49  next_doc(nextDoc),
50  sink(sink),
51  status(status),
52  interval(1)
53  {
54  }
55 
56  int64 operator()
57  (int64 doc_num)
58  {
59  // check search result first
60  if ((doc_num = next_doc(doc_num)) < 0)
61  // e.g. at end of refList
62  return NDR_abort_true;
63 
64  // now check sink
65  if (sink)
66  {
67  doc_num = sink->start(doc_num);
68  if (doc_num < 0)
69  // client abort
70  return NDR_abort_false;
71  }
72 
73  // finally, check status
74  if ((--interval == 0) &&
75  ((interval = status(doc_num)) < 0))
76  doc_num = NDR_abort_false;
77 
78  return doc_num;
79  }
80 
81  private:
82  StatusCallback next_doc;
83  typename STORE::Sink* sink;
84  StatusCallback status;
85  uint64 interval;
86  };
87 }
88 
89 #endif
FindNextDoc(NextDocCallback nextDoc, typename STORE::Sink *sink, StatusCallback status=defaultStatus)
Definition: data_impl.h:46
std::function< int64(int64 val)> NextDocCallback
Definition: data_impl.h:30
int64 defaultNextDoc(int64 doc)
Definition: data_impl.h:34
NextDocResult
Definition: data_impl.h:24
unsigned long long uint64
Definition: types.h:87
static StatusCallback defaultStatus
Default status function.
Definition: types.h:461
std::function< int64(uint64 val)> StatusCallback
A status callback passed to operations that could be time-consuming.
Definition: types.h:457
long long int64
Definition: types.h:86
Xpace project main namespace
Definition: datetime.h:18

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