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

Function build_column

crates/paimon/src/arrow/format/avro.rs:232–370  ·  view source on GitHub ↗
(
    records: &[Value],
    name: &str,
    data_type: &DataType,
    num_rows: usize,
)

Source from the content-addressed store, hash-verified

230}
231
232fn build_column(
233 records: &[Value],
234 name: &str,
235 data_type: &DataType,
236 num_rows: usize,
237) -> crate::Result<Arc<dyn arrow_array::Array>> {
238 // Pre-compute field position once; O(1) per-row access thereafter.
239 let idx = field_index(records, name);
240
241 Ok(match data_type {
242 DataType::Boolean(_) => {
243 let arr: BooleanArray = (0..num_rows)
244 .map(|i| get_field_at(&records[i], idx).and_then(value_as_bool))
245 .collect();
246 Arc::new(arr)
247 }
248 DataType::TinyInt(_) => {
249 let arr: Int8Array = (0..num_rows)
250 .map(|i| {
251 get_field_at(&records[i], idx)
252 .and_then(value_as_i64)
253 .map(|v| v as i8)
254 })
255 .collect();
256 Arc::new(arr)
257 }
258 DataType::SmallInt(_) => {
259 let arr: Int16Array = (0..num_rows)
260 .map(|i| {
261 get_field_at(&records[i], idx)
262 .and_then(value_as_i64)
263 .map(|v| v as i16)
264 })
265 .collect();
266 Arc::new(arr)
267 }
268 DataType::Int(_) => {
269 let arr: Int32Array = (0..num_rows)
270 .map(|i| {
271 get_field_at(&records[i], idx)
272 .and_then(value_as_i64)
273 .map(|v| v as i32)
274 })
275 .collect();
276 Arc::new(arr)
277 }
278 DataType::BigInt(_) => {
279 let arr: Int64Array = (0..num_rows)
280 .map(|i| get_field_at(&records[i], idx).and_then(value_as_i64))
281 .collect();
282 Arc::new(arr)
283 }
284 DataType::Float(_) => {
285 let arr: Float32Array = (0..num_rows)
286 .map(|i| {
287 get_field_at(&records[i], idx)
288 .and_then(value_as_f64)
289 .map(|v| v as f32)

Callers 13

records_to_batchFunction · 0.85
build_array_columnFunction · 0.85
build_map_columnFunction · 0.85
build_row_columnFunction · 0.85
test_build_column_intFunction · 0.85
test_build_column_bigintFunction · 0.85
test_build_column_stringFunction · 0.85
test_build_column_binaryFunction · 0.85

Calls 11

field_indexFunction · 0.85
get_field_atFunction · 0.85
bytes_to_i128_beFunction · 0.85
parse_decimal_stringFunction · 0.85
build_timestamp_columnFunction · 0.85
build_array_columnFunction · 0.85
build_map_columnFunction · 0.85
build_row_columnFunction · 0.85
precisionMethod · 0.80
scaleMethod · 0.80
element_typeMethod · 0.80