hive_metastore 0.2.0

Native hive metastore client for Rust, powered by Volo
Documentation

impl ::std::default::Default for LockComponent {
    fn default() -> Self {
        LockComponent {
            r#type: ::std::default::Default::default(),
            level: ::std::default::Default::default(),
            dbname: ::std::default::Default::default(),
            tablename: ::std::default::Default::default(),
            partitionname: ::std::default::Default::default(),
            operation_type: Some(DataOperationType::UNSET),
            is_acid: Some(false),
            is_dynamic_partition_write: Some(false),
        }
    }
}
#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)]
pub struct LockComponent {
    pub r#type: LockType,

    pub level: LockLevel,

    pub dbname: ::pilota::FastStr,

    pub tablename: ::std::option::Option<::pilota::FastStr>,

    pub partitionname: ::std::option::Option<::pilota::FastStr>,

    pub operation_type: ::std::option::Option<DataOperationType>,

    pub is_acid: ::std::option::Option<bool>,

    pub is_dynamic_partition_write: ::std::option::Option<bool>,
}
impl ::pilota::thrift::Message for LockComponent {
    fn encode<T: ::pilota::thrift::TOutputProtocol>(
        &self,
        __protocol: &mut T,
    ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> {
        #[allow(unused_imports)]
        use ::pilota::thrift::TOutputProtocolExt;
        let struct_ident = ::pilota::thrift::TStructIdentifier {
            name: "LockComponent",
        };

        __protocol.write_struct_begin(&struct_ident)?;
        __protocol.write_i32_field(1, (&self.r#type).inner())?;
        __protocol.write_i32_field(2, (&self.level).inner())?;
        __protocol.write_faststr_field(3, (&self.dbname).clone())?;
        if let Some(value) = self.tablename.as_ref() {
            __protocol.write_faststr_field(4, (value).clone())?;
        }
        if let Some(value) = self.partitionname.as_ref() {
            __protocol.write_faststr_field(5, (value).clone())?;
        }
        if let Some(value) = self.operation_type.as_ref() {
            __protocol.write_i32_field(6, (value).inner())?;
        }
        if let Some(value) = self.is_acid.as_ref() {
            __protocol.write_bool_field(7, *value)?;
        }
        if let Some(value) = self.is_dynamic_partition_write.as_ref() {
            __protocol.write_bool_field(8, *value)?;
        }
        __protocol.write_field_stop()?;
        __protocol.write_struct_end()?;
        ::std::result::Result::Ok(())
    }

    fn decode<T: ::pilota::thrift::TInputProtocol>(
        __protocol: &mut T,
    ) -> ::std::result::Result<Self, ::pilota::thrift::ThriftException> {
        #[allow(unused_imports)]
        use ::pilota::{thrift::TLengthProtocolExt, Buf};

        let mut var_1 = None;
        let mut var_2 = None;
        let mut var_3 = None;
        let mut var_4 = None;
        let mut var_5 = None;
        let mut var_6 = Some(DataOperationType::UNSET);
        let mut var_7 = Some(false);
        let mut var_8 = Some(false);

        let mut __pilota_decoding_field_id = None;

        __protocol.read_struct_begin()?;
        if let ::std::result::Result::Err(mut err) = (|| {
            loop {
                let field_ident = __protocol.read_field_begin()?;
                if field_ident.field_type == ::pilota::thrift::TType::Stop {
                    __protocol.field_stop_len();
                    break;
                } else {
                    __protocol.field_begin_len(field_ident.field_type, field_ident.id);
                }
                __pilota_decoding_field_id = field_ident.id;
                match field_ident.id {
                    Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => {
                        var_1 = Some(::pilota::thrift::Message::decode(__protocol)?);
                    }
                    Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => {
                        var_2 = Some(::pilota::thrift::Message::decode(__protocol)?);
                    }
                    Some(3) if field_ident.field_type == ::pilota::thrift::TType::Binary => {
                        var_3 = Some(__protocol.read_faststr()?);
                    }
                    Some(4) if field_ident.field_type == ::pilota::thrift::TType::Binary => {
                        var_4 = Some(__protocol.read_faststr()?);
                    }
                    Some(5) if field_ident.field_type == ::pilota::thrift::TType::Binary => {
                        var_5 = Some(__protocol.read_faststr()?);
                    }
                    Some(6) if field_ident.field_type == ::pilota::thrift::TType::I32 => {
                        var_6 = Some(::pilota::thrift::Message::decode(__protocol)?);
                    }
                    Some(7) if field_ident.field_type == ::pilota::thrift::TType::Bool => {
                        var_7 = Some(__protocol.read_bool()?);
                    }
                    Some(8) if field_ident.field_type == ::pilota::thrift::TType::Bool => {
                        var_8 = Some(__protocol.read_bool()?);
                    }
                    _ => {
                        __protocol.skip(field_ident.field_type)?;
                    }
                }

                __protocol.read_field_end()?;
                __protocol.field_end_len();
            }
            ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(())
        })() {
            if let Some(field_id) = __pilota_decoding_field_id {
                err.prepend_msg(&format!(
                    "decode struct `LockComponent` field(#{}) failed, caused by: ",
                    field_id
                ));
            }
            return ::std::result::Result::Err(err);
        };
        __protocol.read_struct_end()?;

        let Some(var_1) = var_1 else {
            return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception(
                ::pilota::thrift::ProtocolExceptionKind::InvalidData,
                "field r#type is required".to_string(),
            ));
        };
        let Some(var_2) = var_2 else {
            return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception(
                ::pilota::thrift::ProtocolExceptionKind::InvalidData,
                "field level is required".to_string(),
            ));
        };
        let Some(var_3) = var_3 else {
            return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception(
                ::pilota::thrift::ProtocolExceptionKind::InvalidData,
                "field dbname is required".to_string(),
            ));
        };

        let data = Self {
            r#type: var_1,
            level: var_2,
            dbname: var_3,
            tablename: var_4,
            partitionname: var_5,
            operation_type: var_6,
            is_acid: var_7,
            is_dynamic_partition_write: var_8,
        };
        ::std::result::Result::Ok(data)
    }

    fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>(
        __protocol: &'a mut T,
    ) -> ::std::pin::Pin<
        ::std::boxed::Box<
            dyn ::std::future::Future<
                    Output = ::std::result::Result<Self, ::pilota::thrift::ThriftException>,
                > + Send
                + 'a,
        >,
    > {
        ::std::boxed::Box::pin(async move {
            let mut var_1 = None;
            let mut var_2 = None;
            let mut var_3 = None;
            let mut var_4 = None;
            let mut var_5 = None;
            let mut var_6 = Some(DataOperationType::UNSET);
            let mut var_7 = Some(false);
            let mut var_8 = Some(false);

            let mut __pilota_decoding_field_id = None;

            __protocol.read_struct_begin().await?;
            if let ::std::result::Result::Err(mut err) = async {
                loop {
                    let field_ident = __protocol.read_field_begin().await?;
                    if field_ident.field_type == ::pilota::thrift::TType::Stop {
                        break;
                    } else {
                    }
                    __pilota_decoding_field_id = field_ident.id;
                    match field_ident.id {
                        Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => {
                            var_1 = Some(
                                <LockType as ::pilota::thrift::Message>::decode_async(__protocol)
                                    .await?,
                            );
                        }
                        Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => {
                            var_2 = Some(
                                <LockLevel as ::pilota::thrift::Message>::decode_async(__protocol)
                                    .await?,
                            );
                        }
                        Some(3) if field_ident.field_type == ::pilota::thrift::TType::Binary => {
                            var_3 = Some(__protocol.read_faststr().await?);
                        }
                        Some(4) if field_ident.field_type == ::pilota::thrift::TType::Binary => {
                            var_4 = Some(__protocol.read_faststr().await?);
                        }
                        Some(5) if field_ident.field_type == ::pilota::thrift::TType::Binary => {
                            var_5 = Some(__protocol.read_faststr().await?);
                        }
                        Some(6) if field_ident.field_type == ::pilota::thrift::TType::I32 => {
                            var_6 = Some(
                                <DataOperationType as ::pilota::thrift::Message>::decode_async(
                                    __protocol,
                                )
                                .await?,
                            );
                        }
                        Some(7) if field_ident.field_type == ::pilota::thrift::TType::Bool => {
                            var_7 = Some(__protocol.read_bool().await?);
                        }
                        Some(8) if field_ident.field_type == ::pilota::thrift::TType::Bool => {
                            var_8 = Some(__protocol.read_bool().await?);
                        }
                        _ => {
                            __protocol.skip(field_ident.field_type).await?;
                        }
                    }

                    __protocol.read_field_end().await?;
                }
                ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(())
            }
            .await
            {
                if let Some(field_id) = __pilota_decoding_field_id {
                    err.prepend_msg(&format!(
                        "decode struct `LockComponent` field(#{}) failed, caused by: ",
                        field_id
                    ));
                }
                return ::std::result::Result::Err(err);
            };
            __protocol.read_struct_end().await?;

            let Some(var_1) = var_1 else {
                return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception(
                    ::pilota::thrift::ProtocolExceptionKind::InvalidData,
                    "field r#type is required".to_string(),
                ));
            };
            let Some(var_2) = var_2 else {
                return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception(
                    ::pilota::thrift::ProtocolExceptionKind::InvalidData,
                    "field level is required".to_string(),
                ));
            };
            let Some(var_3) = var_3 else {
                return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception(
                    ::pilota::thrift::ProtocolExceptionKind::InvalidData,
                    "field dbname is required".to_string(),
                ));
            };

            let data = Self {
                r#type: var_1,
                level: var_2,
                dbname: var_3,
                tablename: var_4,
                partitionname: var_5,
                operation_type: var_6,
                is_acid: var_7,
                is_dynamic_partition_write: var_8,
            };
            ::std::result::Result::Ok(data)
        })
    }

    fn size<T: ::pilota::thrift::TLengthProtocol>(&self, __protocol: &mut T) -> usize {
        #[allow(unused_imports)]
        use ::pilota::thrift::TLengthProtocolExt;
        __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier {
            name: "LockComponent",
        }) + __protocol.i32_field_len(Some(1), (&self.r#type).inner())
            + __protocol.i32_field_len(Some(2), (&self.level).inner())
            + __protocol.faststr_field_len(Some(3), &self.dbname)
            + self
                .tablename
                .as_ref()
                .map_or(0, |value| __protocol.faststr_field_len(Some(4), value))
            + self
                .partitionname
                .as_ref()
                .map_or(0, |value| __protocol.faststr_field_len(Some(5), value))
            + self.operation_type.as_ref().map_or(0, |value| {
                __protocol.i32_field_len(Some(6), (value).inner())
            })
            + self
                .is_acid
                .as_ref()
                .map_or(0, |value| __protocol.bool_field_len(Some(7), *value))
            + self
                .is_dynamic_partition_write
                .as_ref()
                .map_or(0, |value| __protocol.bool_field_len(Some(8), *value))
            + __protocol.field_stop_len()
            + __protocol.struct_end_len()
    }
}