Qore Mapper Module Reference 1.6.1
Loading...
Searching...
No Matches
Mapper.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* Mapper.qm Copyright 2014 - 2023 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// minimum required Qore version
26
27// require type definitions everywhere
28
29// enable all warnings
30
31// do not use "$" for vars
32
33// common definitions
34
35// supports using the DataProvider module to describe input and output records
36
37
409namespace Mapper {
411public hashdecl MapperOptionInfo {
413 string type;
414
416 string desc;
417};
418
421
422public:
424 const ConstantConflictList = ("name", "struct", "code", "default");
425
427 const OptionKeys = ...;
428
429
431 const UserOptions = {
432 "allow_dot": <MapperOptionInfo>{
433 "type": "bool",
434 "desc": "a flag to allow dots in input field names instead of interpreting them as field structure "
435 "separators",
436 },
437
438 "allow_output_dot": <MapperOptionInfo>{
439 "type": "bool",
440 "desc": "a flag to allow dots in input field names instead of interpreting them as field structure "
441 "separators",
442 },
443
444 "disable_bulk": <MapperOptionInfo>{
445 "type": "bool",
446 "desc": "a flag to disable bulk operations when there is a hash of lists as input when calling "
447 "mapAuto",
448 },
449
450 "global_type_options": <MapperOptionInfo>{
451 "type": "type-option-hash",
452 "desc": "a hash of global type options to be used by applicable fields if they do not override the "
453 "option",
454 },
455
456 "ignore_missing_input": <MapperOptionInfo>{
457 "type": "bool",
458 "desc": "if true and if an output field has an input mapping but the input hash has no such value, "
459 "and the output field does not require a value, in this case, the output field is omitted "
460 "entirely; this option is useful when the mapper output is used for delta updates with variable "
461 "input, for example; this option cannot be used with bulk input",
462 },
463
464 "input_provider_search": <MapperOptionInfo>{
465 "type": "hash",
466 "desc": "the input provider search criteria",
467 },
468
469 "input_request": <MapperOptionInfo>{
470 "type": "any",
471 "desc": "the arguments for input providers using the request/response API",
472 },
473
474 "input_request_options": <MapperOptionInfo>{
475 "type": "hash",
476 "desc": "any options to input providers using the request/response API",
477 },
478
479 "input_response_error": <MapperOptionInfo>{
480 "type": "string",
481 "desc": "a string indicating the input providers using the request/response API should "
482 "use the given error response message for the record format",
483 },
484
485 "input_search_options": <MapperOptionInfo>{
486 "type": "hash",
487 "desc": "the input provider search options",
488 },
489
490 "input_suppress_data_provider": <MapperOptionInfo>{
491 "type": "bool",
492 "desc": "use any input data provider for type information only",
493 },
494
495 "mapper_handler_context": <MapperOptionInfo>{
496 "type": "hash",
497 "desc": "a hash that will be passed to any field handlers as the context argument",
498 },
499
500 "output_create_ignore_duplicates": <MapperOptionInfo>{
501 "type": "bool",
502 "desc": "a flag that indicates that duplicate records should be ignored when creating records with "
503 "an output data provider",
504 },
505
506 "output_nullable": <MapperOptionInfo>{
507 "type": "bool",
508 "desc": "set output fields as nullable",
509 },
510
511 "output_provider_bulk": <MapperOptionInfo>{
512 "type": "bool",
513 "desc": "a flag to enable bulk operations with an output provider; this option only has an "
514 "effect when used with an output provider that supports bulk operations on output",
515 },
516
517 "output_provider_passive": <MapperOptionInfo>{
518 "type": "bool",
519 "desc": "a flag to disable writing to the output provider while mapping; if this flag is set, the "
520 "output provider will only be used to set the output record type; this option only has an effect "
521 "when used with an output provider",
522 },
523
524 "output_provider_upsert": <MapperOptionInfo>{
525 "type": "bool",
526 "desc": "a flag to enable upserting instead of creating records with an output "
527 "data provider; this option only has an effect when used with an output provider",
528 },
529
530 "output_request_options": <MapperOptionInfo>{
531 "type": "hash",
532 "desc": "any options to output providers using the request/response API",
533 },
534
535 "output_suppress_data_provider": <MapperOptionInfo>{
536 "type": "bool",
537 "desc": "use any output data provider for type information only",
538 },
539
540 "runtime": <MapperOptionInfo>{
541 "type": "hash",
542 "desc": "defines key-value pairs lookups for the \"runtime\" field mapping key",
543 },
544
545 "submappers": <MapperOptionInfo>{
546 "type": "hash",
547 "desc": "each hash key is the name of a global submapper and must have a hash value giving the "
548 "options for submapper as a value; requires the \"submapper_get\" option as well",
549 },
550 };
551
553 const ValidKeys = ...;
554
555
557 const OutputKeys = {
558 "desc": True,
559 "mand": True,
560 "maxlen": True,
561 "type": True,
562 };
563
565 static Type recordType("hash<string, AbstractDataField>");
566
567protected:
569
571 hash mapc;
572
574 hash<auto> mapd;
575
577 hash<auto> mapo;
578
580 *string name;
581
583 *code info_log;
584
587
590
593
596
598 hash<auto> global_transform_opts = {} + {
599 "date.input_timezone": TimeZone::get(),
600 };
601
603 bool trunc_all = False;
604
606
610 bool allow_dot = False;
611
613
617 bool allow_output_dot = False;
618
620 *hash<string, AbstractDataField> input;
621
623 *AbstractDataProvider input_provider;
624
627
630
633
636
639
642
645
648
650 *hash<string, AbstractDataField> output;
651
653 *AbstractDataProvider output_provider;
654
656 *AbstractDataProviderBulkOperation output_provider_bulk_operation;
657
660
663
666
669
671 bool output_nullable = False;
672
675
678
681
683 int count = 0;
684
686
688 *hash<auto> m_runtime;
689
691 hash<auto> identh;
692
694 *list<auto> identl;
695
697 hash<auto> consth;
698
700 hash<auto> rconsth;
701
703 hash<string, hash<MapperRuntimeKeyInfo>> runtime_keys;
704
706 hash<string, hash<auto>> runtime_keys_with_handler;
707
709 hash<string, hash<MapperRuntimeKeyInfo>> runtime_independent_keys;
710
712 hash<string, bool> valid_keys;
713
715 hash<auto> mapper_handler_context = {};
716
719
721 *hash<auto> global_submappers;
722
725
728
730 const TypeMap = {
731 "hash": "hash<auto>",
732 "*hash": "*hash<auto>",
733 "list": "list<auto>",
734 "*list": "*list<auto>",
735 "softlist": "softlist<auto>",
736 "*softlist": "*softlist<auto>",
737 };
738
740 const DeprecatedGlobalTransformOptionMap = {
741 "encoding": "string.encoding",
742 "empty_strings_to_nothing": "string.empty_to_nothing",
743 "date_format": "date.format",
744 "timezone": "date.output_timezone",
745 "input_timezone": "date.input_timezone",
746 "number_format": "number.format",
747 };
748
750 const _Mapper_Thread_Key = "_Mapper_Thread_Key";
751
752public:
753
755
780 constructor(hash<auto> mapv, *hash<auto> opts);
781
782
784protected:
786public:
787
788
789 static hash<string, AbstractDataField> getInputFromHash(hash<auto> input);
790
791 static hash<string, AbstractDataField> getOutputFromHash(hash<auto> output, *hash<auto> mapv, *hash<auto> global_options);
792
794
800protected:
801 submitImpl(code enqueue, auto _data);
802public:
803
804
806
808protected:
810public:
811
812
814protected:
815 *AbstractDataProviderType getExpectedTypeImpl();
816public:
817
818
820protected:
821 *AbstractDataProviderType getReturnTypeImpl();
822public:
823
824
825protected:
826 AbstractDataProviderType getOutputType(hash<auto> hdesc, *hash<auto> mapdesc);
827public:
828
829
830protected:
831 static AbstractDataProviderType getOutputType(hash<auto> hdesc, *hash<auto> mapdesc, *hash<auto> global_options, *bool has_default_value);
832public:
833
834
835 private static hash<string, AbstractDataField> getInputFromHashIntern(hash<auto> input,
836 *reference<bool> structured_input) {
837 HashDataType input_data();
838 foreach hash<auto> h in (input.pairIterator());
839
840 return input_data.getFields();
841 }
842
843 private static hash<string, AbstractDataField> getOutputFromHashIntern(hash<auto> output, *hash<auto> mapv,
844 *hash<auto> global_options, *reference<bool> structured_output) {
845 HashDataType output_data();
846 foreach hash<auto> h in (output.pairIterator());
847
848 return output_data.getFields();
849 }
850
851protected:
852 checkInputOutputOption(hash<auto> opts, string var, *hash<auto> mapv);
853public:
854
855
856protected:
857 setInputProvider(hash<auto> opts);
858public:
859
860
861private:
862 *hash<string, AbstractDataField> getFields(string pfx, AbstractDataProviderType type);
863public:
864
865
866protected:
867 setOutputProvider(hash<auto> opts);
868public:
869
870
872protected:
873 setup(hash<auto> mapv, *hash<auto> opts);
874public:
875
876
878protected:
880public:
881
882
884protected:
885 convertToHash(int t, string k, reference<auto> fh);
886public:
887
888
890protected:
891 processStructuredInputField(string k, string name, reference<list<string>> struct);
892public:
893
894
896protected:
897 *AbstractDataField processStructuredOutputField(string k, reference<hash<auto>> fh);
898public:
899
900
902protected:
903 checkInputField(string k, string name);
904public:
905
906
908 static list<string> splitDottedFields(string k);
909
911
914protected:
915 checkMapField(string k, reference<auto> fh);
916public:
917
918
920protected:
922public:
923
924
926
944 setRuntime(string key, auto value);
945
946
948
966 setRuntime(hash<auto> runtime);
967
968
970
988 replaceRuntime(*hash<auto> runtime);
989
990
992
1003 auto getRuntime(string key);
1004
1005
1007 string getFieldName(string fname);
1008
1009
1011
1013 hash<string, bool> validKeys();
1014
1015
1017
1019 hash<auto> optionKeys();
1020
1021
1023 hash<string, hash<MapperOptionInfo>> getUserOptions();
1024
1025
1027 *AbstractDataProvider getInputProvider();
1028
1029
1031 *AbstractDataProvider getOutputProvider();
1032
1033
1035 *hash<string, AbstractDataField> getInputRecord();
1036
1037
1039 *hash<string, AbstractDataField> getOutputRecord();
1040
1041
1043
1046
1047
1049
1057
1058
1060
1067
1068
1070
1077
1078
1080
1089
1090
1092
1101
1102
1104
1111
1112
1114
1119 *softlist<hash<auto>> mapAutoInput();
1120
1121
1123
1125private:
1126 AbstractDataProviderRecordIterator getInputProviderRecordIterator();
1127public:
1128
1129
1131
1140 list<hash<auto>> mapAll(list<auto> recs);
1141
1142
1144
1153 list<hash<auto>> mapAll(hash<auto> recs);
1154
1155
1157
1166 list<hash<auto>> mapAll(AbstractIterator recs);
1167
1168
1170
1182 hash<auto> mapData(hash<auto> rec);
1183
1184
1186
1202 auto mapAuto(auto recs);
1203
1204
1206
1232 *hash<auto> mapBulk(hash<auto> rec, *hash<auto> crec);
1233
1234
1236 static *hash<auto> getMapperThreadContext();
1237
1239
1251protected:
1252 hash<auto> mapDataIntern(hash<auto> rec, *bool do_log_output);
1253public:
1254
1255
1257protected:
1258 *hash<auto> doCreateRecordIntern(hash<auto> rec);
1259public:
1260
1261
1263protected:
1264 static *hash<auto> swapMapperThreadContext(*hash<auto> new_ctx);
1265public:
1266
1267
1275protected:
1276 *int getRecListSize(hash<auto> rec);
1277public:
1278
1279
1281
1307protected:
1308 nothing mapFieldIntern(reference<hash<auto>> h, string key, hash<auto> rec, bool do_list, int list_size);
1309public:
1310
1311
1313 hash<auto> getOptionsFromTemplate(hash<auto> opts, hash<auto> input_rec, *hash<auto> output_rec);
1314
1315
1316 // recursively remove a key from the output
1317protected:
1318 removeHashOutputKey(reference<auto> output, list<auto> path, int offset);
1319public:
1320
1321
1322 // recursively write output hash
1323protected:
1324 writeHashOutput(reference<auto> output, auto value, list<auto> path, int offset);
1325public:
1326
1327
1329protected:
1330 string truncateField(string k, string val, int ix, int sze, int maxlen);
1331public:
1332
1333
1335protected:
1336 fieldLengthError(string k, string val, int ix, int sze, int maxlen, hash<auto> rc);
1337public:
1338
1339
1341 logOutput(hash<auto> h);
1342
1343
1345
1348
1349
1351
1354
1355
1357 private auto mapFieldType(string key, hash<auto> mapping, AbstractDataProviderType type, auto value,
1358 hash<auto> rec, auto v) {
1359 try {
1360 return type.acceptsValue(value);
1361 } catch (hash<ExceptionInfo> ex) {
1362 rethrow ex.err, sprintf("error in field %y with value %y; %s; rec: %y; output value derived from %s (v: %y)", key,
1363 value, ex.desc, rec, getMappingDescription(key, mapping), v), ex.arg;
1364 }
1365 }
1366
1368protected:
1369 string getMappingDescription(string key, hash<auto> mapping);
1370public:
1371
1372
1374protected:
1376public:
1377
1378
1380
1382protected:
1384public:
1385
1386
1388
1390protected:
1392public:
1393
1394
1396
1398protected:
1399 error(string fmt);
1400public:
1401
1402
1404protected:
1405 error2(string ex, string fmt);
1406public:
1407
1408
1410protected:
1411 auto mapSubclass(hash<auto> m, auto v);
1412public:
1413
1414
1415protected:
1416 static AbstractDataProviderType getInputType(*string type);
1417public:
1418
1419};
1420
1423
1424public:
1425
1426protected:
1429
1430public:
1431
1433
1436
1437
1439 bool next();
1440
1441
1443 bool valid();
1444
1445
1447 bool hasBulk();
1448
1449
1451
1455 list<hash> mapBulk(int size);
1456
1457};
1458
1461
1462public:
1463
1464protected:
1467
1468public:
1469
1471
1477 constructor(Qore::AbstractIterator i, hash<auto> mapv, *hash<auto> opts) ;
1478
1479
1481
1485
1486
1488 hash<auto> getValue();
1489
1490
1492
1495
1496
1498
1501
1502};
1503
1505class AnythingDataType : public AbstractDataProviderType {
1506
1507public:
1508protected:
1511 "string.max_size_chars": <DataProviderTypeOptionInfo>{
1512 "type": Type::Int,
1513 "desc": "the maximum size of strings in chars",
1514 },
1515 "string.empty_to_nothing": <DataProviderTypeOptionInfo>{
1516 "type": Type::Boolean,
1517 "desc": "if an empty string should be converted to no value",
1518 },
1519 };
1520
1521public:
1522
1524 constructor(*hash<auto> options) ;
1525
1526
1528 string getName();
1529
1530
1532 string getDesc();
1533
1534
1536 bool isAssignableFrom(AbstractDataProviderType t);
1537
1538
1540 bool isAssignableFrom(Type t);
1541
1542
1545
1546
1548 *AbstractDataProviderType getElementType();
1549
1550
1552
1558 auto acceptsValue(auto value);
1559
1560
1562 *hash<string, AbstractDataField> getFields();
1563
1564
1566 *hash<string, hash<DataProviderTypeOptionInfo>> getSupportedOptions();
1567
1568
1570 hash<string, bool> getAcceptTypeHash();
1571
1572
1574 hash<string, bool> getReturnTypeHash();
1575
1576};
1577
1580
1581public:
1583 constructor(*hash<auto> options) ;
1584
1585
1587 string getName();
1588
1589
1591 bool isAssignableFrom(AbstractDataProviderType t);
1592
1593
1595 bool isAssignableFrom(Type t);
1596
1597
1600
1601
1603
1609 auto acceptsValue(auto value);
1610
1611};
1612
1614class MapperOutputRecordIterator : public AbstractDataProviderRecordIterator {
1615
1616public:
1617protected:
1620
1622 AbstractDataProviderRecordIterator i;
1623
1624public:
1625
1627 constructor(Mapper mapper, AbstractDataProvider input, *hash<auto> where_cond, *hash<auto> search_options);
1628
1629
1631 bool next();
1632
1633
1635 hash<auto> getValue();
1636
1637
1639 bool valid();
1640
1641};
1642};
abstract base class for hash iterator mappping classes based on a mapper object and an iterator input...
Definition: Mapper.qm.dox.h:1422
list< hash > mapBulk(int size)
performs bulk mapping; if the iterator does not support bulk mapping then it is simulated in this met...
bool next()
Moves the current position of the iterator to the next element; returns False if there are no more el...
bool valid()
returns True if the iterator is currently pointing at a valid element, False if not
constructor(Qore::AbstractIterator iter)
creates the iterator from the arguments passed
bool hasBulk()
returns True if the iterator supports bulk mode; this method returns False (the default)
Qore::AbstractIterator i
input iterator; AbstractIterator::getValue() must return a hash
Definition: Mapper.qm.dox.h:1428
describes a data type that accepts any value; stores "string.max_size_chars" as a type attribute for ...
Definition: Mapper.qm.dox.h:1505
string getDesc()
Returns the description.
bool isAssignableFrom(Type t)
returns True if this type can be assigned from values of the argument type
hash< string, bool > getAcceptTypeHash()
returns a hash of base types accepted by this type
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions()
returns supported options
bool isAssignableFrom(AbstractDataProviderType t)
returns True if this type can be assigned from values of the argument type
hash< string, bool > getReturnTypeHash()
returns a hash of base types returned by this type
constructor(*hash< auto > options)
creates the object
const SupportedOptions
supports a max_size_chars option for strings; to be enforced externally
Definition: Mapper.qm.dox.h:1510
auto acceptsValue(auto value)
returns the value if the value can be assigned to the type
*Type getValueType()
returns the base type for the type, if any
*AbstractDataProviderType getElementType()
returns the subtype (for lists or hashes) if there is only one
*hash< string, AbstractDataField > getFields()
returns the fields of the data structure; if any
string getName()
returns the type name
this class is a base class for mapping data; see Mapper Examples for usage examples
Definition: Mapper.qm.dox.h:420
checkOutputBulkOperation()
raises an error if no output provider is present
constructor()
private constructor for subclasses
auto input_request
the argument for the request/response API for the input provider
Definition: Mapper.qm.dox.h:635
fieldLengthError(string k, string val, int ix, int sze, int maxlen, hash< auto > rc)
called when a field exceeds its maximum length when processing hashes of lists
*hash< string, AbstractDataField > input
an optional description of possible input hash keys
Definition: Mapper.qm.dox.h:620
checkMapField(string k, reference< auto > fh)
perform per-field pre-processing on the passed map in the constructor
string getFieldName(string fname)
returns a descriptive name of the given field if possible, otherwise returns the field name itself
static *hash< auto > getMapperThreadContext()
Get mapper thread context.
checkTimezoneOption(string rn)
verifies a timezone constructor option
private auto mapFieldType(string key, hash< auto > mapping, AbstractDataProviderType type, auto value, hash< auto > rec, auto v)
performs type handling
Definition: Mapper.qm.dox.h:1357
hash< auto > mapDataIntern(hash< auto > rec, *bool do_log_output)
processes the input record and returns a hash of the mapped values where the keys in the hash returne...
*hash< string, AbstractDataField > getOutputRecord()
returns the value of the "output" option
bool structured_output
flag if the field descriptions were provided to the constructor
Definition: Mapper.qm.dox.h:677
bool output_create_ignore_duplicates
flag indicating that duplicate records should be ignored when creating records with an output mapper
Definition: Mapper.qm.dox.h:680
bool input_do_request
indicates that the request/response API should be used for mapper input
Definition: Mapper.qm.dox.h:632
hash< string, hash< auto > > runtime_keys_with_handler
subset of runtime_keys with handlers
Definition: Mapper.qm.dox.h:706
bool input_request_search
a boolean flag that indicates that an input provider that supports both the record API and the reques...
Definition: Mapper.qm.dox.h:641
logOutput(hash< auto > h)
calls the output logging closure or call reference (if any) to log the output record
error(string fmt)
throws a MAP-ERROR exception; prepends the map name to the description if known
discardOutput()
Discards any buffered data in the output data provider in a bulk operation.
bool output_suppress_data_provider
ignore any output data provider; use for type info only
Definition: Mapper.qm.dox.h:727
list< hash< auto > > mapAll(hash< auto > recs)
maps all input records and returns the mapped data as a list of output records
hash< auto > consth
map of constant fields
Definition: Mapper.qm.dox.h:697
hash< auto > optionKeys()
returns a list of valid constructor options for this class (can be overridden in subclasses)
*AbstractDataField processStructuredOutputField(string k, reference< hash< auto > > fh)
Raises an error if invalid fields in structured output data are declared; sets "fh".
convertToHash(int t, string k, reference< auto > fh)
convert a field definition to a hash if possible
processStructuredInputField(string k, string name, reference< list< string > > struct)
raises an error if invalid fields in structured input data are declared; sets "struct"
checkInputProvider()
raises an error if no input provider is present
hash< auto > getOptionsFromTemplate(hash< auto > opts, hash< auto > input_rec, *hash< auto > output_rec)
Returns options from a template hash.
bool disable_bulk
disable bulk operations when there is a hash of lists as input when calling mapAuto
Definition: Mapper.qm.dox.h:647
error2(string ex, string fmt)
throws the given exception; prepends the map name to the description if known
bool output_provider_upsert
if the upsert operations should be used on the output provider
Definition: Mapper.qm.dox.h:662
rollback()
Rolls back data written to the output data provider.
*hash< auto > input_provider_search
search conditions for the input provider
Definition: Mapper.qm.dox.h:626
*hash< string, AbstractDataField > output
an optional description of the output data structure
Definition: Mapper.qm.dox.h:650
MapperOutputRecordIterator getOutputIterator()
returns an output record iterator that produces mapped data from the input data provider
bool supportsBulkApiImpl()
Returns True if the record processor supports bulk operation.
static list< string > splitDottedFields(string k)
Splits a dotted field and replaces escaped (.) dots with plain dots (.)
*AbstractDataProvider output_provider
the optional output data provider
Definition: Mapper.qm.dox.h:653
checkInputField(string k, string name)
raises an error if an invalid input field name is declared; only call this if "input" is defined
flushOutput()
Flushes any remaining data to the output data provider in a bulk operation.
auto getRuntime(string key)
get current runtime option value for a key
runAutonomous()
Runs the input and output mappers with data providers on each end autonomously.
*AbstractDataProviderType getReturnTypeImpl()
Returns the type of data that will be returned, if available.
replaceRuntime(*hash< auto > runtime)
replaces runtime options
hash< auto > identh
map of fields to be mapped 1:1 input -> output
Definition: Mapper.qm.dox.h:691
static *hash< auto > swapMapperThreadContext(*hash< auto > new_ctx)
Swap the mapper thread context.
*code output_log
an optional output data logging callback; must accept a hash giving the output data hash
Definition: Mapper.qm.dox.h:589
*code submapper_get
an optional callback for retrieving a nested mapper; sig: (string name, *hash<auto> opts) {}
Definition: Mapper.qm.dox.h:592
AbstractDataProviderRecordIterator getInputProviderRecordIterator()
returns a record iterator for an input provider
hash< auto > mapd
the hash with a subset of the mappings used dynamically
Definition: Mapper.qm.dox.h:574
*code input_log
an optional input data logging callback; must accept a hash giving the input data hash
Definition: Mapper.qm.dox.h:586
*softlist< hash< auto > > mapAutoInput()
Runs the input data provider through the mapper and returns the output.
*int getRecListSize(hash< auto > rec)
*AbstractDataProvider getOutputProvider()
returns the output provider
setRuntime(hash< auto > runtime)
adds runtime options to the current runtime option hash
static Type recordType("hash<string, AbstractDataField>")
the input and output record type
hash< auto > mapData(hash< auto > rec)
processes the input record and returns a hash of the mapped values where the keys in the hash returne...
int getCount()
returns the internal record count
hash< auto > mapo
the hash of output records for key order
Definition: Mapper.qm.dox.h:577
*AbstractDataProviderBulkOperation output_provider_bulk_operation
bulk output object for an output data provider
Definition: Mapper.qm.dox.h:656
bool output_provider_passive
if the output provide should only be used to set the output type
Definition: Mapper.qm.dox.h:659
hash< string, hash< MapperRuntimeKeyInfo > > runtime_keys
map of field keys provided by the "runtime_keys" option
Definition: Mapper.qm.dox.h:703
*hash< auto > input_search_options
search options for the input provider
Definition: Mapper.qm.dox.h:629
nothing mapFieldIntern(reference< hash< auto > > h, string key, hash< auto > rec, bool do_list, int list_size)
maps a single field to the target
bool input_suppress_data_provider
ignore any input data provider; use for type info only
Definition: Mapper.qm.dox.h:724
*hash< string, AbstractDataField > getInputRecord()
returns the value of the "input" option
*string name
the optional name for the object (for example a table name); will be prepended to field names in erro...
Definition: Mapper.qm.dox.h:580
checkOutputProvider()
raises an error if no output provider is present
*hash< auto > mapper_thread_context
mapper static thread context hash
Definition: Mapper.qm.dox.h:718
hash< string, hash< MapperOptionInfo > > getUserOptions()
returns mapper options useful for users
*hash< auto > output_request_options
options for the request when using the request/response API for the output provider
Definition: Mapper.qm.dox.h:668
hash< string, hash< MapperRuntimeKeyInfo > > runtime_independent_keys
hash of runtime keys that provide independent mappings (where there is no "requires_role" = "value")
Definition: Mapper.qm.dox.h:709
hash< string, bool > valid_keys
hash of valid keys
Definition: Mapper.qm.dox.h:712
auto mapSubclass(hash< auto > m, auto v)
to be overridden as necessary in subclasses
*hash< auto > global_submappers
global submapper hash
Definition: Mapper.qm.dox.h:721
string truncateField(string k, string val, int ix, int sze, int maxlen)
called to truncate fields when processing hashes of lists
*hash< auto > input_request_options
options for the request when using the request/response API for the input provider
Definition: Mapper.qm.dox.h:638
*hash< auto > doCreateRecordIntern(hash< auto > rec)
Creates a record with the output data provider.
submitImpl(code enqueue, auto _data)
Submits the data for processing by the mapper.
hash< auto > rconsth
map of constant runtime fields
Definition: Mapper.qm.dox.h:700
*code template_subst
an optional callback for substituting templated values
Definition: Mapper.qm.dox.h:595
*AbstractDataProvider getInputProvider()
returns the input provider
auto mapAuto(auto recs)
maps all input record(s) automatically and returns the mapped data
setNullableOutput()
sets all fields in the output record as nullable
hash mapc
the hash providing output field names and mappings
Definition: Mapper.qm.dox.h:571
*code info_log
an optional info logging callback; must accept a sprintf()-style format specifier and optional argume...
Definition: Mapper.qm.dox.h:583
*AbstractDataProviderType getExpectedTypeImpl()
Returns the expected type of data to be submitted, if available.
list< hash< auto > > mapAll(list< auto > recs)
maps all input records and returns the mapped data as a list of output records
setup(hash< auto > mapv, *hash< auto > opts)
sets up the mapper object before checking the mapper hash
checkMap()
verifies the input map in the constructor
commit()
Commits data written to the output data provider if the output data provider supports transaction man...
*hash< auto > m_runtime
current runtime values
Definition: Mapper.qm.dox.h:688
bool output_do_request
indicates that the request/response API should be used for mapper output
Definition: Mapper.qm.dox.h:665
resetCount()
resets the internal record count
setRuntime(string key, auto value)
set the runtime option with "key" to value "value"
string getMappingDescription(string key, hash< auto > mapping)
returns a test description for the input mapping
hash< string, bool > validKeys()
returns a list of valid field keys for this class (can be overridden in subclasses)
constructor(hash< auto > mapv, *hash< auto > opts)
builds the object based on a hash providing field mappings, data constraints, and optionally custom m...
*AbstractDataProvider input_provider
the optional input data provider
Definition: Mapper.qm.dox.h:623
list< hash< auto > > mapAll(AbstractIterator recs)
maps all input records and returns the mapped data as a list of output records
bool structured_input
flag if the field descriptions were provided to the constructor
Definition: Mapper.qm.dox.h:674
bool ignore_missing_input
supresses the output field if the input field is missing and the output is optional
Definition: Mapper.qm.dox.h:644
*hash< auto > mapBulk(hash< auto > rec, *hash< auto > crec)
maps a set of records in hash of lists format; returns mapped data in a hash of lists format
*list< auto > identl
list of fields to be mapped 1:1 input -> output
Definition: Mapper.qm.dox.h:694
provides a hash iterator based on a mapper object and an iterator input source
Definition: Mapper.qm.dox.h:1460
constructor(Qore::AbstractIterator i, Mapper::Mapper mapv)
creates the iterator from the arguments passed
constructor(Qore::AbstractIterator i, hash< auto > mapv, *hash< auto > opts)
creates the iterator from the arguments passed
resetCount()
resets the internal record count
Mapper::Mapper mapc
data mapper
Definition: Mapper.qm.dox.h:1466
int getCount()
returns the internal record count
hash< auto > getValue()
returns the current row transformed with the mapper
Output record iterator for Mapper objects with an input data provider.
Definition: Mapper.qm.dox.h:1614
bool valid()
Returns True if the iterator is currently pointing at a valid element, False if not.
constructor(Mapper mapper, AbstractDataProvider input, *hash< auto > where_cond, *hash< auto > search_options)
Creates the object from the arguments.
AbstractDataProviderRecordIterator i
the input data provider
Definition: Mapper.qm.dox.h:1622
Mapper mapper
the mapper
Definition: Mapper.qm.dox.h:1619
bool next()
Moves the current position to the next element; returns False if there are no more elements.
hash< auto > getValue()
Returns the mapped value of the current input record.
describes a data type that accepts any value except NOTHING; stores "string.max_size_chars" as a type...
Definition: Mapper.qm.dox.h:1579
auto acceptsValue(auto value)
returns the value if the value can be assigned to the type
*Type getValueType()
returns the base type for the type, if any
bool isAssignableFrom(Type t)
returns True if this type can be assigned from values of the argument type
bool isAssignableFrom(AbstractDataProviderType t)
returns True if this type can be assigned from values of the argument type
string getName()
returns the type name
constructor(*hash< auto > options)
creates the object
the Mapper namespace contains all the definitions in the Mapper module
describes type options
Definition: Mapper.qm.dox.h:411
string type
the option value type
Definition: Mapper.qm.dox.h:413
string desc
the description of the option
Definition: Mapper.qm.dox.h:416