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 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef OGARROWDATASET_HPP_INCLUDED 14 : #define OGARROWDATASET_HPP_INCLUDED 15 : 16 : #include "ogr_arrow.h" 17 : 18 : /************************************************************************/ 19 : /* OGRArrowDataset() */ 20 : /************************************************************************/ 21 : 22 1711 : inline OGRArrowDataset::OGRArrowDataset( 23 1711 : const std::shared_ptr<arrow::MemoryPool> &poMemoryPool) 24 1711 : : m_poMemoryPool(poMemoryPool) 25 : { 26 1711 : } 27 : 28 : /************************************************************************/ 29 : /* SetLayer() */ 30 : /************************************************************************/ 31 : 32 1707 : inline void OGRArrowDataset::SetLayer(std::unique_ptr<IOGRArrowLayer> &&poLayer) 33 : { 34 1707 : m_poLayer = std::move(poLayer); 35 1707 : } 36 : 37 : /************************************************************************/ 38 : /* RegisterDomainName() */ 39 : /************************************************************************/ 40 : 41 407 : inline void OGRArrowDataset::RegisterDomainName(const std::string &osDomainName, 42 : int iFieldIndex) 43 : { 44 407 : m_aosDomainNames.push_back(osDomainName); 45 407 : m_oMapDomainNameToCol[osDomainName] = iFieldIndex; 46 407 : } 47 : 48 : /************************************************************************/ 49 : /* GetFieldDomainNames() */ 50 : /************************************************************************/ 51 : 52 : inline std::vector<std::string> 53 15 : OGRArrowDataset::GetFieldDomainNames(CSLConstList) const 54 : { 55 15 : return m_aosDomainNames; 56 : } 57 : 58 : /************************************************************************/ 59 : /* GetFieldDomain() */ 60 : /************************************************************************/ 61 : 62 : inline const OGRFieldDomain * 63 76 : OGRArrowDataset::GetFieldDomain(const std::string &name) const 64 : { 65 : { 66 76 : const auto iter = m_oMapFieldDomains.find(name); 67 76 : if (iter != m_oMapFieldDomains.end()) 68 26 : return iter->second.get(); 69 : } 70 50 : const auto iter = m_oMapDomainNameToCol.find(name); 71 50 : if (iter == m_oMapDomainNameToCol.end()) 72 15 : return nullptr; 73 : return m_oMapFieldDomains 74 35 : .insert( 75 105 : std::pair(name, m_poLayer->GetUnderlyingArrowLayer()->BuildDomain( 76 105 : name, iter->second))) 77 35 : .first->second.get(); 78 : } 79 : 80 : /************************************************************************/ 81 : /* GetLayerCount() */ 82 : /************************************************************************/ 83 : 84 772 : inline int OGRArrowDataset::GetLayerCount() const 85 : { 86 772 : return m_poLayer ? 1 : 0; 87 : } 88 : 89 : /************************************************************************/ 90 : /* GetLayer() */ 91 : /************************************************************************/ 92 : 93 2071 : inline const OGRLayer *OGRArrowDataset::GetLayer(int idx) const 94 : { 95 2071 : return idx == 0 ? m_poLayer->GetLayer() : nullptr; 96 : } 97 : 98 : #endif /* OGARROWDATASET_HPP_INCLUDED */