MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / make_column

Function make_column

atomic-core/examples/semantic_codec_lab.rs:131–172  ·  view source on GitHub ↗
(view: &View<'_>, content: &[u8], i: usize, mut method: u8)

Source from the content-addressed store, hash-verified

129}
130
131fn make_column(view: &View<'_>, content: &[u8], i: usize, mut method: u8) -> Result<Column> {
132 let raw = view.columns()[i];
133 if method == 8 {
134 method = match i {
135 1 => 5,
136 7 => 7,
137 8 => 6,
138 _ => 0,
139 };
140 }
141 if method == 10 {
142 method = match i {
143 1 => 9,
144 7 => 7,
145 _ => 0,
146 };
147 }
148 let actual = if !numeric(i) || raw.is_empty() {
149 0
150 } else {
151 match method {
152 5 if i != 1 => 0,
153 6 if i != 8 => 0,
154 7 if i != 7 => 0,
155 9 if i != 1 => 0,
156 _ => method,
157 }
158 };
159 let data = match actual {
160 0..=4 => transforms::encode(actual, raw)?,
161 5 => control::split(raw)?,
162 6 => context::split_references(view)?,
163 7 => context::predict_kinds(view, content)?,
164 9 => lengths::split(view, content)?,
165 _ => anyhow::bail!("unknown candidate"),
166 };
167 Ok(Column {
168 method: actual,
169 raw_len: raw.len().try_into()?,
170 data,
171 })
172}
173
174fn encode_frame(view: &View<'_>, content: &[u8], method: Option<u8>) -> Result<Vec<u8>> {
175 let mut columns = vec![];

Callers 2

encode_frameFunction · 0.85

Calls 8

split_referencesFunction · 0.85
predict_kindsFunction · 0.85
columnsMethod · 0.80
numericFunction · 0.70
encodeFunction · 0.50
splitFunction · 0.50
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by 1