MCPcopy Create free account
hub / github.com/apache/arrow-rs / append_default

Method append_default

arrow-avro/src/reader/record.rs:719–1156  ·  view source on GitHub ↗

Append a single default literal into the decoder's buffers

(&mut self, lit: &AvroLiteral)

Source from the content-addressed store, hash-verified

717
718 /// Append a single default literal into the decoder's buffers
719 fn append_default(&mut self, lit: &AvroLiteral) -> Result<(), AvroError> {
720 match self {
721 Self::Nullable(_, nb, inner) => {
722 if matches!(lit, AvroLiteral::Null) {
723 nb.append(false);
724 inner.append_null()
725 } else {
726 nb.append(true);
727 inner.append_default(lit)
728 }
729 }
730 Self::Null(count) => match lit {
731 AvroLiteral::Null => {
732 *count += 1;
733 Ok(())
734 }
735 _ => Err(AvroError::InvalidArgument(
736 "Non-null default for null type".to_string(),
737 )),
738 },
739 Self::Boolean(b) => match lit {
740 AvroLiteral::Boolean(v) => {
741 b.append(*v);
742 Ok(())
743 }
744 _ => Err(AvroError::InvalidArgument(
745 "Default for boolean must be boolean".to_string(),
746 )),
747 },
748 Self::Int32(v) | Self::Date32(v) | Self::TimeMillis(v) => match lit {
749 AvroLiteral::Int(i) => {
750 v.push(*i);
751 Ok(())
752 }
753 _ => Err(AvroError::InvalidArgument(
754 "Default for int32/date32/time-millis must be int".to_string(),
755 )),
756 },
757 #[cfg(feature = "avro_custom_types")]
758 Self::DurationSecond(v)
759 | Self::DurationMillisecond(v)
760 | Self::DurationMicrosecond(v)
761 | Self::DurationNanosecond(v) => match lit {
762 AvroLiteral::Long(i) => {
763 v.push(*i);
764 Ok(())
765 }
766 _ => Err(AvroError::InvalidArgument(
767 "Default for duration long must be long".to_string(),
768 )),
769 },
770 #[cfg(feature = "avro_custom_types")]
771 Self::Int8(v) => match lit {
772 AvroLiteral::Int(i) => {
773 let x = i8::try_from(*i).map_err(|_| {
774 AvroError::InvalidArgument(format!(
775 "Default for int8 out of range for i8: {i}"
776 ))

Calls 14

push_lengthMethod · 0.80
extend_from_sliceMethod · 0.80
positionMethod · 0.80
on_decoderMethod · 0.80
appendMethod · 0.45
append_nullMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45
as_bytesMethod · 0.45
append_valueMethod · 0.45
iterMethod · 0.45
nameMethod · 0.45