430 const ConstantConflictList = (
"name",
"struct",
"code",
"default");
433 const OptionKeys = ...;
437 const UserOptions = {
440 "desc":
"a flag to allow dots in input field names instead of interpreting them as field structure "
446 "desc":
"a flag to allow dots in input field names instead of interpreting them as field structure "
452 "desc":
"a flag to disable bulk operations when there is a hash of lists as input when calling "
457 "type":
"type-option-hash",
458 "desc":
"a hash of global type options to be used by applicable fields if they do not override the "
464 "desc":
"if true and if an output field has an input mapping but the input hash has no such value, "
465 "and the output field does not require a value, in this case, the output field is omitted "
466 "entirely; this option is useful when the mapper output is used for delta updates with variable "
467 "input, for example; this option cannot be used with bulk input",
472 "desc":
"the input provider search criteria",
477 "desc":
"the arguments for input providers using the request/response API",
482 "desc":
"any options to input providers using the request/response API",
487 "desc":
"a string indicating the input providers using the request/response API should "
488 "use the given error response message for the record format",
493 "desc":
"the input provider search options",
498 "desc":
"use any input data provider for type information only",
503 "desc":
"a hash that will be passed to any field handlers as the context argument",
508 "desc":
"a flag that indicates that duplicate records should be ignored when creating records with "
509 "an output data provider",
514 "desc":
"set output fields as nullable",
519 "desc":
"a flag to enable bulk operations with an output provider; this option only has an "
520 "effect when used with an output provider that supports bulk operations on output",
525 "desc":
"a flag to disable writing to the output provider while mapping; if this flag is set, the "
526 "output provider will only be used to set the output record type; this option only has an effect "
527 "when used with an output provider",
532 "desc":
"a flag to enable upserting instead of creating records with an output "
533 "data provider; this option only has an effect when used with an output provider",
538 "desc":
"any options to output providers using the request/response API",
543 "desc":
"use any output data provider for type information only",
548 "desc":
"defines key-value pairs lookups for the \"runtime\" field mapping key",
553 "desc":
"each hash key is the name of a global submapper and must have a hash value giving the "
554 "options for submapper as a value; requires the \"submapper_get\" option as well",
559 const ValidKeys = ...;
604 hash<auto> global_transform_opts = {} + {
605 "date.input_timezone": TimeZone::get(),
609 bool trunc_all = False;
616 bool allow_dot = False;
623 bool allow_output_dot = False;
626 *hash<string, AbstractDataField>
input;
677 bool output_nullable = False;
721 hash<auto> mapper_handler_context = {};
737 "hash":
"hash<auto>",
738 "*hash":
"*hash<auto>",
739 "list":
"list<auto>",
740 "*list":
"*list<auto>",
741 "softlist":
"softlist<auto>",
742 "*softlist":
"*softlist<auto>",
746 const DeprecatedGlobalTransformOptionMap = {
747 "encoding":
"string.encoding",
748 "empty_strings_to_nothing":
"string.empty_to_nothing",
749 "date_format":
"date.format",
750 "timezone":
"date.output_timezone",
751 "input_timezone":
"date.input_timezone",
752 "number_format":
"number.format",
756 const _Mapper_Thread_Key =
"_Mapper_Thread_Key";
795 static hash<string, AbstractDataField> getInputFromHash(hash<auto> input);
797 static hash<string, AbstractDataField> getOutputFromHash(hash<auto> output, *hash<auto> mapv, *hash<auto> global_options);
832 AbstractDataProviderType getOutputType(hash<auto> hdesc, *hash<auto> mapdesc);
837 static AbstractDataProviderType getOutputType(hash<auto> hdesc, *hash<auto> mapdesc, *hash<auto> global_options, *
bool has_default_value);
842 static hash<string, AbstractDataField> getInputFromHashIntern(hash<auto> input, *reference<bool> structured_input);
847 static hash<string, AbstractDataField> getOutputFromHashIntern(hash<auto> output, *hash<auto> mapv, *hash<auto> global_options, *reference<bool> structured_output);
852 checkInputOutputOption(hash<auto> opts,
string var, *hash<auto> mapv);
857 setInputProvider(hash<auto> opts);
862 *hash<string, AbstractDataField> getFields(
string pfx, AbstractDataProviderType type);
867 setOutputProvider(hash<auto> opts);
873 setup(hash<auto> mapv, *hash<auto> opts);
1166 list<hash<auto>>
mapAll(AbstractIterator recs);
1232 *hash<auto>
mapBulk(hash<auto> rec, *hash<auto> crec);
1308 nothing
mapFieldIntern(reference<hash<auto>> h,
string key, hash<auto> rec,
bool do_list,
int list_size);
1318 removeHashOutputKey(reference<auto> output, list<auto> path,
int offset);
1324 writeHashOutput(reference<auto> output,
auto value, list<auto> path,
int offset);
1358 auto mapFieldType(
string key, hash<auto> mapping, AbstractDataProviderType type,
auto value, hash<auto> rec,
auto v);
1411 static AbstractDataProviderType getInputType(*
string type);
1506 "string.max_size_chars": <DataProviderTypeOptionInfo>{
1508 "desc":
"the maximum size of strings in chars",
1510 "string.empty_to_nothing": <DataProviderTypeOptionInfo>{
1511 "type": Type::Boolean,
1512 "desc":
"if an empty string should be converted to no value",
1617 AbstractDataProviderRecordIterator
i;
abstract base class for hash iterator mappping classes based on a mapper object and an iterator input...
Definition: Mapper.qm.dox.h:1417
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:1423
describes a data type that accepts any value; stores "string.max_size_chars" as a type attribute for ...
Definition: Mapper.qm.dox.h:1500
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:1505
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:426
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:641
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:626
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
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:683
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:686
bool input_do_request
indicates that the request/response API should be used for mapper input
Definition: Mapper.qm.dox.h:638
hash< string, hash< auto > > runtime_keys_with_handler
subset of runtime_keys with handlers
Definition: Mapper.qm.dox.h:712
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:647
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:733
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:703
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
auto mapFieldType(string key, hash< auto > mapping, AbstractDataProviderType type, auto value, hash< auto > rec, auto v)
performs type handling
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:653
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:668
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:632
*hash< string, AbstractDataField > output
an optional description of the output data structure
Definition: Mapper.qm.dox.h:656
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:659
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:697
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:595
*code submapper_get
an optional callback for retrieving a nested mapper; sig: (string name, *hash<auto> opts) {}
Definition: Mapper.qm.dox.h:598
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:580
*code input_log
an optional input data logging callback; must accept a hash giving the input data hash
Definition: Mapper.qm.dox.h:592
*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:583
*AbstractDataProviderBulkOperation output_provider_bulk_operation
bulk output object for an output data provider
Definition: Mapper.qm.dox.h:662
bool output_provider_passive
if the output provide should only be used to set the output type
Definition: Mapper.qm.dox.h:665
hash< string, hash< MapperRuntimeKeyInfo > > runtime_keys
map of field keys provided by the "runtime_keys" option
Definition: Mapper.qm.dox.h:709
*hash< auto > input_search_options
search options for the input provider
Definition: Mapper.qm.dox.h:635
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:730
*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:586
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:724
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:674
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:715
hash< string, bool > valid_keys
hash of valid keys
Definition: Mapper.qm.dox.h:718
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:727
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:644
*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:706
*code template_subst
an optional callback for substituting templated values
Definition: Mapper.qm.dox.h:601
*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:577
*code info_log
an optional info logging callback; must accept a sprintf()-style format specifier and optional argume...
Definition: Mapper.qm.dox.h:589
*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:694
bool output_do_request
indicates that the request/response API should be used for mapper output
Definition: Mapper.qm.dox.h:671
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:629
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:680
bool ignore_missing_input
supresses the output field if the input field is missing and the output is optional
Definition: Mapper.qm.dox.h:650
*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:700
provides a hash iterator based on a mapper object and an iterator input source
Definition: Mapper.qm.dox.h:1455
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:1461
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:1609
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:1617
Mapper mapper
the mapper
Definition: Mapper.qm.dox.h:1614
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:1574
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:417
string type
the option value type
Definition: Mapper.qm.dox.h:419
string desc
the description of the option
Definition: Mapper.qm.dox.h:422