LCOV - code coverage report
Current view: top level - frmts/tiledb - tiledbmultidim.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 100 106 94.3 %
Date: 2024-05-14 13:00:50 Functions: 42 45 93.3 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL TileDB Driver
       4             :  * Purpose:  Implement GDAL TileDB multidimensional support based on https://www.tiledb.io
       5             :  * Author:   TileDB, Inc
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2023, TileDB, Inc
       9             :  *
      10             :  * Permission is hereby granted, free of charge, to any person obtaining a
      11             :  * copy of this software and associated documentation files (the "Software"),
      12             :  * to deal in the Software without restriction, including without limitation
      13             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      14             :  * and/or sell copies of the Software, and to permit persons to whom the
      15             :  * Software is furnished to do so, subject to the following conditions:
      16             :  *
      17             :  * The above copyright notice and this permission notice shall be included
      18             :  * in all copies or substantial portions of the Software.
      19             :  *
      20             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      21             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      23             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      25             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      26             :  * DEALINGS IN THE SOFTWARE.
      27             :  ****************************************************************************/
      28             : 
      29             : #ifndef TILEDBMULTIDIM_H_INCLUDED
      30             : #define TILEDBMULTIDIM_H_INCLUDED
      31             : 
      32             : #include "tiledbheaders.h"
      33             : 
      34             : #include <set>
      35             : 
      36             : constexpr const char *CRS_ATTRIBUTE_NAME = "_CRS";
      37             : constexpr const char *UNIT_ATTRIBUTE_NAME = "_UNIT";
      38             : constexpr const char *DIM_TYPE_ATTRIBUTE_NAME = "_DIM_TYPE";
      39             : constexpr const char *DIM_DIRECTION_ATTRIBUTE_NAME = "_DIM_DIRECTION";
      40             : 
      41             : /************************************************************************/
      42             : /*                     TileDBSharedResource                            */
      43             : /************************************************************************/
      44             : 
      45             : class TileDBSharedResource
      46             : {
      47             :     std::unique_ptr<tiledb::Context> m_ctx{};
      48             :     bool m_bUpdatable = false;
      49             :     bool m_bStats = false;
      50             :     uint64_t m_nTimestamp = 0;
      51             : 
      52             :   public:
      53          52 :     TileDBSharedResource(std::unique_ptr<tiledb::Context> &&ctx,
      54             :                          bool bUpdatable)
      55          52 :         : m_ctx(std::move(ctx)), m_bUpdatable(bUpdatable)
      56             :     {
      57          52 :     }
      58             : 
      59         106 :     inline bool IsUpdatable() const
      60             :     {
      61         106 :         return m_bUpdatable;
      62             :     }
      63             : 
      64         502 :     inline tiledb::Context &GetCtx() const
      65             :     {
      66         502 :         return *(m_ctx.get());
      67             :     }
      68             : 
      69             :     static std::string SanitizeNameForPath(const std::string &osName);
      70             : 
      71          52 :     void SetDumpStats(bool b)
      72             :     {
      73          52 :         m_bStats = b;
      74          52 :     }
      75             : 
      76          75 :     bool GetDumpStats() const
      77             :     {
      78          75 :         return m_bStats;
      79             :     }
      80             : 
      81           0 :     void SetTimestamp(uint64_t t)
      82             :     {
      83           0 :         m_nTimestamp = t;
      84           0 :     }
      85             : 
      86          75 :     uint64_t GetTimestamp() const
      87             :     {
      88          75 :         return m_nTimestamp;
      89             :     }
      90             : };
      91             : 
      92             : /************************************************************************/
      93             : /*                      TileDBAttributeHolder                           */
      94             : /************************************************************************/
      95             : 
      96         133 : class TileDBAttributeHolder
      97             : {
      98             :   private:
      99             :     mutable std::map<std::string, std::shared_ptr<GDALAttribute>>
     100             :         m_oMapAttributes{};
     101             : 
     102             :     virtual uint64_t metadata_num() const = 0;
     103             :     virtual void get_metadata_from_index(uint64_t index, std::string *key,
     104             :                                          tiledb_datatype_t *value_type,
     105             :                                          uint32_t *value_num,
     106             :                                          const void **value) const = 0;
     107             :     virtual bool has_metadata(const std::string &key,
     108             :                               tiledb_datatype_t *value_type) const = 0;
     109             :     virtual void get_metadata(const std::string &key,
     110             :                               tiledb_datatype_t *value_type,
     111             :                               uint32_t *value_num,
     112             :                               const void **value) const = 0;
     113             :     virtual void put_metadata(const std::string &key,
     114             :                               tiledb_datatype_t value_type, uint32_t value_num,
     115             :                               const void *value) = 0;
     116             :     virtual void delete_metadata(const std::string &key) = 0;
     117             : 
     118             :     virtual bool EnsureOpenAs(tiledb_query_type_t mode) const = 0;
     119             :     virtual std::shared_ptr<TileDBAttributeHolder>
     120             :     AsAttributeHolderSharedPtr() const = 0;
     121             : 
     122             :     static std::shared_ptr<GDALAttribute>
     123             :     CreateAttribute(const std::shared_ptr<TileDBAttributeHolder> &poSelf,
     124             :                     const std::string &osName, tiledb_datatype_t value_type,
     125             :                     uint32_t value_num, const void *value);
     126             : 
     127             :   public:
     128             :     virtual ~TileDBAttributeHolder() = 0;
     129             : 
     130             :     virtual bool IIsWritable() const = 0;
     131             :     virtual const std::string &IGetFullName() const = 0;
     132             : 
     133             :     std::shared_ptr<GDALAttribute>
     134             :     CreateAttributeImpl(const std::string &osName,
     135             :                         const std::vector<GUInt64> &anDimensions,
     136             :                         const GDALExtendedDataType &oDataType,
     137             :                         CSLConstList papszOptions = nullptr);
     138             : 
     139             :     std::shared_ptr<GDALAttribute>
     140             :     GetAttributeImpl(const std::string &osName) const;
     141             : 
     142             :     std::vector<std::shared_ptr<GDALAttribute>>
     143             :     GetAttributesImpl(CSLConstList papszOptions = nullptr) const;
     144             : 
     145             :     bool DeleteAttributeImpl(const std::string &osName,
     146             :                              CSLConstList papszOptions = nullptr);
     147             : 
     148             :     bool GetMetadata(const std::string &key, tiledb_datatype_t *value_type,
     149             :                      uint32_t *value_num, const void **value) const;
     150             :     bool PutMetadata(const std::string &key, tiledb_datatype_t value_type,
     151             :                      uint32_t value_num, const void *value);
     152             : };
     153             : 
     154             : /************************************************************************/
     155             : /*                          TileDBGroup                                 */
     156             : /************************************************************************/
     157             : 
     158             : class TileDBArray;
     159             : 
     160             : class TileDBGroup final : public GDALGroup, public TileDBAttributeHolder
     161             : {
     162             :     std::shared_ptr<TileDBSharedResource> m_poSharedResource{};
     163             :     const std::string m_osPath;
     164             :     mutable std::unique_ptr<tiledb::Group> m_poTileDBGroup{};
     165             :     mutable std::map<std::string, std::shared_ptr<TileDBGroup>> m_oMapGroups{};
     166             :     mutable std::map<std::string, std::shared_ptr<TileDBArray>> m_oMapArrays{};
     167             :     mutable std::map<std::string, std::shared_ptr<GDALDimension>>
     168             :         m_oMapDimensions{};
     169             : 
     170             :     //! To prevent OpenMDArray() to indefinitely recursing
     171             :     mutable std::set<std::string> m_oSetArrayInOpening{};
     172             : 
     173          58 :     TileDBGroup(const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     174             :                 const std::string &osParentName, const std::string &osName,
     175             :                 const std::string &osPath)
     176          58 :         : GDALGroup(osParentName, osName), m_poSharedResource(poSharedResource),
     177          58 :           m_osPath(osPath)
     178             :     {
     179          58 :     }
     180             : 
     181             :     static std::shared_ptr<TileDBGroup>
     182          58 :     Create(const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     183             :            const std::string &osParentName, const std::string &osName,
     184             :            const std::string &osPath)
     185             :     {
     186             :         auto poGroup = std::shared_ptr<TileDBGroup>(
     187          58 :             new TileDBGroup(poSharedResource, osParentName, osName, osPath));
     188          58 :         poGroup->SetSelf(poGroup);
     189          58 :         return poGroup;
     190             :     }
     191             : 
     192             :     bool HasObjectOfSameName(const std::string &osName) const;
     193             : 
     194             :   protected:
     195             :     // BEGIN: interfaces of TileDBAttributeHolder
     196             : 
     197             :     bool EnsureOpenAs(tiledb_query_type_t mode) const override;
     198             : 
     199           4 :     uint64_t metadata_num() const override
     200             :     {
     201           4 :         return m_poTileDBGroup->metadata_num();
     202             :     }
     203             : 
     204           3 :     void get_metadata_from_index(uint64_t index, std::string *key,
     205             :                                  tiledb_datatype_t *value_type,
     206             :                                  uint32_t *value_num,
     207             :                                  const void **value) const override
     208             :     {
     209           3 :         m_poTileDBGroup->get_metadata_from_index(index, key, value_type,
     210             :                                                  value_num, value);
     211           3 :     }
     212             : 
     213           4 :     bool has_metadata(const std::string &key,
     214             :                       tiledb_datatype_t *value_type) const override
     215             :     {
     216           4 :         return m_poTileDBGroup->has_metadata(key, value_type);
     217             :     }
     218             : 
     219           4 :     void get_metadata(const std::string &key, tiledb_datatype_t *value_type,
     220             :                       uint32_t *value_num, const void **value) const override
     221             :     {
     222           4 :         m_poTileDBGroup->get_metadata(key, value_type, value_num, value);
     223           4 :     }
     224             : 
     225           3 :     void put_metadata(const std::string &key, tiledb_datatype_t value_type,
     226             :                       uint32_t value_num, const void *value) override
     227             :     {
     228           3 :         m_poTileDBGroup->put_metadata(key, value_type, value_num, value);
     229           3 :     }
     230             : 
     231           2 :     void delete_metadata(const std::string &key) override
     232             :     {
     233           2 :         m_poTileDBGroup->delete_metadata(key);
     234           2 :     }
     235             : 
     236             :     std::shared_ptr<TileDBAttributeHolder>
     237           8 :     AsAttributeHolderSharedPtr() const override
     238             :     {
     239           8 :         return std::dynamic_pointer_cast<TileDBAttributeHolder>(m_pSelf.lock());
     240             :     }
     241             : 
     242          12 :     bool IIsWritable() const override
     243             :     {
     244          12 :         return m_poSharedResource->IsUpdatable();
     245             :     }
     246             : 
     247          14 :     const std::string &IGetFullName() const override
     248             :     {
     249          14 :         return GetFullName();
     250             :     }
     251             : 
     252             :     // END: interfaces of TileDBAttributeHolder
     253             : 
     254             :   public:
     255             :     ~TileDBGroup() override;
     256             : 
     257             :     static std::shared_ptr<TileDBGroup>
     258             :     CreateOnDisk(const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     259             :                  const std::string &osParentName, const std::string &osName,
     260             :                  const std::string &osPath);
     261             : 
     262             :     static std::shared_ptr<TileDBGroup>
     263             :     OpenFromDisk(const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     264             :                  const std::string &osParentName, const std::string &osName,
     265             :                  const std::string &osPath);
     266             : 
     267          61 :     const std::string &GetPath() const
     268             :     {
     269          61 :         return m_osPath;
     270             :     }
     271             : 
     272             :     std::vector<std::string>
     273             :     GetMDArrayNames(CSLConstList papszOptions = nullptr) const override;
     274             : 
     275             :     std::vector<std::string>
     276             :     GetGroupNames(CSLConstList papszOptions = nullptr) const override;
     277             : 
     278             :     std::shared_ptr<GDALDimension>
     279             :     CreateDimension(const std::string &osName, const std::string &osType,
     280             :                     const std::string &osDirection, GUInt64 nSize,
     281             :                     CSLConstList) override;
     282             : 
     283             :     std::shared_ptr<GDALGroup>
     284             :     CreateGroup(const std::string &osName,
     285             :                 CSLConstList papszOptions = nullptr) override;
     286             : 
     287             :     std::shared_ptr<GDALGroup>
     288             :     OpenGroup(const std::string &osName,
     289             :               CSLConstList papszOptions = nullptr) const override;
     290             : 
     291             :     std::shared_ptr<GDALMDArray> CreateMDArray(
     292             :         const std::string &osName,
     293             :         const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
     294             :         const GDALExtendedDataType &oDataType,
     295             :         CSLConstList papszOptions = nullptr) override;
     296             : 
     297             :     std::shared_ptr<GDALMDArray>
     298             :     OpenMDArray(const std::string &osName,
     299             :                 CSLConstList papszOptions = nullptr) const override;
     300             : 
     301             :     bool AddMember(const std::string &osPath, const std::string &osName);
     302             : 
     303             :     std::shared_ptr<GDALAttribute>
     304             :     CreateAttribute(const std::string &osName,
     305             :                     const std::vector<GUInt64> &anDimensions,
     306             :                     const GDALExtendedDataType &oDataType,
     307             :                     CSLConstList papszOptions = nullptr) override;
     308             : 
     309             :     std::shared_ptr<GDALAttribute>
     310             :     GetAttribute(const std::string &osName) const override;
     311             : 
     312             :     std::vector<std::shared_ptr<GDALAttribute>>
     313             :     GetAttributes(CSLConstList papszOptions = nullptr) const override;
     314             : 
     315             :     bool DeleteAttribute(const std::string &osName,
     316             :                          CSLConstList papszOptions = nullptr) override;
     317             : };
     318             : 
     319             : /************************************************************************/
     320             : /*                          TileDBArray                                 */
     321             : /************************************************************************/
     322             : 
     323             : class TileDBArray final : public GDALMDArray, public TileDBAttributeHolder
     324             : {
     325             :     std::shared_ptr<TileDBSharedResource> m_poSharedResource{};
     326             :     const std::vector<std::shared_ptr<GDALDimension>> m_aoDims;
     327             :     const GDALExtendedDataType m_oType;
     328             :     const std::string m_osPath;
     329             :     std::vector<GUInt64> m_anBlockSize{};
     330             :     // Starting offset of each dimension (if not zero)
     331             :     std::vector<uint64_t> m_anStartDimOffset{};
     332             :     mutable bool m_bFinalized = true;
     333             :     mutable std::unique_ptr<tiledb::ArraySchema> m_poSchema{};
     334             : 
     335             :     std::string m_osAttrName{};  // (TileDB) attribute name
     336             :     mutable std::unique_ptr<tiledb::Attribute> m_poAttr{};
     337             :     mutable std::unique_ptr<tiledb::Array> m_poTileDBArray{};
     338             :     mutable std::vector<GByte> m_abyNoData{};
     339             :     std::shared_ptr<OGRSpatialReference> m_poSRS{};
     340             :     std::string m_osUnit{};
     341             :     bool m_bStats = false;
     342             : 
     343             :     // inclusive ending timestamp when opening this array
     344             :     uint64_t m_nTimestamp = 0;
     345             : 
     346             :     std::weak_ptr<TileDBGroup> m_poParent{};  // used for creation path
     347             :     std::string m_osParentPath{};             // used for creation path
     348             :     // used for creation path.
     349             :     // To keep a reference on the indexing variables in CreateOnDisk(),
     350             :     // so they are still alive at Finalize() time
     351             :     std::vector<std::shared_ptr<GDALMDArray>> m_apoIndexingVariables{};
     352             : 
     353             :     CPLStringList m_aosStructuralInfo{};
     354             : 
     355             :     TileDBArray(const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     356             :                 const std::string &osParentName, const std::string &osName,
     357             :                 const std::vector<std::shared_ptr<GDALDimension>> &aoDims,
     358             :                 const GDALExtendedDataType &oType, const std::string &osPath);
     359             : 
     360             :     static std::shared_ptr<TileDBArray>
     361             :     Create(const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     362             :            const std::string &osParentName, const std::string &osName,
     363             :            const std::vector<std::shared_ptr<GDALDimension>> &aoDims,
     364             :            const GDALExtendedDataType &oType, const std::string &osPath);
     365             : 
     366             :     bool Finalize() const;
     367             : 
     368             :   protected:
     369             :     bool IRead(const GUInt64 *arrayStartIdx, const size_t *count,
     370             :                const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
     371             :                const GDALExtendedDataType &bufferDataType,
     372             :                void *pDstBuffer) const override;
     373             : 
     374             :     bool IWrite(const GUInt64 *arrayStartIdx, const size_t *count,
     375             :                 const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
     376             :                 const GDALExtendedDataType &bufferDataType,
     377             :                 const void *pSrcBuffer) override;
     378             : 
     379             :     // BEGIN: interfaces of TileDBAttributeHolder
     380             : 
     381             :     bool EnsureOpenAs(tiledb_query_type_t mode) const override;
     382             : 
     383          40 :     uint64_t metadata_num() const override
     384             :     {
     385          40 :         return m_poTileDBArray->metadata_num();
     386             :     }
     387             : 
     388          51 :     void get_metadata_from_index(uint64_t index, std::string *key,
     389             :                                  tiledb_datatype_t *value_type,
     390             :                                  uint32_t *value_num,
     391             :                                  const void **value) const override
     392             :     {
     393          51 :         m_poTileDBArray->get_metadata_from_index(index, key, value_type,
     394             :                                                  value_num, value);
     395          51 :     }
     396             : 
     397          11 :     bool has_metadata(const std::string &key,
     398             :                       tiledb_datatype_t *value_type) const override
     399             :     {
     400          11 :         return m_poTileDBArray->has_metadata(key, value_type);
     401             :     }
     402             : 
     403          64 :     void get_metadata(const std::string &key, tiledb_datatype_t *value_type,
     404             :                       uint32_t *value_num, const void **value) const override
     405             :     {
     406          64 :         m_poTileDBArray->get_metadata(key, value_type, value_num, value);
     407          64 :     }
     408             : 
     409          10 :     void put_metadata(const std::string &key, tiledb_datatype_t value_type,
     410             :                       uint32_t value_num, const void *value) override
     411             :     {
     412          10 :         m_poTileDBArray->put_metadata(key, value_type, value_num, value);
     413          10 :     }
     414             : 
     415           0 :     void delete_metadata(const std::string &key) override
     416             :     {
     417           0 :         m_poTileDBArray->delete_metadata(key);
     418           0 :     }
     419             : 
     420             :     std::shared_ptr<TileDBAttributeHolder>
     421          61 :     AsAttributeHolderSharedPtr() const override
     422             :     {
     423          61 :         return std::dynamic_pointer_cast<TileDBAttributeHolder>(m_pSelf.lock());
     424             :     }
     425             : 
     426          22 :     bool IIsWritable() const override
     427             :     {
     428          22 :         return IsWritable();
     429             :     }
     430             : 
     431         132 :     const std::string &IGetFullName() const override
     432             :     {
     433         132 :         return GetFullName();
     434             :     }
     435             : 
     436             :     // END: interfaces of TileDBAttributeHolder
     437             : 
     438             :   public:
     439             :     ~TileDBArray() override;
     440             : 
     441             :     static std::shared_ptr<TileDBArray>
     442             :     OpenFromDisk(const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     443             :                  const std::shared_ptr<GDALGroup> &poParent,
     444             :                  const std::string &osParentName, const std::string &osName,
     445             :                  const std::string &osAttributeName, const std::string &osPath,
     446             :                  CSLConstList papszOptions);
     447             : 
     448             :     static std::shared_ptr<TileDBArray> CreateOnDisk(
     449             :         const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     450             :         const std::shared_ptr<TileDBGroup> &poParent, const std::string &osName,
     451             :         const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
     452             :         const GDALExtendedDataType &oDataType, CSLConstList papszOptions);
     453             : 
     454          53 :     bool IsWritable() const override
     455             :     {
     456          53 :         return m_poSharedResource->IsUpdatable();
     457             :     }
     458             : 
     459          61 :     const std::string &GetFilename() const override
     460             :     {
     461          61 :         return m_osPath;
     462             :     }
     463             : 
     464             :     const std::vector<std::shared_ptr<GDALDimension>> &
     465         490 :     GetDimensions() const override
     466             :     {
     467         490 :         return m_aoDims;
     468             :     }
     469             : 
     470         369 :     const GDALExtendedDataType &GetDataType() const override
     471             :     {
     472         369 :         return m_oType;
     473             :     }
     474             : 
     475          15 :     std::vector<GUInt64> GetBlockSize() const override
     476             :     {
     477          15 :         return m_anBlockSize;
     478             :     }
     479             : 
     480             :     const void *GetRawNoDataValue() const override;
     481             : 
     482             :     bool SetRawNoDataValue(const void *pRawNoData) override;
     483             : 
     484          10 :     std::shared_ptr<OGRSpatialReference> GetSpatialRef() const override
     485             :     {
     486          10 :         return m_poSRS;
     487             :     }
     488             : 
     489             :     bool SetSpatialRef(const OGRSpatialReference *poSRS) override;
     490             : 
     491           7 :     const std::string &GetUnit() const override
     492             :     {
     493           7 :         return m_osUnit;
     494             :     }
     495             : 
     496             :     bool SetUnit(const std::string &osUnit) override;
     497             : 
     498             :     CSLConstList GetStructuralInfo() const override;
     499             : 
     500             :     std::shared_ptr<GDALAttribute>
     501             :     CreateAttribute(const std::string &osName,
     502             :                     const std::vector<GUInt64> &anDimensions,
     503             :                     const GDALExtendedDataType &oDataType,
     504             :                     CSLConstList papszOptions = nullptr) override;
     505             : 
     506             :     std::shared_ptr<GDALAttribute>
     507             :     GetAttribute(const std::string &osName) const override;
     508             : 
     509             :     std::vector<std::shared_ptr<GDALAttribute>>
     510             :     GetAttributes(CSLConstList papszOptions = nullptr) const override;
     511             : 
     512             :     bool DeleteAttribute(const std::string &osName,
     513             :                          CSLConstList papszOptions = nullptr) override;
     514             :     static GDALDataType
     515             :     TileDBDataTypeToGDALDataType(tiledb_datatype_t tiledb_dt);
     516             : 
     517             :     static bool GDALDataTypeToTileDB(GDALDataType dt,
     518             :                                      tiledb_datatype_t &tiledb_dt);
     519             : };
     520             : 
     521             : /************************************************************************/
     522             : /*                       TileDBAttribute                                */
     523             : /************************************************************************/
     524             : 
     525             : // Caution: TileDBAttribute implements a GDAL multidim attribute, which
     526             : // in TileDB terminology maps to a TileDB metadata item.
     527             : class TileDBAttribute final : public GDALAttribute
     528             : {
     529             :     std::shared_ptr<GDALAttribute> m_poMemAttribute;
     530             :     std::weak_ptr<TileDBAttributeHolder> m_poParent;
     531             : 
     532             :     TileDBAttribute(const std::string &osParentName, const std::string &osName);
     533             : 
     534             :   protected:
     535             :     bool IRead(const GUInt64 *arrayStartIdx, const size_t *count,
     536             :                const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
     537             :                const GDALExtendedDataType &bufferDataType,
     538             :                void *pDstBuffer) const override;
     539             : 
     540             :     bool IWrite(const GUInt64 *arrayStartIdx, const size_t *count,
     541             :                 const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
     542             :                 const GDALExtendedDataType &bufferDataType,
     543             :                 const void *pSrcBuffer) override;
     544             : 
     545             :     const std::vector<std::shared_ptr<GDALDimension>> &
     546         150 :     GetDimensions() const override
     547             :     {
     548         150 :         return m_poMemAttribute->GetDimensions();
     549             :     }
     550             : 
     551         213 :     const GDALExtendedDataType &GetDataType() const override
     552             :     {
     553         213 :         return m_poMemAttribute->GetDataType();
     554             :     }
     555             : 
     556             :   public:
     557             :     static std::shared_ptr<GDALAttribute>
     558             :     Create(const std::shared_ptr<TileDBAttributeHolder> &poParent,
     559             :            const std::string &osName, const std::vector<GUInt64> &anDimensions,
     560             :            const GDALExtendedDataType &oDataType);
     561             : };
     562             : 
     563             : /************************************************************************/
     564             : /*                           TileDBDimension                            */
     565             : /************************************************************************/
     566             : 
     567             : class TileDBDimension final : public GDALDimension
     568             : {
     569             :     // OK as a shared_ptr rather a weak_ptr, given that for the use we make
     570             :     // of it, m_poIndexingVariable doesn't point to a TileDBDimension
     571             :     std::shared_ptr<GDALMDArray> m_poIndexingVariable{};
     572             : 
     573             :   public:
     574          77 :     TileDBDimension(const std::string &osParentName, const std::string &osName,
     575             :                     const std::string &osType, const std::string &osDirection,
     576             :                     GUInt64 nSize)
     577          77 :         : GDALDimension(osParentName, osName, osType, osDirection, nSize)
     578             :     {
     579          77 :     }
     580             : 
     581          29 :     std::shared_ptr<GDALMDArray> GetIndexingVariable() const override
     582             :     {
     583          29 :         return m_poIndexingVariable;
     584             :     }
     585             : 
     586          18 :     void SetIndexingVariableOneTime(
     587             :         const std::shared_ptr<GDALMDArray> &poIndexingVariable)
     588             :     {
     589          18 :         m_poIndexingVariable = poIndexingVariable;
     590          18 :     }
     591             : };
     592             : 
     593             : /************************************************************************/
     594             : /*                       TileDBArrayGroup                               */
     595             : /************************************************************************/
     596             : 
     597             : class TileDBArrayGroup final : public GDALGroup
     598             : {
     599             :     std::vector<std::shared_ptr<GDALMDArray>> m_apoArrays;
     600             : 
     601             :   public:
     602           2 :     explicit TileDBArrayGroup(
     603             :         const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays)
     604           2 :         : GDALGroup(std::string(), "/"), m_apoArrays(apoArrays)
     605             :     {
     606           2 :     }
     607             : 
     608             :     static std::shared_ptr<GDALGroup>
     609             :     Create(const std::shared_ptr<TileDBSharedResource> &poSharedResource,
     610             :            const std::string &osArrayPath);
     611             : 
     612             :     std::vector<std::string>
     613             :         GetMDArrayNames(CSLConstList /*papszOptions*/ = nullptr) const override;
     614             : 
     615             :     std::shared_ptr<GDALMDArray>
     616             :     OpenMDArray(const std::string &osName,
     617             :                 CSLConstList /*papszOptions*/ = nullptr) const override;
     618             : };
     619             : 
     620             : /************************************************************************/
     621             : /*                     TileDBMultiDimDataset                            */
     622             : /************************************************************************/
     623             : 
     624             : class TileDBMultiDimDataset final : public GDALDataset
     625             : {
     626             :     friend class TileDBDataset;
     627             : 
     628             :     std::shared_ptr<GDALGroup> m_poRG{};
     629             : 
     630             :   public:
     631          52 :     explicit TileDBMultiDimDataset(const std::shared_ptr<GDALGroup> &poRG)
     632          52 :         : m_poRG(poRG)
     633             :     {
     634          52 :     }
     635             : 
     636          55 :     std::shared_ptr<GDALGroup> GetRootGroup() const override
     637             :     {
     638          55 :         return m_poRG;
     639             :     }
     640             : };
     641             : 
     642             : #endif  // TILEDBMULTIDIM_H_INCLUDED

Generated by: LCOV version 1.14