LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/arrow_common - ograrrowdataset.hpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 26 26 100.0 %
Date: 2024-05-13 13:33:37 Functions: 7 7 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  Arrow generic code
       4             :  * Purpose:  Arrow generic code
       5             :  * Author:   Even Rouault, <even.rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2022, Planet Labs
       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 OGARROWDATASET_HPP_INCLUDED
      30             : #define OGARROWDATASET_HPP_INCLUDED
      31             : 
      32             : #include "ogr_arrow.h"
      33             : 
      34             : /************************************************************************/
      35             : /*                         OGRArrowDataset()                            */
      36             : /************************************************************************/
      37             : 
      38        1223 : inline OGRArrowDataset::OGRArrowDataset(
      39        1223 :     const std::shared_ptr<arrow::MemoryPool> &poMemoryPool)
      40        1223 :     : m_poMemoryPool(poMemoryPool)
      41             : {
      42        1223 : }
      43             : 
      44             : /************************************************************************/
      45             : /*                            SetLayer()                                */
      46             : /************************************************************************/
      47             : 
      48        1220 : inline void OGRArrowDataset::SetLayer(std::unique_ptr<OGRArrowLayer> &&poLayer)
      49             : {
      50        1220 :     m_poLayer = std::move(poLayer);
      51        1220 : }
      52             : 
      53             : /************************************************************************/
      54             : /*                          RegisterDomainName()                        */
      55             : /************************************************************************/
      56             : 
      57         202 : inline void OGRArrowDataset::RegisterDomainName(const std::string &osDomainName,
      58             :                                                 int iFieldIndex)
      59             : {
      60         202 :     m_aosDomainNames.push_back(osDomainName);
      61         202 :     m_oMapDomainNameToCol[osDomainName] = iFieldIndex;
      62         202 : }
      63             : 
      64             : /************************************************************************/
      65             : /*                          GetFieldDomainNames()                       */
      66             : /************************************************************************/
      67             : 
      68             : inline std::vector<std::string>
      69          15 : OGRArrowDataset::GetFieldDomainNames(CSLConstList) const
      70             : {
      71          15 :     return m_aosDomainNames;
      72             : }
      73             : 
      74             : /************************************************************************/
      75             : /*                          GetFieldDomain()                            */
      76             : /************************************************************************/
      77             : 
      78             : inline const OGRFieldDomain *
      79          72 : OGRArrowDataset::GetFieldDomain(const std::string &name) const
      80             : {
      81             :     {
      82          72 :         const auto iter = m_oMapFieldDomains.find(name);
      83          72 :         if (iter != m_oMapFieldDomains.end())
      84          25 :             return iter->second.get();
      85             :     }
      86          47 :     const auto iter = m_oMapDomainNameToCol.find(name);
      87          47 :     if (iter == m_oMapDomainNameToCol.end())
      88          15 :         return nullptr;
      89             :     return m_oMapFieldDomains
      90          64 :         .insert(std::pair(name, m_poLayer->BuildDomain(name, iter->second)))
      91          32 :         .first->second.get();
      92             : }
      93             : 
      94             : /************************************************************************/
      95             : /*                           GetLayerCount()                            */
      96             : /************************************************************************/
      97             : 
      98         651 : inline int OGRArrowDataset::GetLayerCount()
      99             : {
     100         651 :     return m_poLayer ? 1 : 0;
     101             : }
     102             : 
     103             : /************************************************************************/
     104             : /*                             GetLayer()                               */
     105             : /************************************************************************/
     106             : 
     107        1512 : inline OGRLayer *OGRArrowDataset::GetLayer(int idx)
     108             : {
     109        1512 :     return idx == 0 ? m_poLayer.get() : nullptr;
     110             : }
     111             : 
     112             : #endif /* OGARROWDATASET_HPP_INCLUDED */

Generated by: LCOV version 1.14