reifydb_core/value/column/push/
i64.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<i64> for ColumnData {
9	fn push(&mut self, value: i64) {
10		match self {
11			ColumnData::Float4(container) => match <i64 as SafeConvert<f32>>::checked_convert(value) {
12				Some(v) => container.push(v),
13				None => container.push_undefined(),
14			},
15			ColumnData::Float8(container) => match <i64 as SafeConvert<f64>>::checked_convert(value) {
16				Some(v) => container.push(v),
17				None => container.push_undefined(),
18			},
19			ColumnData::Int1(container) => match <i64 as SafeConvert<i8>>::checked_convert(value) {
20				Some(v) => container.push(v),
21				None => container.push_undefined(),
22			},
23			ColumnData::Int2(container) => match <i64 as SafeConvert<i16>>::checked_convert(value) {
24				Some(v) => container.push(v),
25				None => container.push_undefined(),
26			},
27			ColumnData::Int4(container) => match <i64 as SafeConvert<i32>>::checked_convert(value) {
28				Some(v) => container.push(v),
29				None => container.push_undefined(),
30			},
31			ColumnData::Int8(container) => container.push(value),
32			ColumnData::Int16(container) => match <i64 as SafeConvert<i128>>::checked_convert(value) {
33				Some(v) => container.push(v),
34				None => container.push_undefined(),
35			},
36			ColumnData::Uint1(container) => match <i64 as SafeConvert<u8>>::checked_convert(value) {
37				Some(v) => container.push(v),
38				None => container.push_undefined(),
39			},
40			ColumnData::Uint2(container) => match <i64 as SafeConvert<u16>>::checked_convert(value) {
41				Some(v) => container.push(v),
42				None => container.push_undefined(),
43			},
44			ColumnData::Uint4(container) => match <i64 as SafeConvert<u32>>::checked_convert(value) {
45				Some(v) => container.push(v),
46				None => container.push_undefined(),
47			},
48			ColumnData::Uint8(container) => match <i64 as SafeConvert<u64>>::checked_convert(value) {
49				Some(v) => container.push(v),
50				None => container.push_undefined(),
51			},
52			ColumnData::Uint16(container) => match <i64 as SafeConvert<u128>>::checked_convert(value) {
53				Some(v) => container.push(v),
54				None => container.push_undefined(),
55			},
56			ColumnData::Undefined(container) => {
57				let mut new_container = ColumnData::int8(vec![0i64; container.len()]);
58				if let ColumnData::Int8(new_container) = &mut new_container {
59					new_container.push(value);
60				}
61				*self = new_container;
62			}
63			other => {
64				panic!(
65					"called `push::<i64>()` on incompatible EngineColumnData::{:?}",
66					other.get_type()
67				);
68			}
69		}
70	}
71}