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

Function read_blob_batch

crates/paimon/src/arrow/format/blob.rs:179–213  ·  view source on GitHub ↗
(
    reader: &dyn FileRead,
    blob_index: &BlobFileIndex,
    target_schema: &Arc<arrow_schema::Schema>,
    positions: &[usize],
    project_values: bool,
)

Source from the content-addressed store, hash-verified

177}
178
179async fn read_blob_batch(
180 reader: &dyn FileRead,
181 blob_index: &BlobFileIndex,
182 target_schema: &Arc<arrow_schema::Schema>,
183 positions: &[usize],
184 project_values: bool,
185) -> crate::Result<RecordBatch> {
186 if !project_values {
187 return RecordBatch::try_new_with_options(
188 target_schema.clone(),
189 Vec::new(),
190 &RecordBatchOptions::new().with_row_count(Some(positions.len())),
191 )
192 .map_err(|e| Error::UnexpectedError {
193 message: format!("Failed to build empty blob RecordBatch: {e}"),
194 source: Some(Box::new(e)),
195 });
196 }
197
198 let planned_reads = plan_blob_reads(blob_index, positions)?;
199 let values = fetch_blob_values(reader, planned_reads).await?;
200 let mut builder = BinaryBuilder::new();
201 for value in values {
202 match value {
203 BlobValue::Null => builder.append_null(),
204 BlobValue::Inline(bytes) => builder.append_value(bytes.as_ref()),
205 }
206 }
207
208 let columns: Vec<ArrayRef> = vec![Arc::new(builder.finish())];
209 RecordBatch::try_new(target_schema.clone(), columns).map_err(|e| Error::UnexpectedError {
210 message: format!("Failed to build blob RecordBatch: {e}"),
211 source: Some(Box::new(e)),
212 })
213}
214
215fn plan_blob_reads(
216 blob_index: &BlobFileIndex,

Callers

nothing calls this directly

Calls 3

plan_blob_readsFunction · 0.85
fetch_blob_valuesFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected