= FDO RFC 34 - FDO Reader Access By Index = This page contains an change request (RFC) for the FDO Open Source project. More FDO RFCs can be found on the [wiki:FDORfcs RFCs] page. == Status == ||RFC Template Version||(1.0)|| ||Submission Date|| April 9, 2009 || ||Last Modified|| Greg Boone [[Timestamp]]|| ||Author||Greg Boone|| ||RFC Status||Not Ready|| ||Implementation Status||Pending|| ||Proposed Milestone||3.5.0.0|| ||Assigned PSC guide(s)||Greg Boone|| ||'''Voting History'''||(vote date)|| ||+1|| || ||+0|| || ||-0|| || ||-1|| || == Motivation == To Provide faster access to data returned from readers in the FDO API. == Overview == 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. {{{ FdoPtr spSelectCmd = static_cast(mConnection->CreateCommand(FdoCommandType_Select)); spSelectCmd->SetFeatureClassName (L"Foo"); FdoPtr spIds = spSelectCmd->GetPropertyNames (); FdoPtr spId = FdoComputedIdentifier::Create(L"AVG_ID", FdoPtr(FdoExpression::Parse(L"Avg(ID)"))); spIds->Add(spId); FdoPtr spReader = spSelectCmd->Execute (); while (spReader->ReadNext()) { double avg = spReader->GetDouble(L"AVG_ID"); } }}} 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: {{{ FdoPtr spSelectCmd = static_cast(mConnection->CreateCommand(FdoCommandType_Select)); spSelectCmd->SetFeatureClassName (L"Foo"); FdoPtr spIds = spSelectCmd->GetPropertyNames (); FdoPtr spId = FdoComputedIdentifier::Create(L"AVG_ID", FdoPtr(FdoExpression::Parse(L"Avg(ID)"))); spIds->Add(spId); FdoPtr spReader = spSelectCmd->Execute (); while (spReader->ReadNext()) { double avg = spReader->GetDouble(0); // 0 is the index of the AVG_ID property } }}} == Requirements == The following FDo interfaces will be updated to allow for indexed access: /// \brief /// The FdoIFeatureReader interface provides a forward-only, read-only iterator /// for reading feature data. A reference to an FdoIFeatureReader is returned /// from the Select and SelectAndLock commands. Because the initial position of the /// FdoIFeatureReader is prior to the first item, you must call /// ReadNext to begin accessing any data. class FdoIReader: public FdoIDisposable { public: ... ... ... /// \brief /// Returns true if the value of the property at the specified /// index is null. /// /// \param index /// Input the index of the property. /// /// \return /// Returns true if the value is null. /// FDO_API virtual FdoBoolean IsNull(FdoInt32 index); /// \brief /// Gets the Boolean value of the property specified at the index position. /// No conversion is performed, thus the property must be FdoDataType_Boolean /// or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the Boolean value. /// FDO_API virtual bool GetBoolean(FdoInt32 index); /// \brief /// Gets the Byte value of the property specified at the index position. /// No conversion is performed, thus the property must be FdoDataType_Byte /// or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the byte value. /// FDO_API virtual FdoByte GetByte(FdoInt32 index); /// \brief /// Gets the date and time value of the of the property specified at /// the index position. No conversion is performed, thus the property /// must be FdoDataType_DateTime or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the date and time value. /// FDO_API virtual FdoDateTime GetDateTime(FdoInt32 index); /// \brief /// Gets the double-precision floating point value of the property specified at /// the index position. No conversion is performed, thus the property must be /// FdoDataType_Double or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the double floating point value /// FDO_API virtual FdoDouble GetDouble(FdoInt32 index); /// \brief /// Gets the 16-bit integer value of the property specified at /// the index position. No conversion is performed, thus the /// property must be FdoDataType_Int16 or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the FdoInt16 value. /// FDO_API virtual FdoInt16 GetInt16(FdoInt32 index); /// \brief /// Gets the 32-bit integer value of the property specified at /// the index position. No conversion is performed, thus the /// property must be FdoDataType_Int32 or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the FdoInt32 value /// FDO_API virtual FdoInt32 GetInt32(FdoInt32 index); /// \brief /// Gets the 64-bit integer value of the property specified at /// the index position. No conversion is performed, thus the /// property must be FdoDataType_Int64 or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the FdoInt64 value. /// FDO_API virtual FdoInt64 GetInt64(FdoInt32 index); /// \brief /// Gets the Single floating point value of the property specified at /// the index position. No conversion is performed, thus the property /// must be FdoDataType_Single or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the single value /// FDO_API virtual FdoFloat GetSingle(FdoInt32 index); /// \brief /// Gets the string value of the property specified at the index /// position. No conversion is performed, thus the property must /// be FdoDataType_String or an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the string value /// FDO_API virtual FdoString* GetString(FdoInt32 index); /// \brief /// Gets a LOBValue reference to the property specified at the index /// position. The LOB is fully read in and data available. /// Because no conversion is performed, the property must be /// FdoDataType_BLOB or FdoDataType_CLOB etc. (a LOB type) /// /// \param index /// Input the index of the property. /// /// \return /// Returns the reference to LOBValue /// FDO_API virtual FdoLOBValue* GetLOB(FdoInt32 index); /// \brief /// Gets a reference to the specified LOB property, specified at the index /// position. The reference is returned as an FdoBLOBStreamReader /// or an FdoCLOBStreamReader, to allow reading in blocks of data. /// Because no conversion is performed, the property must be FdoDataType_BLOB /// or FdoDataType_CLOB etc. (a LOB type) Cast the FdoIStreamReader /// to the appropiate LOB Stream Reader. /// /// \param index /// Input the index of the property. /// /// \return /// Returns a reference to a LOB stream reader /// FDO_API virtual FdoIStreamReader* GetLOBStreamReader(FdoInt32 index); /// \brief /// Gets the geometry value of the property, at the specified index, as a /// byte array in FGF format. Because no conversion is performed, the /// property must be of Geometric type; otherwise, an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the byte array in FGF format. /// FDO_API virtual FdoByteArray* GetGeometry(FdoInt32 index); /// \brief /// Gets the raster object of the property at the specified index. /// Because no conversion is performed, the property must be /// of Raster type; otherwise, an exception is thrown. /// /// \param index /// Input the index of the property. /// /// \return /// Returns the raster object. /// FDO_API virtual FdoIRaster* GetRaster(FdoInt32 index); }; == Provider Implementation == == Test Plan == Existing FDO Core unit tests will be expanded to test the proposed enhancements defined above. == Funding/Resources == Autodesk to provide resources / funding