jecsand838 commented on code in PR #8274:
URL: https://github.com/apache/arrow-rs/pull/8274#discussion_r2322649671
##########
arrow-avro/src/writer/mod.rs:
##########
@@ -63,19 +66,42 @@ impl WriterBuilder {
self
}
+ /// Sets the capacity for the given object and returns the modified
instance.
+ pub fn with_capacity(mut self, capacity: usize) -> Self {
+ self.capacity = capacity;
+ self
+ }
+
/// Create a new `Writer` with specified `AvroFormat` and builder options.
- pub fn build<W, F>(self, writer: W) -> Writer<W, F>
+ /// Performs oneātime startup (header/stream init, encoder plan).
+ pub fn build<W, F>(self, mut writer: W) -> Result<Writer<W, F>, ArrowError>
where
W: Write,
F: AvroFormat,
{
- Writer {
+ let mut format = F::default();
+ let avro_schema = if let Some(json) =
self.schema.metadata.get(SCHEMA_METADATA_KEY) {
+ AvroSchema::new(json.clone())
+ } else {
+ AvroSchema::try_from(&self.schema)?
+ };
Review Comment:
That is much cleaner and idiomatic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]