Lookup Functions
For higher level overview check Lookup tables.
index, index_range, index_all, get_<type>
(since EVL 2.0)
To avoid running lookup function several times to return different fields for given ‘key_value(s)’ use ‘index’ functions, which return only an index to the whole record found in a lookup.
Function ‘index_all’ return all occurrences as a vector.
Functions ‘get_<type>’ then return particular field value for given index.
index(key_value(s))
to lookup by given ‘key_value(s)’ and return an index of an occurrence. It doesn’t care about the order of an occurrence, simply return that one which reach the first. Use better only when sure there is only one such value in a lookup, i.e. use with ‘table::unique_key’ flag of ‘table’ definition.
index_range(key_value(s))
to lookup by given ‘key_value(s)’, where the last key value is the one to fit within the range, and return an index of an occurrence. It doesn’t care about the order of an occurrence, simply return that one which reach the first. Use better only when sure there is only one such value in a lookup, i.e. use with ‘table::unique_key’ flag of ‘table’ definition.
index_all(key_value(s))
to lookup by given ‘key_value(s)’ and return a vector of all occurrences.
get_char(field_name,index)
get_uchar(field_name,index)
get_short(field_name,index)
get_ushort(field_name,index)
get_int(field_name,index)
get_uint(field_name,index)
get_long(field_name,index)
get_ulong(field_name,index)
get_int128(field_name,index)
get_uint128(field_name,index)
get_float(field_name,index)
get_double(field_name,index)
get_decimal(field_name,index)
get_date(field_name,index)
get_datetime(field_name,index)
get_timestamp(field_name,index)
get_time(field_name,index)
get_time_ns(field_name,index)
get_interval(field_name,index)
get_interval_ns(field_name,index)
get_string(field_name,index)
get_ustring(field_name,index)
once having an ‘index’ of the record, these functions return value of particular ‘field_name’.
Usage example
// get path to lookup dir from an environment static string lookup_dir = std::getenv("LOOKUP_DIR"); // define a lookup table (file is sorted and binary, key is unique in the file) static table CompanyGroupID(lookup_dir + "/DimCompany.CompanyGroupID.hist.evf", "generated/evd/Lookup/DimCompany.CompanyGroupID.hist.1.evd", "CompanyGroupID", table::unique_key); // assign necessary fields out->company_group_id = in->company_group_id; // lookup and store as an vector auto group_ids = CompanyGroupID.index_all(in->company_group_id); // loop over such vector for ( auto ind : group_ids ) { out->company_group = CompanyGroupID.get_ustring("CompanyGroupName",ind); out->company_id = CompanyGroupID.get_int("CompanyID",ind); out->company_name = CompanyGroupID.get_ustring("CompanyName",ind); add_record(); // produce a record for each Company in a group } discard(); // to avoid last record of the group to be doubled
lookup_<type>
(since EVL 1.0)
lookup_char(field_name,key_value(s))
lookup_uchar(field_name,key_value(s))
lookup_short(field_name,key_value(s))
lookup_ushort(field_name,key_value(s))
lookup_int(field_name,key_value(s))
lookup_uint(field_name,key_value(s))
lookup_long(field_name,key_value(s))
lookup_ulong(field_name,key_value(s))
lookup_int128(field_name,key_value(s))
lookup_uint128(field_name,key_value(s))
lookup_float(field_name,key_value(s))
lookup_double(field_name,key_value(s))
lookup_decimal(field_name,key_value(s))
lookup_date(field_name,key_value(s))
lookup_datetime(field_name,key_value(s))
lookup_timestamp(field_name,key_value(s))
lookup_time(field_name,key_value(s))
lookup_time_ns(field_name,key_value(s))
lookup_interval(field_name,key_value(s))
lookup_interval_ns(field_name,key_value(s))
lookup_string(field_name,key_value(s))
lookup_ustring(field_name,key_value(s))
to lookup by given ‘key_value(s)’ and return value of ‘field_name’ of given data type.
Usage example
// define a lookup table (it is a sorted text file, ignore case of the key) static table company("/data/dimensions/company.csv", "evd/dimensions/company.evd", "Company_ID", table::text_read | table::ignore_case); // assign looked-up field out->company_name = company.lookup_string("Name", in->company_group_id);
lookup_range_<type>
(since EVL 2.0)
lookup_range_char(field_name,key_value(s))
lookup_range_uchar(field_name,key_value(s))
lookup_range_short(field_name,key_value(s))
lookup_range_ushort(field_name,key_value(s))
lookup_range_int(field_name,key_value(s))
lookup_range_uint(field_name,key_value(s))
lookup_range_long(field_name,key_value(s))
lookup_range_ulong(field_name,key_value(s))
lookup_range_int128(field_name,key_value(s))
lookup_range_uint128(field_name,key_value(s))
lookup_range_float(field_name,key_value(s))
lookup_range_double(field_name,key_value(s))
lookup_range_decimal(field_name,key_value(s))
lookup_range_date(field_name,key_value(s))
lookup_range_datetime(field_name,key_value(s))
lookup_range_timestamp(field_name,key_value(s))
lookup_range_time(field_name,key_value(s))
lookup_range_time_ns(field_name,key_value(s))
lookup_range_interval(field_name,key_value(s))
lookup_range_interval_ns(field_name,key_value(s))
lookup_range_string(field_name,key_value(s))
lookup_range_ustring(field_name,key_value(s))
to lookup by given ‘key_value(s)’, where the last one is the one to fit within the range, and return ‘field_name’ of given data type.