Partially reading in array of arrays where different arrays can be of different types. #1463
-
When reading in some json data which represents some values in columnar format we can have some schema struct for deciphering how to parse the data. For example: {
"schema": [
{"id": "col0", "dataType": "string"},
{"id": "col1", "dataType": "int"},
{"id": "col2", "dataType": "float"}
],
"data": [
["row0", "row1", "row2"],
[100, 200, 300],
[1.5, 2.5, 3.5]
]
} This then needs to be loaded into some struct based on the schema specified. Is there a clever way to perform this style of partial reading without the #1019 implementation. I understand I could load it into a variant but then I would have to either copy it out to different vectors or use a visitor both of which is a bit of a waste. Since the number of rows here can be fairly large only allocating what we need without the need for copy would be ideal. Would be happy for some help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Glaze supports partial reading in a few ways, see documentation: Partial Read So, I would suggest creating a struct for your schema and do a partial read into that. Then based on the schema, configure your data structure and do a partial read on the input into your data. |
Beta Was this translation helpful? Give feedback.
It would be good to be able to target a specific range of values. This really demands another query syntax. I want to add support for JMESPATH, but that is a long term goal.
I wouldn't be afraid of
glz::json_t
(which uses a variant underneath) for handling generic inputs. Also, if you're afraid of copying your vectors then simply callstd::move
after the generic parse, this will avoid the copy and give you generic behavior.