Ticket #1633 (closed enhancement: invalid)
add OGRLayer::CreateFeatures() for "bulk-insertion" of features
| Reported by: | Kosta | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | OGR_SF | Version: | unspecified |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I would like to add this new method to OGRLayer:
virtual OGRErr OGRLayer::CreateFeatures(
OGRFeature** poFeatures,
int iFeatureCount,
int bUseFIDs
);
with a default implementation like this:
OGRErr OGRLayer::CreateFeatures(
OGRFeature **poFeatures,
int iFeatureCount,
int bUseFIDs
) {
for(int i = 0; i < iFeatureCount; ++i) {
OGRFeature* poFeature = poFeatures[i];
assert(poFeature);
long iStoreFID = poFeature->GetFID();
if(!bUseFIDs) poFeature->SetFID(OGRNullFID);
OGRErr error = CreateFeature( poFeature );
if(!bUseFIDs) poFeature->SetFID(iStoreFID);
if( error != OGRERR_NONE ) return error;
}
return OGRERR_NONE;
}
The flag bUseFIDs indicate, if the FIDs of the provided features should be used for insertion (bUseFIDs==true) or if they should be ignored (bUseFIDs==false), thus generating new FIDs for the features during insertion.
This enables driver specific optimizations for insertions of many features at once.
Based on this simple interface enhancement I was able to increase the insertion rate for the MySQL driver from 40 features/second to 250-700 features/second; tested with insertions of 1.000 - 80.000 features...
Change History
Note: See
TracTickets for help on using
tickets.
