Replies: 3 comments 2 replies
-
@phil-opp @haixuanTao hope this is aligned with the ROS bridge efforts ongoing such that Dora user could specify data types between dataflow nodes |
Beta Was this translation helpful? Give feedback.
-
So maybe for reference, One of the key value of dora is to be performant. One of the reason of using arrow is to use zero-copy messages as it implement a well defined data memory layout that can be used across languages without copy. Issues of serialization deserialisation is:
This is why we're trying to use Apache Arrow as a cross-language data format. I think that you mention YAML as an example, but, for the sake of clarity for future readers, I don't think we can use YAML as a performant way of exchanging data. |
Beta Was this translation helpful? Give feedback.
-
I don't understand the question. Doesn't Dora now use arrow for data exchange |
Beta Was this translation helpful? Give feedback.
-
Implement support for primitive data types
Data type comparison between yaml and many other languages
Here is a table comparing the data types supported by YAML and several programming languages:
Note that this table is not exhaustive and some programming languages may support additional data types beyond those listed here. Additionally, the data types listed for each programming language may not be an exact match for those supported by YAML, but are meant to provide a rough comparison.
YAML supports multiple data types, including:
In addition to the basic data types mentioned above, YAML also supports some extended data types, such as dates, times, regular expressions, binary data, and more. These extended data types can be identified using specific tags, such as
!date
,!time
,!regex
,!binary
, and so on.Here is a list of the data types supported by YAML:
Note that the support for these data types may vary depending on the implementation of the YAML parser and the specific version of the YAML specification being used.
Implementation examples of yaml parsing in different languages
1. How to parse YAML data types using Rust
To parse YAML data types in Rust, you can use YAML libraries such as serde_yaml.
First, you need to add serde and serde_yaml to your project dependencies. Add the following lines to your
Cargo.toml
file:Then, you can use the
serde_yaml::from_str
function to parse a YAML string into a Rust struct. For example, assuming you have the following YAML data:You can define a corresponding Rust struct to represent this data:
Now, you can use the
serde_yaml::from_str
function to parse the YAML string into aPerson
struct:The output will be:
You can modify the Rust struct and the YAML data as needed to fit your requirements. Note that you need to match the fields of the Rust struct with the keys of the YAML data, otherwise the parsing will fail.
2. How to parse YAML data types using Python
To parse YAML data types in Python, you can use the PyYAML library.
First, you need to install PyYAML. You can do this by running the following command:
Then, you can use the
yaml.load
function to parse a YAML string into a Python data type. For example, assuming you have the following YAML data:You can use the following code to parse it into a Python dictionary:
The output will be:
You can modify the Python data and the YAML data as needed to fit your requirements. Note that when using the
yaml.load
function, you need to be careful because it can execute arbitrary code, so you should not pass unknown or untrusted YAML data to it.3. How to parse YAML data types using C/C++
To parse YAML data types in C/C++, you can use the libyaml library.
First, you need to install the libyaml library. You can do this by running the following command on Linux:
Then, you can use the following code to parse a YAML file into C/C++ data types. Assuming you have the following YAML data:
You can use the following code to parse it into a C/C++ struct:
The output will be:
You can modify the C/C++ struct and the YAML data as needed to fit your requirements. Note that when using the libyaml library, you need to be careful because it can execute arbitrary code, so you should not pass unknown or untrusted YAML data to it.
4. How to parse YAML data types using Golang
Here is a simplified example program to parse YAML data and output it to the console:
go get gopkg.in/yaml.v3
You can use the following code to parse it into a Golang struct:
The output will be:
You can modify the Golang struct and the YAML data as needed to fit your requirements. Note that when using the "gopkg.in/yaml.v3" package, you need to be careful because it can execute arbitrary code, so you should not pass unknown or untrusted YAML data to it.
Use apache arrow to realize type conversion between yaml and multiple languages
Apache Arrow is a cross-language, in-memory data structure that enables efficient data exchange between multiple programming languages. While Apache Arrow is not itself a data serialization format, it provides a unified data model that makes it easy to convert data types between different programming languages, including YAML.
With Apache Arrow, you can convert your data into Arrow format and then share and manipulate that data across different programming languages without the need for manual type conversions or complex serialization and deserialization code. In fact, many programming languages already support the Arrow format, including C/C++, Python, Rust, Golang, and Java, among others. Therefore, if your application involves data exchange between multiple programming languages, Apache Arrow may be a good choice.
![image](https://private-user-images.githubusercontent.com/11570442/252307761-c2c18f88-dbd5-46f8-b0c5-d68dfb3f0ae8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTc5NDQsIm5iZiI6MTczOTUxNzY0NCwicGF0aCI6Ii8xMTU3MDQ0Mi8yNTIzMDc3NjEtYzJjMThmODgtZGJkNS00NmY4LWIwYzUtZDY4ZGZiM2YwYWU4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDA3MjA0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlhYWMwNmIxMTg2ODExZjMzNDUxNjNmM2JjMWE5NDA3MDUyMDk3ZmUyYWNhZmJhNDBkNDNhNTNhM2ZiYjE3ZDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.I536Xp3qcn3wT122m7k1I6bGLrKhxwUz3Hav2OCumyE)
Beta Was this translation helpful? Give feedback.
All reactions