MCPcopy Create free account
hub / github.com/apache/paimon-rust / build_descriptor_batch

Function build_descriptor_batch

crates/paimon/src/arrow/format/blob.rs:141–177  ·  view source on GitHub ↗
(
    blob_index: &BlobFileIndex,
    target_schema: &Arc<arrow_schema::Schema>,
    positions: &[usize],
    file_path: &str,
)

Source from the content-addressed store, hash-verified

139}
140
141fn build_descriptor_batch(
142 blob_index: &BlobFileIndex,
143 target_schema: &Arc<arrow_schema::Schema>,
144 positions: &[usize],
145 file_path: &str,
146) -> crate::Result<RecordBatch> {
147 let mut builder = BinaryBuilder::new();
148 for &position in positions {
149 let entry = blob_index
150 .entry(position)
151 .ok_or_else(|| Error::DataInvalid {
152 message: format!(
153 "Blob row selection referenced out-of-range position {position} for {} rows",
154 blob_index.num_rows()
155 ),
156 source: None,
157 })?;
158
159 match entry.inline_data_range() {
160 None => builder.append_null(),
161 Some(range) => {
162 let descriptor = BlobDescriptor::new(
163 file_path.to_string(),
164 range.start as i64,
165 (range.end - range.start) as i64,
166 );
167 builder.append_value(descriptor.serialize());
168 }
169 }
170 }
171
172 let columns: Vec<ArrayRef> = vec![Arc::new(builder.finish())];
173 RecordBatch::try_new(target_schema.clone(), columns).map_err(|e| Error::UnexpectedError {
174 message: format!("Failed to build descriptor blob RecordBatch: {e}"),
175 source: Some(Box::new(e)),
176 })
177}
178
179async fn read_blob_batch(
180 reader: &dyn FileRead,

Callers

nothing calls this directly

Calls 3

entryMethod · 0.80
inline_data_rangeMethod · 0.80
serializeMethod · 0.45

Tested by

no test coverage detected