| Crates.io | ptars |
| lib.rs | ptars |
| version | 0.0.9 |
| created_at | 2025-12-23 12:39:34.069898+00 |
| updated_at | 2025-12-30 11:27:36.107274+00 |
| description | Fast conversion from protobuf to Apache Arrow and back |
| homepage | https://github.com/0x26res/ptars |
| repository | https://github.com/0x26res/ptars |
| max_upload_size | |
| id | 2001443 |
| size | 277,522 |
Fast conversion between Protocol Buffers and Apache Arrow in Rust.
RecordBatchRecordBatch back to serialized protobuf messagesgoogle.protobuf.Timestamp → timestamp[ns]google.type.Date → date32google.type.TimeOfDay → time64[ns]DoubleValue, Int32Value, etc.) → nullable primitivesAdd to your Cargo.toml:
[dependencies]
ptars = "0.0.9"
prost-reflect = "0.16"
use ptars::messages_to_record_batch;
use prost_reflect::{DescriptorPool, DynamicMessage};
// Load your protobuf descriptor
let pool = DescriptorPool::decode(include_bytes!("descriptor.bin").as_ref()).unwrap();
let message_descriptor = pool.get_message_by_name("my.package.MyMessage").unwrap();
// Create some messages
let mut msg = DynamicMessage::new(message_descriptor.clone());
msg.set_field_by_name("id", prost_reflect::Value::I32(42));
msg.set_field_by_name("name", prost_reflect::Value::String("example".into()));
let messages = vec![msg];
// Convert to Arrow RecordBatch
let record_batch = messages_to_record_batch(&messages, &message_descriptor);
If you have serialized protobuf messages in an Arrow BinaryArray:
use ptars::binary_array_to_record_batch;
use arrow_array::BinaryArray;
let binary_array: BinaryArray = /* your serialized messages */;
let record_batch = binary_array_to_record_batch(&binary_array, &message_descriptor).unwrap();
use ptars::record_batch_to_array;
// Convert RecordBatch to a BinaryArray of serialized messages
let binary_array = record_batch_to_array(&record_batch, &message_descriptor);
// Decode individual messages
for i in 0..binary_array.len() {
let msg = DynamicMessage::decode(message_descriptor.clone(), binary_array.value(i)).unwrap();
}
Apache-2.0