Changes between Initial Version and Version 1 of rfc29_desired_fields


Ignore:
Timestamp:
Jul 19, 2010, 12:03:58 PM (14 years ago)
Author:
wonder
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • rfc29_desired_fields

    v1 v1  
     1= RFC 29: OGR Set Desired Fields =
     2
     3Author: Martin Dobias[[BR]]
     4Contact: wonder.sk@gmail.com[[BR]]
     5Status: Development
     6
     7== Summary ==
     8
     9To improve performance when fetching features, this RFC proposes a way how to tell OGR which fields are going to be required in subsequent GetFeature() / GetNextFeature() calls. Knowing the necessary fields, the OGR driver can decide to leave the rest of the fields null.
     10
     11== Details ==
     12
     13A new (non-virtual) function should be added to OGRLayer class to allow the client to set which fields will be fetched:
     14
     15{{{
     16void SetDesiredFields(int nNumFields, int* pabFields);
     17}}}
     18
     19and an equivalent call for C API:
     20
     21{{{
     22void CPL_DLL OGR_L_SetDesiredFields( OGRLayerH, int, int* );
     23}}}
     24
     25The parameter "pabFields" is an array of booleans, each item specifies whether the field with the same index should be fetched. The length of the array is specified in "nNumFields" parameter and typically it should be the same as the actual number of fields. The SetDesiredFields() function makes a copy of both nNumFields and pabFields (these have to be stored as class member variables of OGRLayer: nDesiredNumFields, pabDesiredFields).
     26
     27The parameter "nNumFields" is a bit redundant, but it keeps things safe in case some fields are later added so that there is not access beyond the allocated memory of the array.
     28
     29The semantics is as follows: if nNumFields < 0, all fields will be fetched. Otherwise the pabFields array will be copied to an internal one within OGRLayer and only the fields having non-zero value in that array will be fetched.
     30
     31The implementation of fetching in drivers will usually require only small adjustment, e.g.:
     32
     33{{{
     34for( int iField = 0; iField < poDefn->GetFieldCount(); iField++ )
     35{
     36  if (nDesiredNumFields >= 0 && iField < nDesiredNumFields && !pabDesiredFields[iField])
     37    continue;
     38
     39  // fetch field
     40}
     41}}}
     42
     43== Compatibility ==
     44
     45This change is fully backwards compatible: OGR will continue to fetch all fields by default. Only applications using the proposed new API will experience new behavior.
     46
     47There is no need to modify all existing drivers. Drivers that do not consider the desired fields will still fetch all attributes as before.
     48