Changes between Initial Version and Version 1 of FDORfc26


Ignore:
Timestamp:
Oct 7, 2008, 9:44:03 AM (16 years ago)
Author:
oresthalustchak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FDORfc26

    v1 v1  
     1= FDO RFC 26 - New !ExtendedSelect command and Scrollable Reader =
     2
     3This page contains a request for change document (RFC) for the FDO Open Source project. 
     4More FDO RFCs can be found on the [wiki:FDORfcs RFCs] page.
     5
     6== Status ==
     7 
     8||RFC Template Version||1.0||
     9||Submission Date||October 7, 2008||
     10||Last Modified||Orest Halustchak [[Timestamp]]||
     11||Author||Orest Halustchak||
     12||RFC Status||Draft||
     13||Implementation Status||Draft||
     14||Proposed Milestone||3.4.0.0||
     15||Assigned PSC guide(s)||Greg Boone||
     16||'''Voting History'''||||
     17||+1||||
     18||+0||||
     19||-0||||
     20||-1||||
     21 
     22== Overview ==
     23
     24This RFC adds a new extended select command and scrollable reader to the FDO API. It migrates the current custom command implementations of these in the SDF, SHP, and SQLite providers to make them generic FDO capabilities.
     25
     26== Motivation ==
     27
     28Currently the SDF, SHP, and SQLite provides implement custom commands for extended select, which includes support for a scrollable reader and advanced sorting options. The custom command approach is fine for provider specific capabilities that are not generic, but when a capability is something that many providers could support, they should be defined at the FDO generic level. This will allow them to be used generically by any client application.
     29
     30== Proposed Solution ==
     31
     32This RFC defines a generic FDO command for extended select to replace the custom commands and modifies the SDF, SHP, and SQLite providers to implement the new generic command. The custom commands will remain for backwards compatibility but should be deprecated and removed at some point.
     33
     34This enhancement provides the following main capabilities:
     351.      Scrollable reader; move forward, backward and jump to a particular record.
     362.      Support sorting on more than one property.
     37
     38The solution is made of 2 main interfaces, FdoIExtendedSelect and FdoIScrollableReader.
     39
     40The FdoIExtendedSelect is a specialization of the existing FdoISelect command and, likewise, the FdoIScrollableReader is a specialization of the FdoIFeatureReader interface. That implies that both extension exposes the same functionality of their base interfaces and extend it with the new features.
     41
     42=== !ExtendedSelect ===
     43
     44The FdoIExtendedSelect command can be used to create a scrollable reader and provide multi-properties sorting with different sorting option on each property.
     45
     46Sorting is only performed if the ordering collection is not empty. The ordering collection can be set by calling the FdoISelect::GetOrdering().
     47
     48Above and beyond the methods provided by the FdoISelect command, the FdoIExtendedSelect provides the methods shown in the definition below.
     49
     50
     51{{{
     52class FdoIExtendedSelect : public FdoISelect
     53{               
     54       
     55public:
     56        /// \brief
     57        /// Set the ordering option of the selection.
     58        ///
     59        /// \remarks
     60        /// This is only used if the ordering collection is not empty.
     61        ///
     62        /// \param propertyName
     63        /// Is the property name for which the ordering should be applied. This property should be in the ordering collection.
     64        ///
     65        /// \param option
     66        /// Is the ordering option and should be set to one of FdoOrderingOption_Ascending or FdoOrderingOption_Descending.
     67        /// FdoOrderingOption_Ascending is the default value.
     68        virtual void SetOrderingOption( FdoString* propertyName, FdoOrderingOption  option ) = 0;
     69
     70        /// \brief
     71        /// Gets the ordering option for a given property.
     72        ///
     73        /// \param propertyName
     74        //Is the property name for which the ordering should be applied. This property should be in the ordering collection.
     75        ///
     76        /// \return
     77        /// Returns the ordering option.
     78        virtual FdoOrderingOption GetOrderingOption( FdoString* propertyName ) = 0;
     79
     80        /// \brief
     81        /// Clears the internal list of property/ordering option list and re-sets the ordering option for all
     82        /// the ordering properties to the default FdoOrderingOption_Ascending or to the ordering option specified by the
     83        /// FdoIBaseSelect interface.
     84        virtual void ClearOrderingOptions( ) = 0;
     85
     86        /// \brief
     87        /// Executes the select command and returns an FdoIScrollableFeatureReader.
     88        ///
     89        /// \remarks 
     90        /// If ordering is enabled, then the returned reader is sorted according to
     91        /// the ordering collection. This method perform sorting in memory and allocates an integer value for each row.
     92        /// \return
     93        /// Returns a FdoIScrollableFeatureReader object
     94        virtual FdoIScrollableFeatureReader* ExecuteScrollable() = 0;
     95
     96};
     97}}}
     98
     99=== !ScrollableFeatureReader ===
     100
     101The FdoIScrollableFeatureReader is an extension to the FdoIFeature reader that can be traversed in the forward and backward direction (scrollable). It also provides an ad-hoc access to the returned data. Once the reader is positioned at a given record, the FdoIFeatureReader accesors can be used to access the various properties values.
     102
     103On top of the interface supported by the FdoIFeatureReader, the FdoIScrollableFeatureReader supports the methods shown in the definition below.
     104
     105
     106{{{
     107class FdoIScrollableFeatureReader : public FdoIFeatureReader
     108{
     109public:
     110
     111        /// \brief
     112        /// Returns the number of records of the query result.
     113        ///
     114        /// \return
     115        /// Returns number of records.
     116        virtual int Count() = 0;
     117       
     118        /// \brief
     119        /// Positions the reader at the first record of the query result.
     120        ///
     121        /// \return
     122        /// Returns true if a record is found or false if the result is empty.
     123        virtual bool ReadFirst() = 0;
     124
     125        /// \brief
     126        /// Position the reader at the last record of the query result.
     127        ///
     128        /// \return
     129        /// Returns true if a record is found or false if the result is empty.
     130        virtual bool ReadLast() = 0;
     131
     132        /// \brief
     133        /// Advances the reader to the previous item.
     134        ///
     135        /// \remarks
     136        /// The default position of the reader is prior to the first item.
     137        /// Therefore you must call ReadFirst or ReadLast to
     138        /// begin accessing any data.
     139        ///
     140        /// \return
     141        /// Returns true if a record is found or false if reading is complete.
     142        virtual bool ReadPrevious() = 0;
     143
     144        /// \brief
     145        /// Provides the ad-hoc access to the query result.
     146        ///
     147        /// \remarks
     148        /// It positions the position of the reader at a given record
     149        /// defined by the key. If the record is not found,
     150        /// then the reader position is unset and false value is returned.
     151        /// Once the reader’s position becames unset,
     152        /// the caller needs to call ReadFirst, ReadLast or ReadAt to re-position
     153        /// the reader at a valid location.
     154        ///
     155        /// \param key
     156        /// The key that identifies a record.
     157        ///
     158        /// \return
     159        /// Returns true if a record is found or false otherwise.
     160        virtual bool ReadAt(FdoPropertyValueCollection* key) = 0;
     161
     162        /// \brief
     163        /// Provides an ad-hoc access to the query result.
     164        ///
     165        /// \remarks
     166        /// The recordindex is the one-based nth item in the query result.
     167        /// If successful, this method will position the reader at the feature identified by the recordindex.
     168        ///
     169        /// \param recordindex
     170        /// The index of the row.
     171        ///
     172        /// \return
     173        /// Returns true if a record is found or false otherwise.
     174        virtual bool  ReadAtIndex( unsigned int recordindex ) = 0;
     175
     176        /// \brief
     177        /// Given a key of a feature, IndexOf will return the one based index or the record number of the feature within
     178        /// the returned query result.
     179        /// \remarks
     180        /// If the record is not found, then zero is retuned.
     181        /// This is the mirror function of the GetAtIndex function.
     182        /// This method does not affect the reader position.
     183        ///  GetAtIndex need to be called to move the reader to the returned index.
     184        ///
     185        /// \param key
     186        /// The key that identifies a record.
     187        ///
     188        /// \return
     189        /// Returns true if a record is found or false otherwise.
     190        virtual unsigned int IndexOf(FdoPropertyValueCollection* key) = 0;
     191};
     192}}}
     193
     194
     195=== Example ===
     196
     197{{{
     198    FdoPtr<FdoIExtendedSelect> select = (FdoIExtendedSelect*)connection>CreateCommand(FdoCommandType_ExtendedSelect);
     199    select->SetFeatureClassName(L"World_Countries");
     200
     201    FdoPtr<FdoIdentifierCollection>selecProperties = select>GetPropertyNames();
     202    selecProperties->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"MAPKEY")) );
     203    selecProperties->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"NAME")) );
     204    selecProperties->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"KEY")) );
     205    selecProperties->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"Autogenerated_ID")) );
     206
     207    FdoPtr<FdoIdentifierCollection> orders = select->GetOrdering();
     208    orders->Add( FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"NAME")));
     209    orders->Add( FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"Autogenerated_ID")));
     210    select->SetOrderingOption(L"Autogenerated_ID",FdoOrderingOption_Descending);
     211               
     212    FdoPtr<FdoIScrollableFeatureReader>reader = select->Execute();
     213    if( reader->ReadLast() )
     214    do
     215        {
     216                 // get data using the FdoIFeatureReader accessors
     217        } while( reader->ReadPrevious() );
     218
     219}}}
     220
     221== Test Plan ==
     222
     223Test new APIs to validate correct functionality with SDF, SHP, and SQLite providers.
     224
     225== Funding/Resources ==
     226
     227Autodesk