Debian Codegraph @

ogr/ogrsf_frmts/arrow_common/ograrrowdataset.hpp

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