35
35
36
36
namespace deckgl {
37
37
38
+ // / \brief Utility structure that holds metadata of a generic list array.
38
39
struct ListArrayMetadata {
39
40
public:
40
41
ListArrayMetadata (int32_t offset, int32_t length, const std::shared_ptr<arrow::Array>& values)
@@ -45,36 +46,88 @@ struct ListArrayMetadata {
45
46
std::shared_ptr<arrow::Array> values;
46
47
};
47
48
49
+ // / \brief Represents a single row within a given table, which can be queried for easy access to typed data.
48
50
class Row {
49
51
public:
50
52
Row (const std::shared_ptr<arrow::Table>& table, int64_t rowIndex);
51
53
54
+ // / \brief Attempts to get an integer value in this row, for a given columnName.
55
+ // / If the value is of a different type, best effort will be used to convert it to an integer.
56
+ // / \param columnName Name of the column to get the data for.
57
+ // / \param defaultValue Default value that'll be returned if data could not be found.
58
+ // / \returns Integer value found in this row for the given columnName, or defaultValue if one isn't found.
52
59
auto getInt (const std::string& columnName, int defaultValue = 0 ) const -> int;
60
+
61
+ // / \brief Attempts to get a float value in this row, for a given columnName.
62
+ // / If the value is of a different type, best effort will be used to convert it to a float.
63
+ // / \param columnName Name of the column to get the data for.
64
+ // / \param defaultValue Default value that'll be returned if data could not be found.
65
+ // / \returns Float value found in this row for the given columnName, or defaultValue if one isn't found.
53
66
auto getFloat (const std::string& columnName, float defaultValue = 0.0 ) const -> float;
67
+
68
+ // / \brief Attempts to get a double value in this row, for a given columnName.
69
+ // / If the value is of a different type, best effort will be used to convert it to a double.
70
+ // / \param columnName Name of the column to get the data for.
71
+ // / \param defaultValue Default value that'll be returned if data could not be found.
72
+ // / \returns Double value found in this row for the given columnName, or defaultValue if one isn't found.
54
73
auto getDouble (const std::string& columnName, double defaultValue = 0.0 ) const -> double;
74
+
75
+ // / \brief Attempts to get a boolean value in this row, for a given columnName.
76
+ // / If the value is of a different type, best effort will be used to convert it to a boolean.
77
+ // / \param columnName Name of the column to get the data for.
78
+ // / \param defaultValue Default value that'll be returned if data could not be found.
79
+ // / \returns Boolean value found in this row for the given columnName, or defaultValue if one isn't found.
55
80
auto getBool (const std::string& columnName, bool defaultValue = false ) const -> bool;
81
+
82
+ // / \brief Attempts to get a string value in this row, for a given columnName.
83
+ // / \param columnName Name of the column to get the data for.
84
+ // / \param defaultValue Default value that'll be returned if data could not be found.
85
+ // / \returns String value found in this row for the given columnName, or defaultValue if one isn't found.
56
86
auto getString (const std::string& columnName, const std::string& defaultValue = " " ) const -> std::string;
57
87
88
+ // / \brief Attempts to get vector data out of a list array found in this row, for a given columnName.
89
+ // / \param columnName Name of the column to get the data for.
90
+ // / \param defaultValue Default value that'll be returned if data could not be found.
91
+ // / \returns Vector data, potentially padded with zeros if the list was not of a sufficient length,
92
+ // / or defaultValue if data could not be found.
58
93
template <typename T>
59
94
auto getVector2 (const std::string& columnName, const mathgl::Vector2<T>& defaultValue = {}) const
60
95
-> mathgl::Vector2<T> {
61
96
auto data = this ->getListData <T>(columnName, {defaultValue.x , defaultValue.y });
62
97
return mathgl::Vector2<T>{data.size () > 0 ? data.at (0 ) : 0 , data.size () > 1 ? data.at (1 ) : 0 };
63
98
}
99
+
100
+ // / \brief Attempts to get vector data out of a list array found in this row, for a given columnName.
101
+ // / \param columnName Name of the column to get the data for.
102
+ // / \param defaultValue Default value that'll be returned if data could not be found.
103
+ // / \returns Vector data, potentially padded with zeros if the list was not of a sufficient length,
104
+ // / or defaultValue if data could not be found.
64
105
template <typename T>
65
106
auto getVector3 (const std::string& columnName, const mathgl::Vector3<T>& defaultValue = {}) const
66
107
-> mathgl::Vector3<T> {
67
108
auto data = this ->getListData <T>(columnName, {defaultValue.x , defaultValue.y , defaultValue.z });
68
109
return mathgl::Vector3<T>{data.size () > 0 ? data.at (0 ) : 0 , data.size () > 1 ? data.at (1 ) : 0 ,
69
110
data.size () > 2 ? data.at (2 ) : 0 };
70
111
}
112
+
113
+ // / \brief Attempts to get vector data out of a list array found in this row, for a given columnName.
114
+ // / \param columnName Name of the column to get the data for.
115
+ // / \param defaultValue Default value that'll be returned if data could not be found.
116
+ // / \returns Vector data, potentially padded with zeros if the list was not of a sufficient length,
117
+ // / or defaultValue if data could not be found.
71
118
template <typename T>
72
119
auto getVector4 (const std::string& columnName, const mathgl::Vector4<T>& defaultValue = {}) const
73
120
-> mathgl::Vector4<T> {
74
121
auto data = this ->getListData <T>(columnName, {defaultValue.x , defaultValue.y , defaultValue.z , defaultValue.w });
75
122
return mathgl::Vector4<T>{data.size () > 0 ? data.at (0 ) : 0 , data.size () > 1 ? data.at (1 ) : 0 ,
76
123
data.size () > 2 ? data.at (2 ) : 0 , data.size () > 3 ? data.at (3 ) : 0 };
77
124
}
125
+
126
+ // / \brief Attempts to get a set of vector data out of a nested list array found in this row, for a given columnName.
127
+ // / \param columnName Name of the column to get the data for.
128
+ // / \param defaultValue Default value that'll be returned if data could not be found.
129
+ // / \returns A collection of vector data, potentially padded with zeros if the list was not of a sufficient length,
130
+ // / or defaultValue if data could not be found.
78
131
template <typename T>
79
132
auto getVector2List (const std::string& columnName, const std::vector<mathgl::Vector2<T>>& defaultValue = {}) const
80
133
-> std::vector<mathgl::Vector2<T>> {
@@ -87,6 +140,12 @@ class Row {
87
140
88
141
return vectorData;
89
142
}
143
+
144
+ // / \brief Attempts to get a set of vector data out of a nested list array found in this row, for a given columnName.
145
+ // / \param columnName Name of the column to get the data for.
146
+ // / \param defaultValue Default value that'll be returned if data could not be found.
147
+ // / \returns A collection of vector data, potentially padded with zeros if the list was not of a sufficient length,
148
+ // / or defaultValue if data could not be found.
90
149
template <typename T>
91
150
auto getVector3List (const std::string& columnName, const std::vector<mathgl::Vector3<T>>& defaultValue = {}) const
92
151
-> std::vector<mathgl::Vector3<T>> {
@@ -100,6 +159,12 @@ class Row {
100
159
101
160
return vectorData;
102
161
}
162
+
163
+ // / \brief Attempts to get a set of vector data out of a nested list array found in this row, for a given columnName.
164
+ // / \param columnName Name of the column to get the data for.
165
+ // / \param defaultValue Default value that'll be returned if data could not be found.
166
+ // / \returns A collection of vector data, potentially padded with zeros if the list was not of a sufficient length,
167
+ // / or defaultValue if data could not be found.
103
168
template <typename T>
104
169
auto getVector4List (const std::string& columnName, const std::vector<mathgl::Vector4<T>>& defaultValue = {}) const
105
170
-> std::vector<mathgl::Vector4<T>> {
@@ -113,6 +178,11 @@ class Row {
113
178
114
179
return vectorData;
115
180
}
181
+
182
+ // / \brief Attempts to get a variable sized collection of arbitrary data.
183
+ // / \param columnName Name of the column to get the data for.
184
+ // / \param defaultValue Default value that'll be returned if data could not be found.
185
+ // / \returns A collection of requested data type, or defaultValue if data could not be found.
116
186
template <typename T>
117
187
auto getListData (const std::string& columnName, const std::vector<T>& defaultValue = {}) const -> std::vector<T> {
118
188
if (!this ->isValid (columnName)) {
@@ -128,6 +198,11 @@ class Row {
128
198
129
199
return this ->_getListData (optionalMetadata.value (), defaultValue);
130
200
}
201
+
202
+ // / \brief Attempts to get a nested, variable sized collection of arbitrary data.
203
+ // / \param columnName Name of the column to get the data for.
204
+ // / \param defaultValue Default value that'll be returned if data could not be found.
205
+ // / \returns A collection of requested data type, or defaultValue if data could not be found.
131
206
template <typename T>
132
207
auto getNestedListData (const std::string& columnName, const std::vector<std::vector<T>>& defaultValue = {}) const
133
208
-> std::vector<std::vector<T>> {
@@ -151,6 +226,7 @@ class Row {
151
226
auto isValid (const std::string& columnName) const -> bool;
152
227
153
228
// / \brief Increments current row index.
229
+ // / \param increment Amount to increment the current row index by.
154
230
void incrementRowIndex (uint64_t increment = 1 );
155
231
156
232
private:
@@ -249,8 +325,6 @@ class Row {
249
325
250
326
// / \brief Relative row index in respect to the chunk.
251
327
int64_t _chunkRowIndex;
252
-
253
- // std::unordered_map<std::string, std::shared_ptr<arrow::Array>> _cache;
254
328
};
255
329
256
330
} // namespace deckgl
0 commit comments