reifydb_core/value/column/push/
decimal.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::Decimal;
5
6use crate::value::column::{ColumnData, push::Push};
7
8impl Push<Decimal> for ColumnData {
9	fn push(&mut self, value: Decimal) {
10		match self {
11			ColumnData::Decimal {
12				container,
13				..
14			} => {
15				container.push(value);
16			}
17			ColumnData::Undefined(container) => {
18				let mut new_container = ColumnData::decimal_with_capacity(container.len());
19
20				if let ColumnData::Decimal {
21					container: new_container,
22					..
23				} = &mut new_container
24				{
25					for _ in 0..container.len() {
26						new_container.push_undefined();
27					}
28					new_container.push(value);
29				}
30				*self = new_container;
31			}
32			_ => unreachable!("Push<Decimal> for ColumnData with incompatible type"),
33		}
34	}
35}