'Initialize field data and effort estimates for representation
Field data: allow representation per unique value (rather than
record by record), together with bulk-represent this
can reduce the total lookup effort per field to a
single query
Effort estimates: if no bulk-represent is available for a
list:reference, then a lookup per unique value
is only faster if the number of unique values
is significantly lower than the number of
extracted rows (and the number of values per
row), otherwise a per-row lookup is more
efficient.
E.g. 5 rows with 2 values each,
10 unique values in total
=> row-by-row lookup more efficient
(5 queries vs 10 queries)
but: 5 rows with 2 values each,
2 unique values in total
=> value-by-value lookup is faster
(5 queries vs 2 queries)
However: 15 rows with 15 values each,
20 unique values in total
=> value-by-value lookup faster
(15 queries Ã¡ 15 values vs.
20 queries Ã¡ 1 value)!
The required effort is estimated
during the data extraction, and then used to
determine the lookup strategy for the
representation.
@param rfields: the fields to extract ([S3ResourceField])'

def init_field_data(self, rfields):

    table = self.resource.table
    tablename = table._tablename
    pkey = str(table._id)
    field_data = {pkey: ({}, {}, False, False, False, False)}
    effort = {pkey: 0}
    for dfield in rfields:
        colname = dfield.colname
        effort[colname] = 0
        ftype = dfield.ftype[:4]
        field_data[colname] = ({}, {}, (dfield.tname != tablename), (ftype == 'list'), dfield.virtual, (ftype == 'json'))
    self.field_data = field_data
    self.effort = effort
    return
