MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / extract_binary

Function extract_binary

nodedb-strict/src/arrow_extract.rs:233–262  ·  view source on GitHub ↗
(
    decoder: &TupleDecoder,
    tuples: &[&[u8]],
    col_idx: usize,
    n: usize,
)

Source from the content-addressed store, hash-verified

231}
232
233fn extract_binary(
234 decoder: &TupleDecoder,
235 tuples: &[&[u8]],
236 col_idx: usize,
237 n: usize,
238) -> Result<ArrayRef, StrictError> {
239 let (null_buf, null_count) = build_null_buffer(decoder, tuples, col_idx)?;
240 let mut blobs: Vec<Option<&[u8]>> = Vec::with_capacity(n);
241
242 for tuple in tuples {
243 if let Some(raw) = decoder.extract_variable_raw(tuple, col_idx)? {
244 blobs.push(Some(raw));
245 } else {
246 blobs.push(None);
247 }
248 }
249
250 let array = BinaryArray::from(blobs);
251 if null_count > 0 {
252 let data = array
253 .into_data()
254 .into_builder()
255 .null_bit_buffer(Some(null_buf.into_inner().into_inner()))
256 .build()
257 .expect("arrow array builder lengths are consistent");
258 Ok(Arc::new(BinaryArray::from(data)))
259 } else {
260 Ok(Arc::new(array))
261 }
262}
263
264/// Decimal → String representation for Arrow (DataFusion handles decimal as strings
265/// or Decimal128 — we use string for lossless representation).

Callers 1

extract_column_to_arrowFunction · 0.85

Calls 5

build_null_bufferFunction · 0.85
extract_variable_rawMethod · 0.80
pushMethod · 0.45
expectMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected