3535
3636namespace deckgl {
3737
38+ // / \brief Utility structure that holds metadata of a generic list array.
3839struct ListArrayMetadata {
3940 public:
4041 ListArrayMetadata (int32_t offset, int32_t length, const std::shared_ptr<arrow::Array>& values)
@@ -45,36 +46,88 @@ struct ListArrayMetadata {
4546 std::shared_ptr<arrow::Array> values;
4647};
4748
49+ // / \brief Represents a single row within a given table, which can be queried for easy access to typed data.
4850class Row {
4951 public:
5052 Row (const std::shared_ptr<arrow::Table>& table, int64_t rowIndex);
5153
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.
5259 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.
5366 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.
5473 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.
5580 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.
5686 auto getString (const std::string& columnName, const std::string& defaultValue = " " ) const -> std::string;
5787
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.
5893 template <typename T>
5994 auto getVector2 (const std::string& columnName, const mathgl::Vector2<T>& defaultValue = {}) const
6095 -> mathgl::Vector2<T> {
6196 auto data = this ->getListData <T>(columnName, {defaultValue.x , defaultValue.y });
6297 return mathgl::Vector2<T>{data.size () > 0 ? data.at (0 ) : 0 , data.size () > 1 ? data.at (1 ) : 0 };
6398 }
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.
64105 template <typename T>
65106 auto getVector3 (const std::string& columnName, const mathgl::Vector3<T>& defaultValue = {}) const
66107 -> mathgl::Vector3<T> {
67108 auto data = this ->getListData <T>(columnName, {defaultValue.x , defaultValue.y , defaultValue.z });
68109 return mathgl::Vector3<T>{data.size () > 0 ? data.at (0 ) : 0 , data.size () > 1 ? data.at (1 ) : 0 ,
69110 data.size () > 2 ? data.at (2 ) : 0 };
70111 }
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.
71118 template <typename T>
72119 auto getVector4 (const std::string& columnName, const mathgl::Vector4<T>& defaultValue = {}) const
73120 -> mathgl::Vector4<T> {
74121 auto data = this ->getListData <T>(columnName, {defaultValue.x , defaultValue.y , defaultValue.z , defaultValue.w });
75122 return mathgl::Vector4<T>{data.size () > 0 ? data.at (0 ) : 0 , data.size () > 1 ? data.at (1 ) : 0 ,
76123 data.size () > 2 ? data.at (2 ) : 0 , data.size () > 3 ? data.at (3 ) : 0 };
77124 }
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.
78131 template <typename T>
79132 auto getVector2List (const std::string& columnName, const std::vector<mathgl::Vector2<T>>& defaultValue = {}) const
80133 -> std::vector<mathgl::Vector2<T>> {
@@ -87,6 +140,12 @@ class Row {
87140
88141 return vectorData;
89142 }
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.
90149 template <typename T>
91150 auto getVector3List (const std::string& columnName, const std::vector<mathgl::Vector3<T>>& defaultValue = {}) const
92151 -> std::vector<mathgl::Vector3<T>> {
@@ -100,6 +159,12 @@ class Row {
100159
101160 return vectorData;
102161 }
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.
103168 template <typename T>
104169 auto getVector4List (const std::string& columnName, const std::vector<mathgl::Vector4<T>>& defaultValue = {}) const
105170 -> std::vector<mathgl::Vector4<T>> {
@@ -113,6 +178,11 @@ class Row {
113178
114179 return vectorData;
115180 }
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.
116186 template <typename T>
117187 auto getListData (const std::string& columnName, const std::vector<T>& defaultValue = {}) const -> std::vector<T> {
118188 if (!this ->isValid (columnName)) {
@@ -128,6 +198,11 @@ class Row {
128198
129199 return this ->_getListData (optionalMetadata.value (), defaultValue);
130200 }
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.
131206 template <typename T>
132207 auto getNestedListData (const std::string& columnName, const std::vector<std::vector<T>>& defaultValue = {}) const
133208 -> std::vector<std::vector<T>> {
@@ -151,6 +226,7 @@ class Row {
151226 auto isValid (const std::string& columnName) const -> bool;
152227
153228 // / \brief Increments current row index.
229+ // / \param increment Amount to increment the current row index by.
154230 void incrementRowIndex (uint64_t increment = 1 );
155231
156232 private:
@@ -249,8 +325,6 @@ class Row {
249325
250326 // / \brief Relative row index in respect to the chunk.
251327 int64_t _chunkRowIndex;
252-
253- // std::unordered_map<std::string, std::shared_ptr<arrow::Array>> _cache;
254328};
255329
256330} // namespace deckgl
0 commit comments