-
Notifications
You must be signed in to change notification settings - Fork 20
Conversation
Thanks for making the change! First of all, sorry for the long and funky tests in Looks good, I have a couple questions though. Now With the current approach we can map |
Another thing - should we rename |
Thanks for taking a look @sadikovi .
Only
The mapping can still happen at the
I'm debating on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it makes sense. It was a bit difficult for me to see it coming together in two separate PRs. As long as we can map Row
enum and fields to something and get values, it is good.
Agree, we should just call it Field
.
I left some minor comments. And sorry again for all those tests that you need to update.
src/record/api.rs
Outdated
fields: Vec<(String, RowField)> | ||
} | ||
|
||
pub fn make_row(fields: Vec<(String, RowField)>) -> Row { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some doc to the function? Thanks.
Would it be better to keep it as macro, since it is used in different places? Would it be inlined? If so, then it is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll mark it inline and document it.
mod triplet; | ||
|
||
pub use self::api::Row; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we export RowField
as well or will it work with just Row
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not expose RowField
(or Field
). For primitive types, the getters will return Rust native types, such as i32
, bool
etc. We also need to define and expose clean-defined interfaces for array and map. The former should also have getters like getBoolean(rowIndex: usize)
to return the value at a particular row, and the latter should have something like getKeys()
, getValues()
, etc.
I'll take a further look into this. It seems rather verbose if we have to define getXXX
for every data type on struct, array, etc. I wonder if there's a cleaner way to do it.
@@ -297,7 +298,24 @@ impl Reader { | |||
|
|||
/// Reads current record as `Row` from the reader tree. | |||
/// Automatically advances all necessary readers. | |||
/// This must be called on the root level reader (i.e., for Message type). | |||
/// Otherwise, it will panic. | |||
fn read(&mut self) -> Row { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do we call read
? I am just a bit confused:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The read
is called on next()
for both RowIter
and ReaderIter
.
src/record/api.rs
Outdated
List(Vec<Row>), // List of elements | ||
Map(Vec<(Row, Row)>) // List of key-value pairs | ||
Group(Row), // Struct, child elements are tuples of field-value pairs | ||
List(Vec<RowField>), // List of elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess when it is list of structs, it will be List(Group(Row), Group(Row), ...)
. Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it will be something like List(Vec(Group(Row), Group(Row),...))
, and the array interface that I proposed above should have something like getStruct(rowIndex)
which will return a Row
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks.
Would it be beneficial to also make List
and Map
separate, similar to Row
, so they can define their own set of methods to get length, elements by index, keys and values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about to replace List<Vec<Row>>
to something like List<Array>
(we'll need better naming on this) where the Array
implements the public APIs. Similar for Map<Vec<Row, Row>>
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember you suggested this some time ago. Yes, sounds like a good idea. You could consider calling them Struct
, Array
, Map
, Field
, and we would return Struct
for a top-level record, so it aligns with get_struct
, get_array
, and get_map
methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I guess, all TODOs will be fixed as part of field accessors work that is open right now.
Can you add docs for Map and List and rebase? Thanks!
Yes all the TODOs will be fixed later. Will add doc for Map & List, and rebase. Thanks |
This breaks the `Row` struct into two parts: a `RowField` which represent a single field in a row, and a top-level `Row` struct which represents the value for a message or struct type. Only the latter is exposed as public API.
Merged. Thanks @sadikovi ! |
@sunchao No worries, thanks for the changes. |
This breaks the
Row
struct into two parts: aRowField
which represent a single field in a row, and a top-level
Row
struct which represents the value for a message or struct type.
Only the latter is exposed as public API.