reifydb_core/value/column/push/
i8.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4use reifydb_type::SafeConvert;
5
6use crate::value::column::{data::ColumnData, push::Push};
7
8impl Push<i8> for ColumnData {
9	fn push(&mut self, value: i8) {
10		match self {
11			ColumnData::Float4(container) => match <i8 as SafeConvert<f32>>::checked_convert(value) {
12				Some(v) => container.push(v),
13				None => container.push_undefined(),
14			},
15			ColumnData::Float8(container) => match <i8 as SafeConvert<f64>>::checked_convert(value) {
16				Some(v) => container.push(v),
17				None => container.push_undefined(),
18			},
19			ColumnData::Int1(container) => {
20				container.push(value);
21			}
22			ColumnData::Int2(container) => match <i8 as SafeConvert<i16>>::checked_convert(value) {
23				Some(v) => container.push(v),
24				None => container.push_undefined(),
25			},
26			ColumnData::Int4(container) => match <i8 as SafeConvert<i32>>::checked_convert(value) {
27				Some(v) => container.push(v),
28				None => container.push_undefined(),
29			},
30			ColumnData::Int8(container) => match <i8 as SafeConvert<i64>>::checked_convert(value) {
31				Some(v) => container.push(v),
32				None => container.push_undefined(),
33			},
34			ColumnData::Int16(container) => match <i8 as SafeConvert<i128>>::checked_convert(value) {
35				Some(v) => container.push(v),
36				None => container.push_undefined(),
37			},
38			ColumnData::Uint1(container) => match <i8 as SafeConvert<u8>>::checked_convert(value) {
39				Some(v) => container.push(v),
40				None => container.push_undefined(),
41			},
42			ColumnData::Uint2(container) => match <i8 as SafeConvert<u16>>::checked_convert(value) {
43				Some(v) => container.push(v),
44				None => container.push_undefined(),
45			},
46			ColumnData::Uint4(container) => match <i8 as SafeConvert<u32>>::checked_convert(value) {
47				Some(v) => container.push(v),
48				None => container.push_undefined(),
49			},
50			ColumnData::Uint8(container) => match <i8 as SafeConvert<u64>>::checked_convert(value) {
51				Some(v) => container.push(v),
52				None => container.push_undefined(),
53			},
54			ColumnData::Uint16(container) => match <i8 as SafeConvert<u128>>::checked_convert(value) {
55				Some(v) => container.push(v),
56				None => container.push_undefined(),
57			},
58			ColumnData::Undefined(container) => {
59				let mut new_container = ColumnData::int1(vec![0i8; container.len()]);
60				if let ColumnData::Int1(new_container) = &mut new_container {
61					new_container.push(value);
62				}
63				*self = new_container;
64			}
65			other => {
66				panic!(
67					"called `push::<i8>()` on incompatible EngineColumnData::{:?}",
68					other.get_type()
69				);
70			}
71		}
72	}
73}