| 1 | |
| 2 | == FDO Indexing APIs == |
| 3 | |
| 4 | === Overview === |
| 5 | |
| 6 | 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. |
| 7 | |
| 8 | 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 |
| 9 | |
| 10 | === Possible Interfaces === |
| 11 | |
| 12 | New Command Types: |
| 13 | {{{ |
| 14 | FdoCommandType_CreateIndex |
| 15 | FdoCommandType_GetIndexes |
| 16 | FdoCommandType_DestroyIndex |
| 17 | }}} |
| 18 | |
| 19 | FdoICreateIndex: |
| 20 | {{{ |
| 21 | /// \brief |
| 22 | /// Defines the CreateIndex command, which creates an index on the current |
| 23 | /// data store |
| 24 | class FdoICreateIndex : public FdoICommand |
| 25 | { |
| 26 | public: |
| 27 | /// \brief |
| 28 | /// Gets the name of the index to create |
| 29 | /// |
| 30 | /// \return |
| 31 | /// Returns the name of the index |
| 32 | /// |
| 33 | FDO_API virtual FdoString* GetName() = 0; |
| 34 | |
| 35 | /// \brief |
| 36 | /// Sets the name of the index to create |
| 37 | /// |
| 38 | FDO_API virtual void SetName(const FdoString* value) = 0; |
| 39 | |
| 40 | /// \brief |
| 41 | /// Gets the name of the class definition to create this index on |
| 42 | /// |
| 43 | /// \return |
| 44 | /// Returns the name of the class |
| 45 | /// |
| 46 | FDO_API virtual FdoString* GetClassName() = 0; |
| 47 | |
| 48 | /// \brief |
| 49 | /// Sets the name of the class definition to create this index on |
| 50 | /// |
| 51 | FDO_API virtual void SetClassName(const FdoString* className) = 0; |
| 52 | |
| 53 | /// \brief |
| 54 | /// Gets the collection of property names this index will be created on |
| 55 | /// |
| 56 | /// \return |
| 57 | /// Returns the collection of property names |
| 58 | /// |
| 59 | FDO_API virtual FdoStringCollection* GetPropertyNames() = 0; |
| 60 | |
| 61 | /// \brief |
| 62 | /// Sets a boolean flag that indicates how the CreateIndex command will behave |
| 63 | /// if the named index already exists. |
| 64 | FDO_API virtual void SetUpdateExisting(const bool value) = 0; |
| 65 | |
| 66 | /// \brief |
| 67 | /// Gets a boolean flag that indicates how the CreateIndex command will behave |
| 68 | /// if the named index already exists. |
| 69 | /// |
| 70 | /// \return |
| 71 | /// Returns true if command should update existing index |
| 72 | /// |
| 73 | FDO_API virtual bool GetUpdateExisting() = 0; |
| 74 | |
| 75 | /// \brief |
| 76 | /// Executes the command |
| 77 | /// |
| 78 | FDO_API virtual void Execute() = 0; |
| 79 | }; |
| 80 | }}} |
| 81 | |
| 82 | FdoIDestroyIndex: |
| 83 | {{{ |
| 84 | /// \brief |
| 85 | /// Defines the DestroyIndex command, which destroys an existing index. Input to the |
| 86 | /// command is the name of the index to destroy. |
| 87 | class FdoIDestroyIndex : public FdoICommand |
| 88 | { |
| 89 | public: |
| 90 | /// \brief |
| 91 | /// Gets the name of the index to destroy |
| 92 | /// |
| 93 | /// \return |
| 94 | /// Returns the name of the index |
| 95 | /// |
| 96 | FDO_API virtual FdoString* GetName() = 0; |
| 97 | |
| 98 | /// \brief |
| 99 | /// Sets the name of the index to destroy |
| 100 | /// |
| 101 | FDO_API virtual void SetName(FdoString* value) = 0; |
| 102 | |
| 103 | /// \brief |
| 104 | /// Executes the command |
| 105 | /// |
| 106 | FDO_API virtual void Execute() = 0; |
| 107 | }; |
| 108 | }}} |
| 109 | |
| 110 | FdoIGetIndexes: |
| 111 | {{{ |
| 112 | /// \brief |
| 113 | /// Defines the GetIndexes command, which enumerates the existing indexes |
| 114 | class FdoIGetIndexes: public FdoICommand |
| 115 | { |
| 116 | public: |
| 117 | /// \brief |
| 118 | /// Executes the command returning an FdoIIndexReader |
| 119 | /// |
| 120 | FDO_API virtual FdoIIndexReader Execute() = 0; |
| 121 | }; |
| 122 | }}} |
| 123 | |
| 124 | FdoIIndexReader: |
| 125 | {{{ |
| 126 | /// \brief |
| 127 | /// Provides a forward-only, read-only iterator for reading data store indexes |
| 128 | /// A reference to an FdoIIndexReader is returned from the GetIndexes commands. |
| 129 | /// Because the initial position of the FdoIIndexReader is prior to the first item, |
| 130 | /// you must call ReadNext to begin acessing any data |
| 131 | class FdoIIndexReader: public FdoIDisposable |
| 132 | { |
| 133 | public: |
| 134 | /// \brief |
| 135 | /// Gets the name of the index currently being read |
| 136 | /// |
| 137 | /// \return |
| 138 | /// Returns the name of the index |
| 139 | /// |
| 140 | FDO_API virtual FdoString* GetName() = 0; |
| 141 | |
| 142 | /// \brief |
| 143 | /// Gets the name of the feature schema this current index is being applied to |
| 144 | /// |
| 145 | /// \return |
| 146 | /// Returns the name of the feature schema |
| 147 | /// |
| 148 | FDO_API virtual FdoString* GetSchemaName() = 0; |
| 149 | |
| 150 | /// \brief |
| 151 | /// Gets the name of the class definition this current index is being applied to |
| 152 | /// |
| 153 | /// \return |
| 154 | /// Returns the name of the class definition |
| 155 | /// |
| 156 | FDO_API virtual FdoString* GetClassName() = 0; |
| 157 | |
| 158 | /// \brief |
| 159 | /// Gets the names of the properties this current index is being applied to |
| 160 | /// |
| 161 | /// \return |
| 162 | /// Returns a collection of property names |
| 163 | /// |
| 164 | FDO_API virtual FdoStringCollection* GetPropertyNames() = 0; |
| 165 | |
| 166 | /// \brief |
| 167 | /// Advances the reader to the next item. The default position of the reader |
| 168 | /// is prior to the first item. Thus, you must call ReadNext to begin |
| 169 | /// accessing any data. |
| 170 | /// |
| 171 | /// \return |
| 172 | /// Returns true if there is a next item. |
| 173 | /// |
| 174 | FDO_API virtual bool ReadNext() = 0; |
| 175 | }; |
| 176 | }}} |
| 177 | |
| 178 | === More points of discussion === |
| 179 | |
| 180 | * Support for certain index types? |
| 181 | * Support in FdoIApplySchema and Fdo* schema classes instead? |