fn deserialize<D>(deserializer: D) -> Result<Block, D::Error>
    where
        D: de::Deserializer<'de>,
    {
        let helper: Value = Deserialize::deserialize(deserializer)?;
        let tuple = (
            decode_value(helper.get("schema")),
            decode_value(helper.get("records")),
        );

        match tuple {
            (Some(schema), Some(records)) => {
                // We have to make sure that this is safe
                // TODO(magrund)
                let fbs_schema = ipc::get_size_prefixed_root_as_message(&schema[4..]);
                let fbs_records = ipc::get_size_prefixed_root_as_message(&records[4..]);

                if fbs_schema.header_type() == MessageHeader::Schema {
                    if let Some(fbs_schema) = fbs_schema.header_as_schema() {
                        let ss = ipc::convert::fb_to_schema(fbs_schema);

                        if fbs_records.header_type() == MessageHeader::RecordBatch {
                            let body_length = fbs_records.bodyLength();

                            if let Some(fbs_records) = fbs_records.header_as_record_batch() {
                                // Read fom the record batch
                                let x = rr::read_record_batch(
                                    &records[records.len() - body_length as usize..],
                                    fbs_records,
                                    Arc::new(ss),
                                );
                                if let Ok(Some(x)) = x {
                                    return Ok(Block::new(
                                        x,
                                        helper.get("schema").unwrap().as_str().unwrap().to_string(),
                                        helper
                                            .get("records")
                                            .unwrap()
                                            .as_str()
                                            .unwrap()
                                            .to_string(),
                                        helper.get("aId").unwrap().as_str().unwrap().to_string(),
                                    ));
                                }
                            }
                        }
                    }
                }
                return Err(D::Error::custom("Missing field `schema` in Block"));
            }
            (_, _) => return Err(D::Error::custom("Missing field `schema` in Block")),
        }
    }
/// Custom implementation to deserialize a Block from a given JSON record. First, we
/// extract the JSON string values from the known keys, then we convert them to binary
/// by base64 decoding them. Finally, we extract the Schema and RecordBatch messages and
/// deserialize them into the Arrow Array types.
Custom implementation to deserialize a Block from a given JSON record. First, we
extract the JSON string values from the known keys, then we convert them to binary
by base64 decoding them. Finally, we extract the Schema and RecordBatch messages and
deserialize them into the Arrow Array types.
Custom implementation to deserialize a Block from a given JSON record . First we extract the JSON string values from the known keys then we convert them to binary by base64 decoding them . Finally we extract the Schema and RecordBatch messages and deserialize them into the Arrow Array types .
fn deserialize<D>(deserializer: D) -> Result<Block, D::Error>
    where
        D: de::Deserializer<'de>,
    {
        let helper: Value = Deserialize::deserialize(deserializer)?;
        let tuple = (
            decode_value(helper.get("schema")),
            decode_value(helper.get("records")),
        );
        match tuple {
            (Some(schema), Some(records)) => {
                // We have to make sure that this is safe
                // TODO(magrund)
                let fbs_schema = ipc::get_size_prefixed_root_as_message(&schema[4..]);
                let fbs_records = ipc::get_size_prefixed_root_as_message(&records[4..]);
                if fbs_schema.header_type() == MessageHeader::Schema {
                    if let Some(fbs_schema) = fbs_schema.header_as_schema() {
                        let ss = ipc::convert::fb_to_schema(fbs_schema);
                        if fbs_records.header_type() == MessageHeader::RecordBatch {
                            let body_length = fbs_records.bodyLength();
                            if let Some(fbs_records) = fbs_records.header_as_record_batch() {
                                // Read fom the record batch
                                let x = rr::read_record_batch(
                                    &records[records.len() - body_length as usize..],
                                    fbs_records,
                                    Arc::new(ss),
                                );
                                if let Ok(Some(x)) = x {
                                    return Ok(Block::new(
                                        x,
                                        helper.get("schema").unwrap().as_str().unwrap().to_string(),
                                        helper
                                            .get("records")
                                            .unwrap()
                                            .as_str()
                                            .unwrap()
                                            .to_string(),
                                        helper.get("aId").unwrap().as_str().unwrap().to_string(),
                                    ));
                                }
                            }
                        }
                    }
                }
                return Err(D::Error::custom("Missing field `schema` in Block"));
            }
            (_, _) => return Err(D::Error::custom("Missing field `schema` in Block")),
        }
    }
fn deserialize < D > ( deserializer : D ) -> Result < Block , D :: Error > where D : de :: Deserializer < ' de > , { let helper : Value = Deserialize :: deserialize ( deserializer ) ? ; let tuple = ( decode_value ( helper . get ( " " ) ) , decode_value ( helper . get ( " " ) ) , ) ; match tuple { ( Some ( schema ) , Some ( records ) ) => { // We have to make sure that this is safe // TODO(magrund) let fbs_schema = ipc :: get_size_prefixed_root_as_message ( & schema [ 4 .. ] ) ; let fbs_records = ipc :: get_size_prefixed_root_as_message ( & records [ 4 .. ] ) ; if fbs_schema . header_type ( ) == MessageHeader :: Schema { if let Some ( fbs_schema ) = fbs_schema . header_as_schema ( ) { let ss = ipc :: convert :: fb_to_schema ( fbs_schema ) ; if fbs_records . header_type ( ) == MessageHeader :: RecordBatch { let body_length = fbs_records . bodyLength ( ) ; if let Some ( fbs_records ) = fbs_records . header_as_record_batch ( ) { // Read fom the record batch let x = rr :: read_record_batch ( & records [ records . len ( ) - body_length as usize .. ] , fbs_records , Arc :: new ( ss ) , ) ; if let Ok ( Some ( x ) ) = x { return Ok ( Block :: new ( x , helper . get ( " " ) . unwrap ( ) . as_str ( ) . unwrap ( ) . to_string ( ) , helper . get ( " " ) . unwrap ( ) . as_str ( ) . unwrap ( ) . to_string ( ) , helper . get ( " " ) . unwrap ( ) . as_str ( ) . unwrap ( ) . to_string ( ) , ) ) ; } } } } } return Err ( D :: Error :: custom ( " " ) ) ; } ( _ , _ ) => return Err ( D :: Error :: custom ( " " ) ) , } }
Custom implementation to deserialize a Block from a given JSON record.
Custom implementation to deserialize a Block from a given JSON record .
deserializer
D
deserializer
D