MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / decode

Function decode

src/storage/src/source/sql_server/replication.rs:744–767  ·  view source on GitHub ↗

Helper method to decode a row from a [`tiberius::Row`] (or 2 of them in the case of update) to a [`Row`]. This centralizes the decode and mapping to result.

(
    decoder: &SqlServerRowDecoder,
    row: &tiberius::Row,
    mz_row: &mut Row,
    arena: &RowArena,
    new_row: Option<&tiberius::Row>,
)

Source from the content-addressed store, hash-verified

742/// Helper method to decode a row from a [`tiberius::Row`] (or 2 of them in the case of update)
743/// to a [`Row`]. This centralizes the decode and mapping to result.
744fn decode(
745 decoder: &SqlServerRowDecoder,
746 row: &tiberius::Row,
747 mz_row: &mut Row,
748 arena: &RowArena,
749 new_row: Option<&tiberius::Row>,
750) -> Result<SourceMessage, DataflowError> {
751 match decoder.decode(row, mz_row, arena, new_row) {
752 Ok(()) => Ok(SourceMessage {
753 key: Row::default(),
754 value: mz_row.clone(),
755 metadata: Row::default(),
756 }),
757 Err(e) => {
758 let kind = DecodeErrorKind::Text(e.to_string().into());
759 // TODO(sql_server2): Get the raw bytes from `tiberius`.
760 let raw = format!("{row:?}");
761 Err(DataflowError::DecodeError(Box::new(DecodeError {
762 kind,
763 raw: raw.as_bytes().to_vec(),
764 })))
765 }
766 }
767}
768
769/// Helper method to return a "definite" error upstream.
770async fn return_definite_error(

Callers 15

renderFunction · 0.70
handle_data_eventFunction · 0.70
plan_create_subsourceFunction · 0.50
smoketest_lsn_orderingFunction · 0.50
test_caseFunction · 0.50
decodeMethod · 0.50
decodeMethod · 0.50

Calls 7

TextClass · 0.85
to_vecMethod · 0.80
DecodeErrorClass · 0.50
decodeMethod · 0.45
cloneMethod · 0.45
to_stringMethod · 0.45
as_bytesMethod · 0.45

Tested by 2

test_caseFunction · 0.40