| 386 | } // namespace |
| 387 | |
| 388 | static bool GetCurrentOutputLayer( |
| 389 | GDALAlgorithm *const alg, const OGRFeatureDefn *const poSrcFeatureDefn, |
| 390 | OGRLayer *const poSrcLayer, const std::string &osKey, |
| 391 | const std::vector<OGRwkbGeometryType> &aeGeomTypes, |
| 392 | const std::string &osLayerDir, const std::string &osScheme, |
| 393 | const std::string &osPatternIn, bool partDigitLeadingZeroes, |
| 394 | size_t partDigitCount, const int featureLimit, const GIntBig maxFileSize, |
| 395 | const bool omitPartitionedFields, |
| 396 | const std::vector<bool> &abPartitionedFields, |
| 397 | const std::vector<bool> &abPartitionedGeomFields, const char *pszExtension, |
| 398 | GDALDriver *const poOutDriver, const CPLStringList &datasetCreationOptions, |
| 399 | const CPLStringList &layerCreationOptions, |
| 400 | const OGRFeatureDefn *const poFeatureDefnWithoutPartitionedFields, |
| 401 | const int nSpatialIndexPerFeatureConstant, |
| 402 | const int nSpatialIndexPerLog2FeatureCountConstant, bool bUseTransactions, |
| 403 | lru11::Cache<std::string, std::shared_ptr<Layer>> &oCacheOutputLayer, |
| 404 | std::shared_ptr<Layer> &outputLayer) |
| 405 | { |
| 406 | const std::string osPattern = |
| 407 | !osPatternIn.empty() ? osPatternIn |
| 408 | : osScheme == GDALVectorPartitionAlgorithm::SCHEME_HIVE |
| 409 | ? DEFAULT_PATTERN_HIVE |
| 410 | : osKey.empty() ? DEFAULT_PATTERN_FLAT_NO_FIELD |
| 411 | : DEFAULT_PATTERN_FLAT; |
| 412 | |
| 413 | bool bLimitReached = false; |
| 414 | bool bOpenOrCreateNewFile = true; |
| 415 | if (oCacheOutputLayer.tryGet(osKey, outputLayer)) |
| 416 | { |
| 417 | if (featureLimit > 0 && outputLayer->nFeatureCount >= featureLimit) |
| 418 | { |
| 419 | bLimitReached = true; |
| 420 | } |
| 421 | else if (maxFileSize > 0 && |
| 422 | outputLayer->nFileSize + |
| 423 | (nSpatialIndexPerFeatureConstant > 0 |
| 424 | ? (outputLayer->nFeatureCount * |
| 425 | nSpatialIndexPerFeatureConstant + |
| 426 | static_cast<int>(std::ceil( |
| 427 | log2(outputLayer->nFeatureCount)))) * |
| 428 | nSpatialIndexPerLog2FeatureCountConstant |
| 429 | : 0) >= |
| 430 | maxFileSize) |
| 431 | { |
| 432 | bLimitReached = true; |
| 433 | } |
| 434 | else |
| 435 | { |
| 436 | bOpenOrCreateNewFile = false; |
| 437 | } |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | outputLayer = std::make_unique<Layer>(); |
| 442 | outputLayer->bUseTransactions = bUseTransactions; |
| 443 | } |
| 444 | |
| 445 | const auto SubstituteVariables = [&osKey, poSrcLayer](const std::string &s) |
no test coverage detected