Skip to content

Commit c1545f4

Browse files
committed
fix
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent bf5f390 commit c1545f4

35 files changed

Lines changed: 1954 additions & 264 deletions

vortex-test/compat-gen/src/fixtures/clickbench.rs renamed to vortex-test/compat-gen/src/fixtures/arrays/datasets/clickbench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use vortex_array::vtable::ArrayId;
1414
use vortex_error::VortexResult;
1515
use vortex_error::vortex_err;
1616

17-
use super::ArrayFixture;
17+
use crate::fixtures::ArrayFixture;
1818

1919
/// First partition of ClickBench hits, limited to 1000 rows.
2020
const CLICKBENCH_URL: &str =
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
mod clickbench;
5+
#[allow(clippy::cast_possible_truncation)]
6+
mod tpch;
7+
8+
use crate::fixtures::ArrayFixture;
9+
10+
/// All dataset-derived fixtures.
11+
pub fn fixtures() -> Vec<Box<dyn ArrayFixture>> {
12+
let mut fixtures = Vec::new();
13+
fixtures.extend(tpch::fixtures());
14+
fixtures.extend(clickbench::fixtures());
15+
fixtures
16+
}

vortex-test/compat-gen/src/fixtures/tpch.rs renamed to vortex-test/compat-gen/src/fixtures/arrays/datasets/tpch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use vortex_array::arrow::FromArrowArray;
1717
use vortex_array::vtable::ArrayId;
1818
use vortex_error::VortexResult;
1919

20-
use super::ArrayFixture;
20+
use crate::fixtures::ArrayFixture;
2121

2222
const SCALE_FACTOR: f64 = 0.01;
2323

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
mod datasets;
5+
mod synthetic;
6+
7+
use super::ArrayFixture;
8+
9+
/// All array fixtures.
10+
pub fn fixtures() -> Vec<Box<dyn ArrayFixture>> {
11+
let mut fixtures = Vec::new();
12+
fixtures.extend(synthetic::fixtures());
13+
fixtures.extend(datasets::fixtures());
14+
fixtures
15+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex_array::ArrayRef;
5+
use vortex_array::IntoArray;
6+
use vortex_array::arrays::Bool;
7+
use vortex_array::arrays::BoolArray;
8+
use vortex_array::arrays::StructArray;
9+
use vortex_array::dtype::FieldNames;
10+
use vortex_array::validity::Validity;
11+
use vortex_array::vtable::ArrayId;
12+
use vortex_error::VortexResult;
13+
14+
use crate::fixtures::ArrayFixture;
15+
16+
pub struct BooleansFixture;
17+
18+
impl ArrayFixture for BooleansFixture {
19+
fn name(&self) -> &str {
20+
"booleans.vortex"
21+
}
22+
23+
fn description(&self) -> &str {
24+
"Boolean arrays with mixed true/false values including a nullable column"
25+
}
26+
27+
fn expected_encodings(&self) -> Vec<ArrayId> {
28+
vec![Bool::ID]
29+
}
30+
31+
fn build(&self) -> VortexResult<ArrayRef> {
32+
let bools = BoolArray::from_iter([true, false, true, true, false]);
33+
let nullable_bools =
34+
BoolArray::from_iter([Some(true), None, Some(false), None, Some(true)]);
35+
let arr = StructArray::try_new(
36+
FieldNames::from(["flag", "nullable_flag"]),
37+
vec![bools.into_array(), nullable_bools.into_array()],
38+
5,
39+
Validity::NonNullable,
40+
)?;
41+
Ok(arr.into_array())
42+
}
43+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex_array::ArrayRef;
5+
use vortex_array::IntoArray;
6+
use vortex_array::arrays::ChunkedArray;
7+
use vortex_array::arrays::Primitive;
8+
use vortex_array::arrays::PrimitiveArray;
9+
use vortex_array::arrays::StructArray;
10+
use vortex_array::dtype::FieldNames;
11+
use vortex_array::validity::Validity;
12+
use vortex_array::vtable::ArrayId;
13+
use vortex_error::VortexResult;
14+
15+
use crate::fixtures::ArrayFixture;
16+
17+
pub struct ChunkedFixture;
18+
19+
impl ArrayFixture for ChunkedFixture {
20+
fn name(&self) -> &str {
21+
"chunked.vortex"
22+
}
23+
24+
fn description(&self) -> &str {
25+
"ChunkedArray with 3 chunks of 1000 rows each containing deterministic u32 values"
26+
}
27+
28+
fn expected_encodings(&self) -> Vec<ArrayId> {
29+
vec![Primitive::ID]
30+
}
31+
32+
fn build(&self) -> VortexResult<ArrayRef> {
33+
let value_gen = |chunk_idx| {
34+
let values: Vec<u32> = (0u32..1000).map(|i| chunk_idx * 1000 + i).collect();
35+
let primitives =
36+
PrimitiveArray::new(vortex_buffer::Buffer::from(values), Validity::NonNullable);
37+
Ok(StructArray::try_new(
38+
FieldNames::from(["id"]),
39+
vec![primitives.into_array()],
40+
1000,
41+
Validity::NonNullable,
42+
)?
43+
.into_array())
44+
};
45+
46+
Ok(
47+
ChunkedArray::from_iter((0u32..3).map(value_gen).collect::<VortexResult<Vec<_>>>()?)
48+
.into_array(),
49+
)
50+
}
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex_array::ArrayRef;
5+
use vortex_array::IntoArray;
6+
use vortex_array::arrays::FixedSizeList;
7+
use vortex_array::arrays::FixedSizeListArray;
8+
use vortex_array::arrays::PrimitiveArray;
9+
use vortex_array::arrays::StructArray;
10+
use vortex_array::dtype::FieldNames;
11+
use vortex_array::validity::Validity;
12+
use vortex_array::vtable::ArrayId;
13+
use vortex_buffer::buffer;
14+
use vortex_error::VortexResult;
15+
16+
use crate::fixtures::ArrayFixture;
17+
18+
pub struct FixedSizeListFixture;
19+
20+
impl ArrayFixture for FixedSizeListFixture {
21+
fn name(&self) -> &str {
22+
"fixed_size_list.vortex"
23+
}
24+
25+
fn description(&self) -> &str {
26+
"Fixed-size list arrays (e.g. 3-element vectors)"
27+
}
28+
29+
fn expected_encodings(&self) -> Vec<ArrayId> {
30+
vec![FixedSizeList::ID]
31+
}
32+
33+
fn build(&self) -> VortexResult<ArrayRef> {
34+
// 4 vectors of 3 f64 each
35+
let elements = PrimitiveArray::new(
36+
buffer![
37+
1.0f64, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0
38+
],
39+
Validity::NonNullable,
40+
);
41+
let fsl = FixedSizeListArray::try_new(elements.into_array(), 3, Validity::NonNullable, 4)?;
42+
43+
let arr = StructArray::try_new(
44+
FieldNames::from(["vectors"]),
45+
vec![fsl.into_array()],
46+
4,
47+
Validity::NonNullable,
48+
)?;
49+
Ok(arr.into_array())
50+
}
51+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex_array::ArrayRef;
5+
use vortex_array::IntoArray;
6+
use vortex_array::arrays::List;
7+
use vortex_array::arrays::ListArray;
8+
use vortex_array::arrays::PrimitiveArray;
9+
use vortex_array::arrays::StructArray;
10+
use vortex_array::arrays::VarBinArray;
11+
use vortex_array::dtype::FieldNames;
12+
use vortex_array::validity::Validity;
13+
use vortex_array::vtable::ArrayId;
14+
use vortex_buffer::buffer;
15+
use vortex_error::VortexResult;
16+
17+
use crate::fixtures::ArrayFixture;
18+
19+
pub struct ListFixture;
20+
21+
impl ArrayFixture for ListFixture {
22+
fn name(&self) -> &str {
23+
"list.vortex"
24+
}
25+
26+
fn description(&self) -> &str {
27+
"Variable-length list arrays with integer and string elements"
28+
}
29+
30+
fn expected_encodings(&self) -> Vec<ArrayId> {
31+
vec![List::ID]
32+
}
33+
34+
fn build(&self) -> VortexResult<ArrayRef> {
35+
// List of i32: [[1,2,3], [4,5], [6], [7,8,9,10]]
36+
let elements = PrimitiveArray::new(
37+
buffer![1i32, 2, 3, 4, 5, 6, 7, 8, 9, 10],
38+
Validity::NonNullable,
39+
);
40+
let offsets = PrimitiveArray::new(buffer![0i64, 3, 5, 6, 10], Validity::NonNullable);
41+
let int_list = ListArray::try_new(
42+
elements.into_array(),
43+
offsets.into_array(),
44+
Validity::NonNullable,
45+
)?;
46+
47+
// List of strings: [["a","b"], ["hello"], [], ["x","y","z"]]
48+
let str_elements = VarBinArray::from(vec!["a", "b", "hello", "x", "y", "z"]);
49+
let str_offsets = PrimitiveArray::new(buffer![0i64, 2, 3, 3, 6], Validity::NonNullable);
50+
let str_list = ListArray::try_new(
51+
str_elements.into_array(),
52+
str_offsets.into_array(),
53+
Validity::NonNullable,
54+
)?;
55+
56+
let arr = StructArray::try_new(
57+
FieldNames::from(["int_list", "str_list"]),
58+
vec![int_list.into_array(), str_list.into_array()],
59+
4,
60+
Validity::NonNullable,
61+
)?;
62+
Ok(arr.into_array())
63+
}
64+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
//! Per-array-type synthetic fixtures.
5+
//!
6+
//! Each fixture exercises a core Vortex array type with boundary values and nullable variants.
7+
8+
mod bool;
9+
mod chunked;
10+
mod fixed_size_list;
11+
mod list;
12+
mod null;
13+
mod primitive;
14+
mod struct_nested;
15+
mod varbin;
16+
mod varbinview;
17+
18+
use crate::fixtures::ArrayFixture;
19+
20+
/// All per-array-type fixtures.
21+
pub fn fixtures() -> Vec<Box<dyn ArrayFixture>> {
22+
vec![
23+
Box::new(primitive::PrimitivesFixture),
24+
Box::new(varbin::VarBinFixture),
25+
Box::new(varbinview::VarBinViewFixture),
26+
Box::new(bool::BooleansFixture),
27+
Box::new(struct_nested::StructNestedFixture),
28+
Box::new(chunked::ChunkedFixture),
29+
Box::new(list::ListFixture),
30+
Box::new(fixed_size_list::FixedSizeListFixture),
31+
Box::new(null::NullFixture),
32+
]
33+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex_array::ArrayRef;
5+
use vortex_array::IntoArray;
6+
use vortex_array::arrays::Null;
7+
use vortex_array::arrays::NullArray;
8+
use vortex_array::arrays::PrimitiveArray;
9+
use vortex_array::arrays::StructArray;
10+
use vortex_array::dtype::FieldNames;
11+
use vortex_array::validity::Validity;
12+
use vortex_array::vtable::ArrayId;
13+
use vortex_buffer::buffer;
14+
use vortex_error::VortexResult;
15+
16+
use crate::fixtures::ArrayFixture;
17+
18+
pub struct NullFixture;
19+
20+
impl ArrayFixture for NullFixture {
21+
fn name(&self) -> &str {
22+
"null.vortex"
23+
}
24+
25+
fn description(&self) -> &str {
26+
"All-null column using NullArray alongside an integer column"
27+
}
28+
29+
fn expected_encodings(&self) -> Vec<ArrayId> {
30+
vec![Null::ID]
31+
}
32+
33+
fn build(&self) -> VortexResult<ArrayRef> {
34+
let null_col = NullArray::new(10);
35+
let int_col = PrimitiveArray::new(
36+
buffer![0i32, 1, 2, 3, 4, 5, 6, 7, 8, 9],
37+
Validity::NonNullable,
38+
);
39+
40+
let arr = StructArray::try_new(
41+
FieldNames::from(["nulls", "ids"]),
42+
vec![null_col.into_array(), int_col.into_array()],
43+
10,
44+
Validity::NonNullable,
45+
)?;
46+
Ok(arr.into_array())
47+
}
48+
}

0 commit comments

Comments
 (0)