pub struct AvroSchema {
pub json_string: String,
}
Expand description
A wrapper for an Avro schema in its JSON string representation.
Fields§
§json_string: String
The Avro schema as a JSON string.
Implementations§
Source§impl AvroSchema
impl AvroSchema
pub(crate) fn schema(&self) -> Result<Schema<'_>, ArrowError>
Sourcepub fn fingerprint(
&self,
hash_type: FingerprintAlgorithm,
) -> Result<Fingerprint, ArrowError>
pub fn fingerprint( &self, hash_type: FingerprintAlgorithm, ) -> Result<Fingerprint, ArrowError>
Returns the fingerprint of the schema, computed using the specified FingerprintAlgorithm
.
The fingerprint is computed over the schema’s Parsed Canonical Form
as defined by the Avro specification. Depending on hash_type
, this
will return one of the supported Fingerprint
variants:
Fingerprint::Rabin
forFingerprintAlgorithm::Rabin
Fingerprint::MD5
forFingerprintAlgorithm::MD5
Fingerprint::SHA256
forFingerprintAlgorithm::SHA256
Note: FingerprintAlgorithm::None
cannot be used to generate a fingerprint
and will result in an error. If you intend to use a Schema Registry ID-based
wire format, load or set the Fingerprint::Id
directly via Fingerprint::load_fingerprint_id
or SchemaStore::set
.
See also: https://avro.apache.org/docs/1.11.1/specification/#schema-fingerprints
§Errors
Returns an error if deserializing the schema fails, if generating the
canonical form of the schema fails, or if hash_type
is FingerprintAlgorithm::None
.
§Examples
use arrow_avro::schema::{AvroSchema, FingerprintAlgorithm};
let avro = AvroSchema::new("\"string\"".to_string());
let fp = avro.fingerprint(FingerprintAlgorithm::Rabin).unwrap();
pub(crate) fn generate_fingerprint( schema: &Schema<'_>, hash_type: FingerprintAlgorithm, ) -> Result<Fingerprint, ArrowError>
Sourcepub fn generate_fingerprint_rabin(
schema: &Schema<'_>,
) -> Result<Fingerprint, ArrowError>
pub fn generate_fingerprint_rabin( schema: &Schema<'_>, ) -> Result<Fingerprint, ArrowError>
Generates the 64-bit Rabin fingerprint for the given Schema
.
The fingerprint is computed from the canonical form of the schema.
This is also known as CRC-64-AVRO
.
§Returns
A Fingerprint::Rabin
variant containing the 64-bit fingerprint.
Sourcepub(crate) fn generate_canonical_form(
schema: &Schema<'_>,
) -> Result<String, ArrowError>
pub(crate) fn generate_canonical_form( schema: &Schema<'_>, ) -> Result<String, ArrowError>
Generates the Parsed Canonical Form for the given Schema
.
The canonical form is a standardized JSON representation of the schema, primarily used for generating a schema fingerprint for equality checking.
This form strips attributes that do not affect the schema’s identity,
such as doc
fields, aliases
, and any properties not defined in the
Avro specification.
https://avro.apache.org/docs/1.11.1/specification/#parsing-canonical-form-for-schemas
Sourcepub fn from_arrow_with_options(
schema: &ArrowSchema,
null_order: Option<Nullability>,
) -> Result<AvroSchema, ArrowError>
pub fn from_arrow_with_options( schema: &ArrowSchema, null_order: Option<Nullability>, ) -> Result<AvroSchema, ArrowError>
Build Avro JSON from an Arrow [ArrowSchema
], applying the given null‑union order.
If the input Arrow schema already contains Avro JSON in
SCHEMA_METADATA_KEY
, that JSON is returned verbatim to preserve
the exact header encoding alignment; otherwise, a new JSON is generated
honoring null_union_order
at all nullable sites.
Trait Implementations§
Source§impl Clone for AvroSchema
impl Clone for AvroSchema
Source§fn clone(&self) -> AvroSchema
fn clone(&self) -> AvroSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AvroSchema
impl Debug for AvroSchema
Source§impl<'de> Deserialize<'de> for AvroSchema
impl<'de> Deserialize<'de> for AvroSchema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for AvroSchema
impl PartialEq for AvroSchema
Source§impl Serialize for AvroSchema
impl Serialize for AvroSchema
Source§impl TryFrom<&Schema> for AvroSchema
impl TryFrom<&Schema> for AvroSchema
impl Eq for AvroSchema
impl StructuralPartialEq for AvroSchema
Auto Trait Implementations§
impl Freeze for AvroSchema
impl RefUnwindSafe for AvroSchema
impl Send for AvroSchema
impl Sync for AvroSchema
impl Unpin for AvroSchema
impl UnwindSafe for AvroSchema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.