Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: "partition" step of "vector pipeline" 5 : * Author: Even Rouault <even dot rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDALALG_VECTOR_PARTITION_INCLUDED 14 : #define GDALALG_VECTOR_PARTITION_INCLUDED 15 : 16 : #include "gdalalg_vector_pipeline.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALVectorPartitionAlgorithm */ 22 : /************************************************************************/ 23 : 24 : class GDALVectorPartitionAlgorithm /* non final */ 25 : : public GDALVectorPipelineStepAlgorithm 26 : { 27 : public: 28 : static constexpr const char *NAME = "partition"; 29 : static constexpr const char *DESCRIPTION = 30 : "Partition a vector dataset into multiple files."; 31 : static constexpr const char *HELP_URL = 32 : "/programs/gdal_vector_partition.html"; 33 : 34 : explicit GDALVectorPartitionAlgorithm(bool standaloneStep = false); 35 : 36 24 : bool CanBeLastStep() const override 37 : { 38 24 : return true; 39 : } 40 : 41 2 : bool IsNativelyStreamingCompatible() const override 42 : { 43 2 : return false; 44 : } 45 : 46 : static constexpr const char *SCHEME_HIVE = "hive"; 47 : static constexpr const char *SCHEME_FLAT = "flat"; 48 : 49 : private: 50 : static ConstructorOptions GetConstructorOptions(bool standaloneStep); 51 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 52 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 53 : 54 : std::vector<std::string> m_fields{}; 55 : int m_featureLimit = 0; 56 : std::string m_maxFileSizeStr{}; 57 : GIntBig m_maxFileSize = 0; 58 : bool m_omitPartitionedFields = false; 59 : int m_maxCacheSize = 400; 60 : int m_transactionSize = 65536; 61 : std::string m_scheme = SCHEME_HIVE; 62 : std::string m_pattern{}; 63 : 64 : // Computed 65 : bool m_partDigitLeadingZeroes = true; 66 : size_t m_partDigitCount = 10; 67 : }; 68 : 69 : /************************************************************************/ 70 : /* GDALVectorPartitionAlgorithmStandalone */ 71 : /************************************************************************/ 72 : 73 92 : class GDALVectorPartitionAlgorithmStandalone final 74 : : public GDALVectorPartitionAlgorithm 75 : { 76 : public: 77 46 : GDALVectorPartitionAlgorithmStandalone() 78 46 : : GDALVectorPartitionAlgorithm(/* standaloneStep = */ true) 79 : { 80 46 : } 81 : 82 : ~GDALVectorPartitionAlgorithmStandalone() override; 83 : }; 84 : 85 : //! @endcond 86 : 87 : #endif /* GDALALG_VECTOR_FILTER_INCLUDED */