| 1 | '''RFC 12: Improved File Management''' |
| 2 | |
| 3 | Author: Konstantin Baumann[[BR]] |
| 4 | Contact: baumann@hpi.uni-potsdam.de[[BR]] |
| 5 | Status: Proposed |
| 6 | |
| 7 | '''Summary''' |
| 8 | |
| 9 | Some OGR drivers can dramatically increase the speed of and optimize the insertion of a set of features, if the driver knows, that there is a whole set of features that should/could be inserted at once (instead of just one by one). |
| 10 | |
| 11 | '''!CreateFeatures()''' |
| 12 | |
| 13 | The following new virtual method is added to the OGRLayer class, with an analogous C function: |
| 14 | {{{ |
| 15 | virtual OGRErr CreateFeatures( OGRFeature** papoFeatures, int iFeatureCount ); |
| 16 | }}} |
| 17 | |
| 18 | A default implementation is given as below: |
| 19 | {{{ |
| 20 | OGRErr OGRLayer::CreateFeatures( |
| 21 | OGRFeature **papoFeatures, |
| 22 | int iFeatureCount |
| 23 | ) { |
| 24 | for(int i = 0; i < iFeatureCount; ++i) { |
| 25 | OGRErr error = CreateFeature( papoFeatures[i] ); |
| 26 | if( error != OGRERR_NONE ) return error; |
| 27 | } |
| 28 | return OGRERR_NONE; |
| 29 | } |
| 30 | }}} |
| 31 | |
| 32 | This triggers the old behavior of an unoptimized insertion. |
| 33 | |
| 34 | Individual drivers can override the default implementation and can implement an optimized algorithm for inserting a set of features. |
| 35 | |
| 36 | '''Additional Notes''' |
| 37 | |
| 38 | Based in this new interface function, I was able to increase the insertion speed of features in the MySQL driver from 40 per second to up to 800-2000 per second. I think other drivers can benefit from this change, too. |
| 39 | |
| 40 | '''Implementation Plan''' |
| 41 | |
| 42 | A patch for the describe additions can be trivially provided. |
| 43 | |
| 44 | I can provide another patch based on this interface which contains the optimized implementation for the MySQL driver. |