| 27 | |
| 28 | Currently, data returned in Feature readers or Data readers can only be accessed using named properties. For example, in the following example, the feature reader returned from the select command has to be accessed using the !GetDouble method, with an input parameter that is the property name. In such an implementation, there is an associated cost to determining which property is being requested. Such a cost is typically encountered in performing a lookup based on the name, which inevitably results in some form of a string comparison. |
| 29 | |
| 30 | {{{ |
| 31 | FdoPtr<FdoISelect> spSelectCmd = static_cast<FdoISelect>(mConnection->CreateCommand(FdoCommandType_Select)); |
| 32 | spSelectCmd->SetFeatureClassName (L"Foo"); |
| 33 | |
| 34 | FdoPtr<FdoIdentifierCollection> spIds = spSelectCmd->GetPropertyNames (); |
| 35 | FdoPtr<FdoIdentifier> spId = FdoComputedIdentifier::Create(L"AVG_ID", FdoPtr<FdoExpression>(FdoExpression::Parse(L"Avg(ID)"))); |
| 36 | spIds->Add(spId); |
| 37 | |
| 38 | FdoPtr<FdoIFeatureReader> spReader = spSelectCmd->Execute (); |
| 39 | while (spReader->ReadNext()) |
| 40 | { |
| 41 | double avg = spReader->GetDouble(L"AVG_ID"); |
| 42 | } |
| 43 | }}} |
| 44 | |
| 45 | The goal of this RFC is to add overloaded methods to the various FDO reader interfaces that accept an integer argument representing the indexed location of the property in the reader's in-memory representation of the feature. It is expected that this will speed up processing and provide a better end-user experience. User would be able to access their data using an index into the feature reader collection as follows: |
| 46 | |
| 47 | {{{ |
| 48 | FdoPtr<FdoISelect> spSelectCmd = static_cast<FdoISelect>(mConnection->CreateCommand(FdoCommandType_Select)); |
| 49 | spSelectCmd->SetFeatureClassName (L"Foo"); |
| 50 | |
| 51 | FdoPtr<FdoIdentifierCollection> spIds = spSelectCmd->GetPropertyNames (); |
| 52 | FdoPtr<FdoIdentifier> spId = FdoComputedIdentifier::Create(L"AVG_ID", FdoPtr<FdoExpression>(FdoExpression::Parse(L"Avg(ID)"))); |
| 53 | spIds->Add(spId); |
| 54 | |
| 55 | FdoPtr<FdoIFeatureReader> spReader = spSelectCmd->Execute (); |
| 56 | while (spReader->ReadNext()) |
| 57 | { |
| 58 | double avg = spReader->GetDouble(0); // 0 is the index of the AVG_ID property |
| 59 | } |
| 60 | }}} |
| 61 | |