-
Notifications
You must be signed in to change notification settings - Fork 9
/
DataProvider.qm
329 lines (276 loc) · 18.7 KB
/
DataProvider.qm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# -*- mode: qore; indent-tabs-mode: nil -*-
#! @file DataProvider.qm module for data access and introspection
/* DataProvider.qm Copyright 2019 - 2022 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
# minimum required Qore version
%requires qore >= 1.1
# assume local scope for variables, do not use "$" signs
%new-style
# require type definitions everywhere
%require-types
# strict argument handling
%strict-args
# enable all warnings
%enable-all-warnings
%requires(reexport) reflection
%requires(reexport) Util
%requires(reexport) MapperUtil
module DataProvider {
version = "2.3";
desc = "user module for data access and introspection";
author = "David Nichols <david@qore.org>";
url = "http://qore.org";
license = "MIT";
init = sub () {
# register the data provider factory
DataProvider::registerFactory(new NullDataProviderFactory());
# to workaround #4048 (circular initialization error)
AbstractDataProviderType::anyDataType = new QoreDataType(AutoType);
};
}
/** @mainpage DataProvider Module
@tableofcontents
@section dataproviderintro Introduction to the DataProvider Module
The %DataProvider module provides APIs for hierarchical data structures from arbitrary sources to be described,
queried, introspected, and updated. It also supports data providers with request-reply semantics such as REST
schemas or with SOAP messaging.
The data provider module supports high-performance reading (searching) and writing as well as record creation and
upserting and transaction management if supported by the underlying data provider implementation as well.
The %Qore command-line program \c qdp provides a user-friendly interface to data provider functionality.
This module provides the following primary classes:
- @ref DataProvider::AbstractDataField "AbstractDataField"
- @ref DataProvider::AbstractDataProcessor "AbstractDataProcessor"
- @ref DataProvider::AbstractDataProvider "AbstractDataProvider"
- @ref DataProvider::AbstractDataProviderBulkOperation "AbstractDataProviderBulkOperation"
- @ref DataProvider::AbstractDataProviderBulkRecordInterface "AbstractDataProviderBulkRecordInterface"
- @ref DataProvider::AbstractDataProviderFactory "AbstractDataProviderFactory"
- @ref DataProvider::AbstractDataProviderRecordIterator "AbstractDataProviderRecordIterator"
- @ref DataProvider::DataProvider "DataProvider"
- @ref DataProvider::DataProviderBulkRecordIterator "DataProviderBulkRecordIterator"
- @ref DataProvider::DataProviderPipeline "DataProviderPipeline"
- @ref DataProvider::DefaultBulkInserter "DefaultBulkInserter"
- @ref DataProvider::DefaultBulkUpserter "DefaultBulkUpserter"
- @ref DataProvider::DefaultBulkRecordIterface "DefaultBulkRecordIterface"
- @ref DataProvider::DefaultRecordIterator "DefaultRecordIterator"
- @ref DataProvider::QoreDataField "QoreDataField"
The following supporting type classes are also provided:
- @ref DataProvider::AbstractDataProviderType "AbstractDataProviderType"
- @ref DataProvider::DataProviderTypeCache "DataProviderTypeCache"
- @ref DataProvider::HashDataType "HashDataType"
- @ref DataProvider::HashDeclDataType "HashDeclDataType"
- @ref DataProvider::ListDataType "ListDataType"
- @ref DataProvider::NullDataProvider "NullDataProvider"
- @ref DataProvider::NullDataProviderFactory "NullDataProviderFactory"
- @ref DataProvider::QoreBinaryDataType "QoreBinaryDataType"
- @ref DataProvider::QoreBinaryDataTypeBase "QoreBinaryDataTypeBase"
- @ref DataProvider::QoreBinaryOrNothingDataType "QoreBinaryOrNothingDataType"
- @ref DataProvider::QoreBoolDataType "QoreBoolDataType"
- @ref DataProvider::QoreBoolDataTypeBase "QoreBoolDataTypeBase"
- @ref DataProvider::QoreBoolOrNothingDataType "QoreBoolOrNothingDataType"
- @ref DataProvider::QoreDataType "QoreDataType"
- @ref DataProvider::QoreDateDataType "QoreDateDataType"
- @ref DataProvider::QoreDateDataTypeBase "QoreDateDataTypeBase"
- @ref DataProvider::QoreDateOrNothingDataType "QoreDateOrNothingDataType"
- @ref DataProvider::QoreFloatDataType "QoreFloatDataType"
- @ref DataProvider::QoreFloatDataTypeBase "QoreFloatDataTypeBase"
- @ref DataProvider::QoreFloatOrNothingDataType "QoreFloatOrNothingDataType"
- @ref DataProvider::QoreHashDataType "QoreHashDataType"
- @ref DataProvider::QoreIntDataType "QoreIntDataType"
- @ref DataProvider::QoreIntDataTypeBase "QoreIntDataTypeBase"
- @ref DataProvider::QoreIntOrNothingDataType "QoreIntOrNothingDataType"
- @ref DataProvider::QoreListDataType "QoreListDataType"
- @ref DataProvider::QoreNumberDataType "QoreNumberDataType"
- @ref DataProvider::QoreNumberDataTypeBase "QoreNumberDataTypeBase"
- @ref DataProvider::QoreNumberOrNothingDataType "QoreNumberOrNothingDataType"
- @ref DataProvider::QoreSoftBinaryDataType "QoreSoftBinaryDataType"
- @ref DataProvider::QoreSoftBinaryNoNullDataType "QoreSoftBinaryNoNullDataType"
- @ref DataProvider::QoreSoftBinaryOrNothingDataType "QoreSoftBinaryOrNothingDataType"
- @ref DataProvider::QoreSoftBoolDataType "QoreSoftBoolDataType"
- @ref DataProvider::QoreSoftBoolNoNullDataType "QoreSoftBoolNoNullDataType"
- @ref DataProvider::QoreSoftBoolOrNothingDataType "QoreSoftBoolOrNothingDataType"
- @ref DataProvider::QoreSoftDateDataType "QoreSoftDateDataType"
- @ref DataProvider::QoreSoftDateNoNullDataType "QoreSoftDateNoNullDataType"
- @ref DataProvider::QoreSoftDateOrNothingDataType "QoreSoftDateOrNothingDataType"
- @ref DataProvider::QoreSoftFloatDataType "QoreSoftFloatDataType"
- @ref DataProvider::QoreSoftFloatNoNullDataType "QoreSoftFloatNoNullDataType"
- @ref DataProvider::QoreSoftFloatOrNothingDataType "QoreSoftFloatOrNothingDataType"
- @ref DataProvider::QoreSoftIntDataType "QoreSoftIntDataType"
- @ref DataProvider::QoreSoftIntNoNullDataType "QoreSoftIntNoNullDataType"
- @ref DataProvider::QoreSoftIntOrNothingDataType "QoreSoftIntOrNothingDataType"
- @ref DataProvider::QoreSoftNumberDataType "QoreSoftNumberDataType"
- @ref DataProvider::QoreSoftNumberNoNullDataType "QoreSoftNumberNoNullDataType"
- @ref DataProvider::QoreSoftNumberOrNothingDataType "QoreSoftNumberOrNothingDataType"
- @ref DataProvider::QoreSoftStringDataType "QoreSoftStringDataType"
- @ref DataProvider::QoreSoftStringOrNothingDataType "QoreSoftStringOrNothingDataType"
- @ref DataProvider::QoreStringDataType "QoreStringDataType"
- @ref DataProvider::QoreStringDataTypeBase "QoreStringDataTypeBase"
- @ref DataProvider::QoreStringOrNothingDataType "QoreStringOrNothingDataType"
@subsection dataprovider_modules Data Provider Modules
This module uses the \c "QORE_DATA_PROVIDERS" environment variable to register data provider
modules. Each data provider registration module must provide one of the following two public functions.
@subsubsection dataprovider_dynamic_discovery Data Provider Dynamic Discovery
Implement a public function with the following signature to support dynamic discovery of data providers:
@code{.py}
# returns a hash of connection provider factory names to module names
public hash<string, string> sub get_data_provider_map() { ... }
@endcode
@subsubsection dataprovider_type_dynamic_discovery Data Provider Type Dynamic Discovery
Implement a public function with the following signature to support dynamic discovery of data provider types:
@code{.py}
# returns a hash of type prefix paths (ex: \c "qore/sftp") to module names
public hash<string, string> sub get_type_provider_map() { ... }
@endcode
Data provider registration modules declared in the \c "QORE_DATA_PROVIDERS" environment variable must
be separated by the platform-specific @ref Qore::PathSep "PathSep" character as in the following
examples:
@par Unix Example
@verbatim
export QORE_DATA_PROVIDERS=MyConnectionProvider:OtherConnectionProvider
@endverbatim
@par Windows CMD.EXE Example
@verbatim
set QORE_DATA_PROVIDERS=MyConnectionProvider;OtherConnectionProvider
@endverbatim
@par Windows PowerShell Example
@verbatim
$env:QORE_DATA_PROVIDERS="MyConnectionProvider;OtherConnectionProvider"
@endverbatim
@section dataprovider_pipelines Data Provider Pipelines
Data provider pipelines allow for efficient processing of record or other data in multiple streams and, if
desired, in multiple threads.
Pipeline data can be any data type except a list, as list values are interpreted as multiple output values in
@ref DataProvider::AbstractDataProcessor "pipeline procesor objects".
@section dataprovider_pipeline_bulk_processing Data Provider Pipeline Bulk Processing
Bulk processing is processing of record data that is in "hash of lists" form, so a single hash, where each key
value is a list of values for that key. Records can be formed as by taking each hash key and then using each
list value in order for the values of each record. In case a key is assigned a single value instead of a
list, it's interpreted as constant value for all records. Note that the first key value for bulk data must be a
list of values in order for the bulk data to be properly detected.
Each pipeline processor element must declare if it is compatible with bulk processing by implementing the
@ref DataProvider::AbstractDataProcessor::supportsBulkApiImpl() "AbstractDataProcessor::supportsBulkApiImpl()"
method.
If a processor does not support the bulk API, but bulk data is submitted, then the bulk data will be separately
iterated, and each record will be passed separately to the processor with a significant performance penalty when
processing large volumes of data.
@section dataprovider_relnotes Release Notes
@subsection dataprovider_v2_3 DataProvider v2.3
- addded \c search_operators to the data provider response to report supported search operators
(<a href="https://github.com/qorelanguage/qore/issues/4528">issue 4528</a>)
- fixed a type error in \c DataProvider::search*() calls with an empty \c where hash argument
(<a href="https://github.com/qorelanguage/qore/issues/4511">issue 4511</a>)
@subsection dataprovider_v2_2_1 DataProvider v2.2.1
- made it possible to determine the default field type in @ref DataProvider::HashDataType "HashDataType"
(<a href="https://github.com/qorelanguage/qore/issues/4491">issue 4491</a>)
@subsection dataprovider_v2_2 DataProvider v2.2
- added an attribute to factories to indicate if any children can support the request-response pattern
(<a href="https://github.com/qorelanguage/qore/issues/4486">issue 4486</a>)
- added the @ref DataProvider::DTT_ClientOnly "DTT_ClientOnly" type tag constant
(<a href="https://github.com/qorelanguage/qore/issues/4477">issue 4477</a>)
@subsection dataprovider_v2_1_2 DataProvider v2.1.2
- fixed a bug where %DataProvider types based on string that accept multiple input types with conversions but are
not soft types threw spurious errors at runtime with non-string types
(<a href="https://github.com/qorelanguage/qore/issues/4471">issue 4471</a>)
- added the \c desc key supporting a markdown description to data provider info
(<a href="https://github.com/qorelanguage/qore/issues/4465">issue 4465</a>)
- fixed a bug where hash types incorrectly claimed compatibility with incompatible hashes
(<a href="https://github.com/qorelanguage/qore/issues/4463">issue 4463</a>)
@subsection dataprovider_v2_1_1 DataProvider v2.1.1
- fixed a type error iterating data in @ref DataProvider::DefaultBulkRecordIterface "DefaultBulkRecordIterface"
(<a href="https://github.com/qorelanguage/qore/issues/4457">issue 4457</a>)
@subsection dataprovider_v2_1 DataProvider v2.1
- added support for tags on data provider types (i.e.
@ref DataProvider::AbstractDataProviderType "AbstractDataProviderType")
(<a href="https://github.com/qorelanguage/qore/issues/4442">issue 4442</a>)
- fixed data provider factory info to provide info about the actual data provider factory instead of only provider
info
(<a href="https://github.com/qorelanguage/qore/issues/4438">issue 4438</a>)
- added "from example" APIs to data provider factories:
- @ref DataProvider::AbstractDataProviderFactory::getProviderFromExample() "AbstractDataProviderFactory::getProviderFromExample()"
- @ref DataProvider::AbstractDataProviderFactory::getExampleProviderRecordOutput() "AbstractDataProviderFactory::getExampleProviderRecordOutput()"
(<a href="https://github.com/qorelanguage/qore/issues/4430">issue 4430</a>)
- added generic search capabilities to data providers with no native search capabilities
(<a href="https://github.com/qorelanguage/qore/issues/4430">issue 4430</a>)
@subsection dataprovider_v2_0 DataProvider v2.0
- added a logger to the @ref DataProvider::AbstractDataProvider "AbstractDataProvider" class to enable logging
(<a href="https://github.com/qorelanguage/qore/issues/4409">issue 4409</a>)
- added support for creating, reading, updating, and modifying data providers
(<a href="https://github.com/qorelanguage/qore/issues/4395">issue 4395</a>)
@subsection dataprovider_v1_2_3 DataProvider v1.3
- added @ref DataProvider::DataProviderTypeCache::listParentTypes() "DataProviderTypeCache::listParentTypes()" to
allow a list of parent types to be returned
(<a href="https://github.com/qorelanguage/qore/issues/4385">issue 4385</a>)
@subsection dataprovider_v1_2_2 DataProvider v1.2.2
- added support for starting a transaction with DataProviders that support transaction management
(<a href="https://github.com/qorelanguage/qore/issues/4346">issue 4346</a>)
@subsection dataprovider_v1_2_1 DataProvider v1.2.1
- return the \c base_type key in input type info in
@ref DataProvider::AbstractDataProviderType::getInputInfo() "getInputInfo"
(<a href="https://github.com/qorelanguage/qore/issues/4311">issue 4311</a>)
@subsection dataprovider_v1_2 DataProvider v1.2
- greatly improved dataprovider and type acquisition speed from clients requiring initialization from the environment
(<a href="https://github.com/qorelanguage/qore/issues/4305">issue 4305</a>)
@subsection dataprovider_v1_1 DataProvider v1.1
- the @ref DataProvider::DefaultRecordIterator class supports the \c limit search option
@subsection dataprovider_v1_0_6 DataProvider v1.0.6
- fixed a bug where the @ref data_type "data" type was not supported correctly as a data provider type
(<a href="https://github.com/qorelanguage/qore/issues/4232">issue 4232</a>)
@subsection dataprovider_v1_0_5 DataProvider v1.0.5
- fixed an issue where it was not possible for pipeline to flush any pending data or to perform reset or purge
operations when pipeline processing is complete; for this the
@ref DataProvider::AbstractDataProcessor::flush() "AbstractDataProcessor::flush()" and
@ref DataProvider::AbstractDataProcessor::flushImpl() "AbstractDataProcessor::flushImpl()" methods were
implemented
(<a href="https://github.com/qorelanguage/qore/issues/4107">issue 4107</a>)
@subsection dataprovider_v1_0_4 DataProvider v1.0.4
- fixed type-handling bugs handling data provider options
(<a href="https://github.com/qorelanguage/qore/issues/4062">issue 4062</a>)
@subsection dataprovider_v1_0_3 DataProvider v1.0.3
- fixed bugs in the default return value for
@ref DataProvider::AbstractDataProcessor::getExpectedType() "AbstractDataProcessor::getExpectedType()" and
@ref DataProvider::AbstractDataProcessor::getReturnType() "AbstractDataProcessor::getReturnType()"
(<a href="https://github.com/qorelanguage/qore/issues/4043">issue 4043</a>)
@subsection dataprovider_v1_0_2 DataProvider v1.0.2
- fixed a bug where @ref DataProvider::HashDataType "HashDataType" would not enforce fields or field types when
checking for type and value compatibility
(<a href="https://github.com/qorelanguage/qore/issues/4037">issue 4037</a>)
- added new %Qore base types to the data type hierarchy
- implemented the following classes:
- @ref DataProvider::AbstractDataProcessor "AbstractDataProcessor"
- @ref DataProvider::DataProviderBulkRecordIterator "DataProviderBulkRecordIterator"
- @ref DataProvider::DataProviderPipeline "DataProviderPipeline"\n
(<a href="https://github.com/qorelanguage/qore/issues/3876">issue 3876</a>)
- added \c DUPLICATE-RECORD exception documentation for
@ref DataProvider::AbstractDataProvider::createRecord() "AbstractDataProvider::createRecord()"
- updated to allow data provider type attributes to appear as children in the type hierarchy
(<a href="https://github.com/qorelanguage/qore/issues/4015">issue 4015</a>)
@subsection dataprovider_v1_0_1 DataProvider v1.0.1
- implemented callbacks to allow for dynamic elements of request-response data providers (such as URI paths) to be
resolved at runtime
(<a href="https://github.com/qorelanguage/qore/issues/3838">issue 3838</a>)
- @ref DataProvider::AbstractDataProviderType "AbstractDataProviderType" and
@ref DataProvider::AbstractDataField "AbstractDataField" classes made serializable
(<a href="https://github.com/qorelanguage/qore/issues/3809">issue 3809</a>)
- implemented the @ref DataProvider::DataProviderTypeCache "DataProviderTypeCache" class to encapsulate reusable
type caching logic
(<a href="https://github.com/qorelanguage/qore/issues/3810">issue 3810</a>)
@subsection dataprovider_v1_0 DataProvider v1.0
- initial release of the module
*/
#! contains all public definitions in the DataProvider module
public namespace DataProvider {
}