wiki:FdoIndexingApis

Version 1 (modified by jng, 16 years ago) ( diff )

Some ideas about indexing

FDO Indexing APIs

Overview

A common data store concept that has yet to be exposed in FDO is indexes. Nearly all databases (spatial or non-spatial), have some form of indexing capability available, however this indexing has to be done outside of FDO as no interface currently exists to do this through FDO. For the purposes of this discussion, we are mainly referring to property (attribute) indexes and not spatial indexes.

It would make sense for FDO to support the ability to create custom indexes. Perhaps the best way to expose such an interface would be to model it in the exact same way that Spatial Contexts are managed. So something like

Possible Interfaces

New Command Types:

FdoCommandType_CreateIndex
FdoCommandType_GetIndexes
FdoCommandType_DestroyIndex

FdoICreateIndex:

/// \brief
/// Defines the CreateIndex command, which creates an index on the current
/// data store
class FdoICreateIndex : public FdoICommand
{
public:
    /// \brief
    ///  Gets the name of the index to create
    /// 
    /// \return
    /// Returns the name of the index
    /// 
    FDO_API virtual FdoString* GetName() = 0;

    /// \brief
    ///  Sets the name of the index to create
    /// 
    FDO_API virtual void SetName(const FdoString* value) = 0;

    /// \brief
    ///  Gets the name of the class definition to create this index on
    /// 
    /// \return
    /// Returns the name of the class
    /// 
    FDO_API virtual FdoString* GetClassName() = 0;

    /// \brief
    ///  Sets the name of the class definition to create this index on
    /// 
    FDO_API virtual void SetClassName(const FdoString* className) = 0;

    /// \brief
    ///  Gets the collection of property names this index will be created on
    /// 
    /// \return
    /// Returns the collection of property names
    /// 
    FDO_API virtual FdoStringCollection* GetPropertyNames() = 0;

    /// \brief
    ///  Sets a boolean flag that indicates how the CreateIndex command will behave
    /// if the named index already exists. 
    FDO_API virtual void SetUpdateExisting(const bool value) = 0;

    /// \brief
    ///  Gets a boolean flag that indicates how the CreateIndex command will behave
    /// if the named index already exists. 
    /// 
    /// \return
    /// Returns true if command should update existing index
    /// 
    FDO_API virtual bool GetUpdateExisting() = 0;

    /// \brief
    ///  Executes the command
    /// 
    FDO_API virtual void Execute() = 0;  
};

FdoIDestroyIndex:

/// \brief
/// Defines the DestroyIndex command, which destroys an existing index. Input to the
/// command is the name of the index to destroy.
class FdoIDestroyIndex : public FdoICommand
{
public:
    /// \brief
    ///  Gets the name of the index to destroy 
    /// 
    /// \return
    /// Returns the name of the index
    /// 
    FDO_API virtual FdoString* GetName() = 0;

    /// \brief
    ///  Sets the name of the index to destroy 
    /// 
    FDO_API virtual void SetName(FdoString* value) = 0;

    /// \brief
    ///  Executes the command
    /// 
    FDO_API virtual void Execute() = 0;
};

FdoIGetIndexes:

/// \brief
/// Defines the GetIndexes command, which enumerates the existing indexes
class FdoIGetIndexes: public FdoICommand
{
public:
    /// \brief
    ///  Executes the command returning an FdoIIndexReader
    /// 
    FDO_API virtual FdoIIndexReader Execute() = 0;  
};

FdoIIndexReader:

/// \brief
/// Provides a forward-only, read-only iterator for reading data store indexes
/// A reference to an FdoIIndexReader is returned from the GetIndexes commands.
/// Because the initial position of the FdoIIndexReader is prior to the first item,
/// you must call ReadNext to begin acessing any data
class FdoIIndexReader: public FdoIDisposable
{
public:
    /// \brief
    /// Gets the name of the index currently being read
    /// 
    /// \return
    /// Returns the name of the index
    /// 
    FDO_API virtual FdoString* GetName() = 0;

    /// \brief
    /// Gets the name of the feature schema this current index is being applied to
    /// 
    /// \return
    /// Returns the name of the feature schema
    /// 
    FDO_API virtual FdoString* GetSchemaName() = 0;

    /// \brief
    /// Gets the name of the class definition this current index is being applied to
    /// 
    /// \return
    /// Returns the name of the class definition
    /// 
    FDO_API virtual FdoString* GetClassName() = 0;

    /// \brief
    /// Gets the names of the properties this current index is being applied to
    /// 
    /// \return
    /// Returns a collection of property names
    /// 
    FDO_API virtual FdoStringCollection* GetPropertyNames() = 0;

    /// \brief
    /// Advances the reader to the next item. The default position of the reader
    /// is prior to the first item. Thus, you must call ReadNext to begin
    /// accessing any data.
    /// 
    /// \return
    /// Returns true if there is a next item.
    /// 
    FDO_API virtual bool ReadNext() = 0;
};

More points of discussion

  • Support for certain index types?
  • Support in FdoIApplySchema and Fdo* schema classes instead?
Note: See TracWiki for help on using the wiki.