| Qore DataProvider Module Reference 1.2.1

DataProviderPipeline.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3
25 // assume local scope for variables, do not use "$" signs
26 // require type definitions everywhere
28 // enable all warnings
29 // allow weak references
30
32 namespace DataProvider {
36 const PS_ABORTED = "ABORTED";
38
40 const PS_RUNNING = "RUNNING";
41
43 const PS_IDLE = "IDLE";
45
47 public struct PipelineInfo {
49 string name;
50
52 *date start_time;
53
55 *date stop_time;
56
58
60 string status;
61
63 int record_count;
64
66 int num_queues;
67
69
71 bool bulk;
72
74 date duration;
75
77 float duration_secs;
78
80 float recs_per_sec;
81 };
82
84 public struct PipelineOptionInfo {
86
88 *code debug_log;
89
91
93 *code error_log;
94
96
98 *code info_log;
99
101 /* it is called in the new pipeline queue thread with no arguments
102 */
103 *code thread_callback;
104
106 *string name;
107 };
108
110 class PipelineQueue {
111
112 public:
114 int id;
115
117 Mutex lck;
118
120 Counter cnt;
121
123 Condition cond();
124
126 Condition flush_cond();
127
129 int queue_waiting = 0;
130
132 int data_waiting = 0;
133
135 int flush_waiting = 0;
136
138 list<auto> queue;
139
141 int size;
142
144 int tid;
145
147
151 list<auto> elems();
152
154 bool do_flush;
155
157 bool data_flushed;
158
160 DataProviderPipeline parent;
161
163 constructor(DataProviderPipeline parent, Mutex lck, Counter cnt, int id, int size);
164
165
167 int getId();
168
169
171
175 submit(auto qdata);
176
177
179 run(Counter run_cnt);
180
181
183
185 waitDone();
186
187
190 protected:
191 runIntern();
192 public:
193
194
195 protected:
196 flushIntern();
197 public:
198
199 };
200
202
207 class DataProviderPipeline {
208
209 public:
210
211
212 protected:
214 string name;
215
217 hash<string, PipelineQueue> pmap;
218
220
222 bool do_bulk = True;
223
225 bool locked = False;
226
228 Sequence seq(1);
229
231 list<hash<ExceptionInfo>> error_list;
232
234 date start_time;
235
237 date stop_time;
238
240 int record_count = 0;
241
243 *code info_log;
244
246 *code error_log;
247
249 *code debug_log;
250
252 /* it is called in the new pipeline queue thread with no arguments
253 */
254 *code thread_callback;
255
257 Mutex lck();
258
260 bool stop_flag;
261
263 bool abort_flag;
264
266 Counter cnt();
267
268 public:
269
271
275 constructor(*hash<PipelineOptionInfo> opts);
276
277
279
281 copy();
282
283
285
291 destructor();
292
293
295 string getName();
296
297
299 bool hasQueue(int id);
300
301
303 bool stopping();
304
305
307 bool aborting();
308
309
311 registerThread(PipelineQueue queue);
312
313
315
320 append(AbstractDataProcessor processor);
321
322
324
334 append(int id, AbstractDataProcessor processor);
335
336
338
348 int appendQueue(int id);
349
350
352 bool isProcessing();
353
354
356 submit(auto _data);
357
358
360 submitData(AbstractIterator i);
361
362
364 submit(AbstractDataProviderRecordIterator i);
365
366
368 submit(AbstractDataProviderBulkRecordInterface i);
369
370
372
375 reset();
376
377
379
382 waitDone();
383
384
386
394 abort(*bool ignore_exceptions);
395
396
398
402 hash<PipelineInfo> getInfo();
403
404
406 reportError(PipelineQueue queue, hash<ExceptionInfo> ex);
407
408
410 logInfo(string fmt);
411
412
414 logError(string fmt);
415
416
418 logDebug(string fmt);
419
420
422 private:
423 PipelineQueue copyPipeline(PipelineQueue old_queue);
424 public:
425
426
428
430 private:
431 submitIntern(auto _data);
432 public:
433
434
436
438 private:
439 submitDataIntern(auto _data);
440 public:
441
442
444
448 private:
449 submitBulkIntern(AbstractDataProviderBulkRecordInterface i);
450 public:
451
452
454
456 private:
457 resetIntern();
458 public:
459
460
462
464 private:
465 checkSubmitIntern();
466 public:
467
468
470
472 private:
473 checkLockedIntern();
474 public:
475
476
478
480 private:
481 throwPipelineException();
482 public:
483
484
486 private:
487 checkUpdatePipelineIntern(int id);
488 public:
489
490
492 private:
493 stopIntern();
494 public:
495
496
498 private:
499 stopInternUnlocked();
500 public:
501
502 };
503 };
504
505 *list get_stack();
506
507
508
DataProvider::DataProviderPipeline::logError
logError(string fmt)
Logs to the error log, if set.
date
date date(date dt)
DataProvider::DataProviderPipeline::pmap
hash< string, PipelineQueue > pmap
Hash of queues keyed by queue ID.
Definition: DataProviderPipeline.qc.dox.h:217
DataProvider::PipelineOptionInfo::info_log
*code info_log
a closure or call reference for info logging
Definition: DataProviderPipeline.qc.dox.h:98
DataProvider::PipelineQueue::tid
int tid
TID of the background thread.
Definition: DataProviderPipeline.qc.dox.h:144
DataProvider::PipelineQueue::waitDone
waitDone()
Wait for the queue to be empty, then wait for all terminating pipelines to be empty.
DataProvider::PipelineQueue::getId
int getId()
Returns the pipeline ID.
DataProvider::DataProviderPipeline::copyPipeline
PipelineQueue copyPipeline(PipelineQueue old_queue)
Called by the copy constructor to copy the queues.
DataProvider::PipelineQueue::do_flush
bool do_flush
Flush pipeline flag.
Definition: DataProviderPipeline.qc.dox.h:154
DataProvider::DataProviderPipeline::start_time
date start_time
run start time
Definition: DataProviderPipeline.qc.dox.h:234
DataProvider::PipelineQueue::id
int id
Queue ID.
Definition: DataProviderPipeline.qc.dox.h:114
DataProvider::DataProviderPipeline::stop_flag
bool stop_flag
Stop flag.
Definition: DataProviderPipeline.qc.dox.h:260
DataProvider::DataProviderPipeline::submit
submit(auto _data)
Submits data for processing.
DataProvider::PS_ABORTED
const PS_ABORTED
Pipeline status: ABORTED.
Definition: DataProviderPipeline.qc.dox.h:37
DataProvider::AbstractDataProviderRecordIterator
Defines the abstract class for data provider iterators; the destructor releases the iterator...
Definition: AbstractDataProviderRecordIterator.qc.dox.h:33
DataProvider::PS_IDLE
const PS_IDLE
Pipeline status: IDLE.
Definition: DataProviderPipeline.qc.dox.h:43
DataProvider::PipelineInfo::duration
date duration
Total time processing end to end.
Definition: DataProviderPipeline.qc.dox.h:74
DataProvider::PipelineQueue::size
int size
Maximum queue size.
Definition: DataProviderPipeline.qc.dox.h:141
DataProvider::DataProviderPipeline::locked
bool locked
Locked flag.
Definition: DataProviderPipeline.qc.dox.h:225
DataProvider::PipelineInfo::name
string name
The name of the pipeline.
Definition: DataProviderPipeline.qc.dox.h:49
DataProvider::DataProviderPipeline::name
string name
A descriptive name for logging purposes.
Definition: DataProviderPipeline.qc.dox.h:214
DataProvider::PipelineInfo::num_queues
int num_queues
Number of pipeline queues.
Definition: DataProviderPipeline.qc.dox.h:66
True
const True
DataProvider::PipelineQueue::cond
Condition cond()
Queue condition variable.
DataProvider::DataProviderPipeline::error_log
*code error_log
Error log closure; takes a single format string and then arguments for format placeholders.
Definition: DataProviderPipeline.qc.dox.h:246
DataProvider::PipelineInfo::stop_time
*date stop_time
Stop time for processing.
Definition: DataProviderPipeline.qc.dox.h:55
DataProvider::DataProviderPipeline::reset
reset()
Resets the pipeline.
DataProvider::DataProviderPipeline::append
append(AbstractDataProcessor processor)
Appends a data processor to the default queue.
DataProvider::DataProviderPipeline::getName
string getName()
Returns the pipeline name.
DataProvider::DataProviderPipeline::appendQueue
int appendQueue(int id)
Appends a new queue to an existing pipeline and returns the new queue ID.
DataProvider::PipelineInfo::duration_secs
float duration_secs
Total time processing end to end as a floating-point value in durationSecondsFloat.
Definition: DataProviderPipeline.qc.dox.h:77
DataProvider::DataProviderPipeline::do_bulk
bool do_bulk
Bulk flag.
Definition: DataProviderPipeline.qc.dox.h:222
DataProvider::PipelineInfo::bulk
bool bulk
Flag that indicates if the pipeline is capable of bulk record processing.
Definition: DataProviderPipeline.qc.dox.h:71
False
const False
DataProvider::PipelineInfo::status
string status
Pipeline status.
Definition: DataProviderPipeline.qc.dox.h:60
DataProvider::DataProviderPipeline::debug_log
*code debug_log
Debug log closure; takes a single format string and then arguments for format placeholders.
Definition: DataProviderPipeline.qc.dox.h:249
DataProvider::PS_RUNNING
const PS_RUNNING
Pipeline status: RUNNING.
Definition: DataProviderPipeline.qc.dox.h:40
DataProvider::AbstractDataProcessor
Defines an abstract class for accepting data and outputting optionally transformed or filtered data...
Definition: AbstractDataProcessor.qc.dox.h:33
DataProvider::PipelineQueue::elems
list< auto > elems()
Pipeline elements.
DataProvider::PipelineQueue::flush_cond
Condition flush_cond()
Flush condition variable.
DataProvider::PipelineInfo
Pipeline info.
Definition: DataProviderPipeline.qc.dox.h:47
DataProvider::PipelineQueue::flush_waiting
int flush_waiting
Number of threads waiting on the flush cond.
Definition: DataProviderPipeline.qc.dox.h:135
DataProvider::DataProviderPipeline::stop_time
date stop_time
run stop time (set in waitDone())
Definition: DataProviderPipeline.qc.dox.h:237
DataProvider::DataProviderPipeline::isProcessing
bool isProcessing()
Returns True if the pipeline is processing data.
DataProvider::DataProviderPipeline::aborting
bool aborting()
Returns True if the object is aborting.
DataProvider::DataProviderPipeline::abort
abort(*bool ignore_exceptions)
Aborts execution of a pipeline in progress.
list
list< auto > list(...)
DataProvider::DataProviderPipeline::copy
copy()
Copy constructor; creates an empty pipeline with the same configuration as the original.
DataProvider::DataProviderPipeline::error_list
list< hash< ExceptionInfo > > error_list
list of exceptions in pipelines
Definition: DataProviderPipeline.qc.dox.h:231
DataProvider::PipelineInfo::recs_per_sec
float recs_per_sec
Records processed per second end to end.
Definition: DataProviderPipeline.qc.dox.h:80
DataProvider::DataProviderPipeline::thread_callback
*code thread_callback
a closure or call reference for setting thread-local data in new pipeline queue threads ...
Definition: DataProviderPipeline.qc.dox.h:254
DataProvider::PipelineOptionInfo::name
*string name
the name of the pipeline for logging purposes; if this key is not included, a generic name will be ge...
Definition: DataProviderPipeline.qc.dox.h:106
DataProvider::AbstractDataProviderBulkRecordInterface
Defines the abstract class for data provider iterators; the destructor releases the iterator...
Definition: AbstractDataProviderBulkRecordInterface.qc.dox.h:33
DataProvider::PipelineOptionInfo
Pipeline option info.
Definition: DataProviderPipeline.qc.dox.h:84
DataProvider::PipelineQueue::parent
DataProviderPipeline parent
Parent object.
Definition: DataProviderPipeline.qc.dox.h:160
DataProvider::DataProviderPipeline
Defines a class for passing data through record processors.
Definition: DataProviderPipeline.qc.dox.h:207
DataProvider::DataProviderPipeline::abort_flag
bool abort_flag
Abort flag.
Definition: DataProviderPipeline.qc.dox.h:263
DataProvider::PipelineQueue
Pipeline element.
Definition: DataProviderPipeline.qc.dox.h:110
DataProvider::PipelineQueue::data_waiting
int data_waiting
Number of threads waiting on data.
Definition: DataProviderPipeline.qc.dox.h:132
DataProvider::DataProviderPipeline::reportError
reportError(PipelineQueue queue, hash< ExceptionInfo > ex)
Called from a pipeline queue object to report a fatal error durring processing.
DataProvider::DataProviderPipeline::destructor
destructor()
Destroys the object.
DataProvider::DataProviderPipeline::waitDone
waitDone()
Waits for all queues to have processed remaining data.
DataProvider::DataProviderPipeline::submitIntern
submitIntern(auto _data)
Submits data for processing.
DataProvider::DataProviderPipeline::info_log
*code info_log
Info log closure; takes a single format string and then arguments for format placeholders.
Definition: DataProviderPipeline.qc.dox.h:243
DataProvider::DataProviderPipeline::submitData
submitData(AbstractIterator i)
Submits data for processing.
DataProvider::PipelineQueue::queue_waiting
int queue_waiting
Number of threads waiting data to be removed from the queue.
Definition: DataProviderPipeline.qc.dox.h:129
DataProvider::DataProviderPipeline::checkUpdatePipelineIntern
checkUpdatePipelineIntern(int id)
Check if the given queue exists.
DataProvider::PipelineInfo::start_time
*date start_time
Start of processing.
Definition: DataProviderPipeline.qc.dox.h:52
DataProvider::DataProviderPipeline::logDebug
logDebug(string fmt)
Logs to the debug log, if set.
DataProvider::PipelineQueue::queue
list< auto > queue
Data queue.
Definition: DataProviderPipeline.qc.dox.h:138
DataProvider::DataProviderPipeline::checkSubmitIntern
checkSubmitIntern()
Throws an exception if the pipeline cannot be used; locks the pipeline for changes otherwise...
DataProvider::DataProviderPipeline::checkLockedIntern
checkLockedIntern()
Throws an exception if the pipeline is locked.
DataProvider::PipelineOptionInfo::debug_log
*code debug_log
a closure or call reference for debug logging
Definition: DataProviderPipeline.qc.dox.h:88
DataProvider::DataProviderPipeline::hasQueue
bool hasQueue(int id)
Returns True if the given queue exists, False if not.
DataProvider::DataProviderPipeline::constructor
constructor(*hash< PipelineOptionInfo > opts)
Creates the object with the given options.
DataProvider::DataProviderPipeline::seq
Sequence seq(1)
Pipeline ID sequence generator.
DataProvider::DataProviderPipeline::getInfo
hash< PipelineInfo > getInfo()
Returns pipeline info.
DataProvider::PipelineInfo::record_count
int record_count
Number of input records submitted.
Definition: DataProviderPipeline.qc.dox.h:63
DataProvider::PipelineQueue::cnt
Counter cnt
Parent counter.
Definition: DataProviderPipeline.qc.dox.h:120
DataProvider::DataProviderPipeline::throwPipelineException
throwPipelineException()
Throws an exception if errors occured in background pipeline processing.
DataProvider::PipelineQueue::run
run(Counter run_cnt)
Processing thread.
DataProvider::DataProviderPipeline::stopInternUnlocked
stopInternUnlocked()
Stops all background pipeline queues; lock must be held.
DataProvider
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:27
DataProvider::PipelineOptionInfo::thread_callback
*code thread_callback
a closure or call reference for setting thread-local data in new pipeline queue threads ...
Definition: DataProviderPipeline.qc.dox.h:103
DataProvider::DataProviderPipeline::record_count
int record_count
Record count.
Definition: DataProviderPipeline.qc.dox.h:240
DataProvider::DataProviderPipeline::logInfo
logInfo(string fmt)
Logs to the info log, if set.
DataProvider::DataProviderPipeline::stopIntern
stopIntern()
Stops all background pipeline queues.
DataProvider::DataProviderPipeline::stopping
bool stopping()
Returns True if the object is stopping.
DataProvider::DataProviderPipeline::cnt
Counter cnt()
Thread counter.
DataProvider::PipelineOptionInfo::error_log
*code error_log
a closure or call reference for error logging
Definition: DataProviderPipeline.qc.dox.h:93
DataProvider::PipelineQueue::submit
submit(auto qdata)
Submits data for processing.
DataProvider::PipelineQueue::runIntern
runIntern()
DataProvider::PipelineQueue::data_flushed
bool data_flushed
Data flushed confirmation.
Definition: DataProviderPipeline.qc.dox.h:157
DataProvider::DataProviderPipeline::resetIntern
resetIntern()
Resets the pipeline.
DataProvider::DataProviderPipeline::submitDataIntern
submitDataIntern(auto _data)
Submits a single record for processing.
DataProvider::DataProviderPipeline::submitBulkIntern
submitBulkIntern(AbstractDataProviderBulkRecordInterface i)
Submits bulk data for processing.
DataProvider::PipelineQueue::constructor
constructor(DataProviderPipeline parent, Mutex lck, Counter cnt, int id, int size)
Creates the object.
DataProvider::DataProviderPipeline::lck
Mutex lck()
Atomic lock.
DataProvider::PipelineQueue::lck
Mutex lck
Parent lock.
Definition: DataProviderPipeline.qc.dox.h:117
DataProvider::DataProviderPipeline::registerThread
registerThread(PipelineQueue queue)
Registers a new thread.