MCPcopy Create free account
hub / github.com/apache/arrow-rs / create_random_batch

Function create_random_batch

arrow/src/util/data_gen.rs:37–54  ·  view source on GitHub ↗

Create a random [RecordBatch] from a schema

(
    schema: SchemaRef,
    size: usize,
    null_density: f32,
    true_density: f32,
)

Source from the content-addressed store, hash-verified

35
36/// Create a random [RecordBatch] from a schema
37pub fn create_random_batch(
38 schema: SchemaRef,
39 size: usize,
40 null_density: f32,
41 true_density: f32,
42) -> Result<RecordBatch> {
43 let columns = schema
44 .fields()
45 .iter()
46 .map(|field| create_random_array(field, size, null_density, true_density))
47 .collect::<Result<Vec<ArrayRef>>>()?;
48
49 RecordBatch::try_new_with_options(
50 schema,
51 columns,
52 &RecordBatchOptions::new().with_match_field_names(false),
53 )
54}
55
56/// Create a random [ArrayRef] from a [DataType] with a length,
57/// null density and true density (for [BooleanArray]).

Calls 4

create_random_arrayFunction · 0.85
iterMethod · 0.45
fieldsMethod · 0.45