avantgardnerio commented on code in PR #4294:
URL: https://github.com/apache/arrow-rs/pull/4294#discussion_r1209439535


##########
arrow-flight/src/lib.rs:
##########
@@ -433,24 +464,45 @@ impl FlightDescriptor {
 }
 
 impl FlightInfo {
-    /// Create a new [`FlightInfo`] that describes the access
-    /// coordinates for retrieval of a dataset.
-    pub fn new(
-        message: IpcMessage,
-        flight_descriptor: Option<FlightDescriptor>,
-        endpoint: Vec<FlightEndpoint>,
-        total_records: i64,
-        total_bytes: i64,
-        ordered: bool,
-    ) -> Self {
-        let IpcMessage(vals) = message;
+    /// Create a new, empty `FlightInfo`, describing where to fetch flight data
+    ///
+    ///
+    /// # Example:
+    /// ```
+    /// # use arrow_flight::{FlightInfo, Ticket, FlightDescriptor, 
FlightEndpoint};
+    /// # use arrow_schema::{Schema, Field, DataType};
+    /// # fn get_schema() -> Schema {
+    /// #   Schema::new(vec![
+    /// #     Field::new("a", DataType::Utf8, false),
+    /// #   ])
+    /// # }
+    /// #
+    /// // Create a new FlightInfo
+    /// let flight_info = FlightInfo::new()
+    ///   // Encode the Arrow schema
+    ///   .with_schema(&get_schema())
+    ///   .expect("encoding failed")
+    ///   .with_descriptor(
+    ///      FlightDescriptor::new_cmd("a command")
+    ///   )
+    ///   .with_endpoint(
+    ///      FlightEndpoint::new()
+    ///        .with_ticket(Ticket::new("ticket contents")
+    ///      )
+    ///    )
+    ///   .with_descriptor(FlightDescriptor::new_cmd("RUN QUERY"));
+    /// ```
+    pub fn new() -> FlightInfo {
         FlightInfo {
-            schema: vals,
-            flight_descriptor,
-            endpoint,
-            total_records,
-            total_bytes,
-            ordered,
+            schema: Bytes::new(),
+            flight_descriptor: None,
+            endpoint: vec![],
+            ordered: false,
+            // Flight says "Set these to -1 if unknown."
+            //
+            // 
https://github.com/apache/arrow-rs/blob/17ca4d51d0490f9c65f5adde144f677dbc8300e7/format/Flight.proto#L287-L289

Review Comment:
   Love this doc link, thank you for that



-- 
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]

Reply via email to