Record Class SingleTableConfig
- Record Components:
tableName- native (fully qualified) name of a tableidColumnName- native name of the id-column in that tabletableNature- characteristics of the tabletableFilters- optional list of filter columns to be added on each selection from this table, null means emptyargColumnMap- argument to column definition mappingautoMappingPolicy- optional policy for argNames not covered explicitly
- All Implemented Interfaces:
de.calamanari.adl.cnv.tps.ArgMetaInfoLookup, DataTableConfig, TableMetaInfo, Serializable
SingleTableConfig describes the mappings of argNames to columns of one particular table.
Hint: If any column is marked DataColumn.isAlwaysKnown() then the table will be automatically configured with
TableNature.containsAllIds()=true.
On sparse data:
We call it sparse data if the data of a table is irregular.
Example 1: data copied but not merged from multiple sources
+------+-------+-------+-------+---------+ | ID | COLOR | SHAPE | RX0 | RX1 | +------+-------+-------+-------+---------+ | 8231 | blue | rect | NULL | NULL | +------+-------+-------+-------+---------+ | 8231 | NULL | NULL | 1 | NULL | +------+-------+-------+-------+---------+ | 8231 | NULL | NULL | NULL | 1 | +------+-------+-------+-------+---------+ | 9555 | ... | ... | ... | ... | +------+-------+-------+-------+---------+
Interestingly, none of the columns in the example above is DataColumn.isMultiRow(), or in other words: none of the attributes is a collection
(ArgMetaInfo.isCollection()). The problem is that the data has not been merged. To get the full picture, data from several rows must be
considered.
Example 2: multi-row (collection) attribute with missing repetition
+------+-------+-------+--------+---------+ | ID | NAME | BRAND | TYPE | WEEKDAY | +------+-------+-------+--------+---------+ | 8231 | CROW | SKIRT | M365 | SUN | +------+-------+-------+--------+---------+ | 8231 | CROW | NULL | NULL | MON | +------+-------+-------+--------+---------+ | 8231 | CROW | NULL | NULL | WED | +------+-------+-------+--------+---------+ | 9555 | ... | ... | ... | ... | +------+-------+-------+--------+---------+
Here, WEEKDAY may contain multiple values (in multiple rows), but unfortunately, the values for some other fields have not been repeated since the first occurrence of the record 8231 on Sunday. Again, a query may have to consider multiple rows to get the full picture.
In general it is recommended to streamline the onboarding process to avoid any sparse data tables for performance reasons and to avoid logical
problems.
Sparse data makes all attributes multi-row and thus independent from each other. For example if you query
brand = foo AND product = bar with the two columns BRAND and PRODUCT side-by-side you would expect to include rows with both conditions
true for a single row. By marking the table as sparse or both columns as multi-row you lose this dependency. Consequently, the query would also match if
there are two rows, (BRAND:xyz, PRODUCT:bar) and (BRAND:foo, PRODUCT:hugo).
Note: For convenience reasons this class implements ArgMetaInfoLookup to play nicely with some core features.
Instances are deeply immutable.
- Author:
- Karl Eilebrecht
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSingleTableConfig(String tableName, String idColumnName, TableNature tableNature, List<FilterColumn> tableFilters, Map<String, ArgColumnAssignment> argColumnMap, AutoMappingPolicy autoMappingPolicy) Creates an instance of aSingleTableConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the meta information for all the tables in this configuration.Returns the value of theargColumnMaprecord component.Returns the value of theautoMappingPolicyrecord component.booleanfinal booleanIndicates whether some other object is "equal to" this one.Entry point for fluently setting up a table in the the physical data model and along with it the logical data model (mapped argNames)Entry point for setting up a table and for mapping it to existing argNamesfinal inthashCode()Returns a hash code value for this object.Returns the value of theidColumnNamerecord component.lookupAssignment(String argName, de.calamanari.adl.ProcessContext ctx) Determines the column assignment for the given argName.lookupTableMetaInfo(String argName, de.calamanari.adl.ProcessContext ctx) Returns the table meta infos for the column that is mapped to the given argNameintReturns the total number of tables in this configurationReturns the value of thetableFiltersrecord component.Returns the value of thetableNamerecord component.Returns the value of thetableNaturerecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from interface de.calamanari.adl.cnv.tps.ArgMetaInfoLookup
isAlwaysKnown, isCollection, lookup, typeOfMethods inherited from interface DataTableConfig
lookup, lookupColumn, lookupTableMetaInfoByTableName, numberOfTablesInvolved, primaryTable, tableMetaInfosInvolved, tablesInvolved, tablesThatContainAllIds
-
Constructor Details
-
SingleTableConfig
public SingleTableConfig(String tableName, String idColumnName, TableNature tableNature, List<FilterColumn> tableFilters, Map<String, ArgColumnAssignment> argColumnMap, AutoMappingPolicy autoMappingPolicy) Creates an instance of aSingleTableConfigrecord class.- Parameters:
tableName- the value for thetableNamerecord componentidColumnName- the value for theidColumnNamerecord componenttableNature- the value for thetableNaturerecord componenttableFilters- the value for thetableFiltersrecord componentargColumnMap- the value for theargColumnMaprecord componentautoMappingPolicy- the value for theautoMappingPolicyrecord component
-
-
Method Details
-
forTable
Entry point for fluently setting up a table in the the physical data model and along with it the logical data model (mapped argNames)This is more for testing convenience. The recommended way is first creating a logical data model with all the argNames and then calling
forTable(String, ArgMetaInfoLookup)to setup the table(s) and create a mapping.- Parameters:
tableName- physical table name- Returns:
- builder
-
forTable
public static ConfigBuilderInterfaces.SingleTableStep2 forTable(String tableName, de.calamanari.adl.cnv.tps.ArgMetaInfoLookup argMetaInfoLookup) Entry point for setting up a table and for mapping it to existing argNames- Parameters:
tableName-argMetaInfoLookup- (logical data model with all the argNames)- Returns:
- builder
-
lookupAssignment
Description copied from interface:DataTableConfigDetermines the column assignment for the given argName.- Specified by:
lookupAssignmentin interfaceDataTableConfig- Parameters:
argName-ctx-- Returns:
- the configured
ArgColumnAssignmentifArgMetaInfoLookup.contains(String)=true, otherwise throws exception
-
contains
- Specified by:
containsin interfacede.calamanari.adl.cnv.tps.ArgMetaInfoLookup
-
numberOfTables
public int numberOfTables()Description copied from interface:DataTableConfigReturns the total number of tables in this configuration- Specified by:
numberOfTablesin interfaceDataTableConfig- Returns:
- number of tables this config is based on, >=1
-
lookupTableMetaInfo
Description copied from interface:DataTableConfigReturns the table meta infos for the column that is mapped to the given argName- Specified by:
lookupTableMetaInfoin interfaceDataTableConfig- Parameters:
argName-ctx-- Returns:
- meta data
-
allTableMetaInfos
Description copied from interface:DataTableConfigReturns the meta information for all the tables in this configuration.Important: Although the order is not defined, best case the order in the list reflects the order of configuration.
In any case it must be stable and it should be deterministic because this is the order the default implementations of several other methods relies on. If the result is composed from an underlying set, then the list should be sorted before returning to avoid indeterministic behavior like flaky tests or unexplainable variations when generating queries.- Specified by:
allTableMetaInfosin interfaceDataTableConfig- Returns:
- all configured tables
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
tableName
Returns the value of thetableNamerecord component.- Specified by:
tableNamein interfaceTableMetaInfo- Returns:
- the value of the
tableNamerecord component
-
idColumnName
Returns the value of theidColumnNamerecord component.- Specified by:
idColumnNamein interfaceTableMetaInfo- Returns:
- the value of the
idColumnNamerecord component
-
tableNature
Returns the value of thetableNaturerecord component.- Specified by:
tableNaturein interfaceTableMetaInfo- Returns:
- the value of the
tableNaturerecord component
-
tableFilters
Returns the value of thetableFiltersrecord component.- Specified by:
tableFiltersin interfaceTableMetaInfo- Returns:
- the value of the
tableFiltersrecord component
-
argColumnMap
Returns the value of theargColumnMaprecord component.- Returns:
- the value of the
argColumnMaprecord component
-
autoMappingPolicy
Returns the value of theautoMappingPolicyrecord component.- Returns:
- the value of the
autoMappingPolicyrecord component
-