|
15 | 15 | //! ## Creating and building decimal vectors |
16 | 16 | //! |
17 | 17 | //! ``` |
18 | | -//! use vortex_dtype::{DecimalDType, PrecisionScale}; |
| 18 | +//! use vortex_dtype::{PrecisionScale}; |
19 | 19 | //! use vortex_vector::decimal::{DVectorMut}; |
20 | 20 | //! use vortex_vector::VectorMutOps; |
21 | 21 | //! |
22 | 22 | //! // Create a decimal vector with precision=9, scale=2 (e.g., up to 9999999.99). |
23 | | -//! let decimal_dtype = DecimalDType::new(9, 2); |
| 23 | +//! let ps = PrecisionScale::<i32>::new(9, 2); |
24 | 24 | //! let mut vec = DVectorMut::<i32>::with_capacity(&decimal_dtype, 5); |
25 | 25 | //! assert_eq!(vec.len(), 0); |
26 | 26 | //! assert!(vec.capacity() >= 5); |
|
49 | 49 | //! |
50 | 50 | //! ``` |
51 | 51 | //! use vortex_buffer::BufferMut; |
52 | | -//! use vortex_dtype::{DecimalDType, PrecisionScale}; |
| 52 | +//! use vortex_dtype::{PrecisionScale}; |
53 | 53 | //! use vortex_mask::MaskMut; |
54 | 54 | //! use vortex_vector::decimal::DVectorMut; |
55 | 55 | //! use vortex_vector::VectorMutOps; |
56 | 56 | //! |
57 | 57 | //! // Create a decimal vector with nulls. |
58 | | -//! let decimal_dtype = DecimalDType::new(5, 2); // Up to 999.99. |
59 | | -//! let ps = PrecisionScale::<i32>::try_from(&decimal_dtype).unwrap(); |
| 58 | +//! let ps = PrecisionScale::<i32>::new(5, 2); // Up to 999.99. |
60 | 59 | //! |
61 | 60 | //! // Create with some null values (validity mask: true = not null, false = null). |
62 | 61 | //! let elements = BufferMut::from_iter([1000_i32, 0, 2500, 0]); // 10.00, null, 25.00, null. |
|
80 | 79 | //! ## Extending and manipulating vectors |
81 | 80 | //! |
82 | 81 | //! ``` |
83 | | -//! use vortex_dtype::DecimalDType; |
| 82 | +//! use vortex_dtype::{PrecisionScale}; |
84 | 83 | //! use vortex_vector::decimal::DVectorMut; |
85 | 84 | //! use vortex_vector::VectorMutOps; |
86 | 85 | //! |
87 | 86 | //! // Create two decimal vectors with scale=3 (3 decimal places). |
88 | | -//! let decimal_dtype = DecimalDType::new(10, 3); |
89 | | -//! let mut vec1 = DVectorMut::<i64>::with_capacity(&decimal_dtype, 10); |
| 87 | +//! let ps = PrecisionScale::<i64>::new(10, 3); |
| 88 | +//! let mut vec1 = DVectorMut::<i64>::with_capacity(ps, 10); |
90 | 89 | //! vec1.try_push(1234567).unwrap(); // 1234.567. |
91 | 90 | //! vec1.try_push(2345678).unwrap(); // 2345.678. |
92 | 91 | //! |
93 | | -//! let mut vec2 = DVectorMut::<i64>::with_capacity(&decimal_dtype, 10); |
| 92 | +//! let mut vec2 = DVectorMut::<i64>::with_capacity(ps, 10); |
94 | 93 | //! vec2.try_push(3456789).unwrap(); // 3456.789. |
95 | 94 | //! vec2.try_push(4567890).unwrap(); // 4567.890. |
96 | 95 | //! |
|
116 | 115 | //! ## Converting between mutable and immutable |
117 | 116 | //! |
118 | 117 | //! ``` |
119 | | -//! use vortex_dtype::DecimalDType; |
| 118 | +//! use vortex_dtype::{PrecisionScale}; |
120 | 119 | //! use vortex_vector::decimal::DVectorMut; |
121 | 120 | //! use vortex_vector::{VectorMutOps, VectorOps}; |
122 | 121 | //! |
123 | 122 | //! // Create a mutable decimal vector. |
124 | | -//! let decimal_dtype = DecimalDType::new(18, 6); // High precision with 6 decimal places. |
125 | | -//! let mut vec_mut = DVectorMut::<i128>::with_capacity(&decimal_dtype, 3); |
| 123 | +//! let ps = PrecisionScale::<i128>::new(18, 6); // High precision with 6 decimal places. |
| 124 | +//! let mut vec_mut = DVectorMut::<i128>::with_capacity(ps, 3); |
126 | 125 | //! vec_mut.try_push(1000000).unwrap(); // 1.000000. |
127 | 126 | //! vec_mut.try_push(2500000).unwrap(); // 2.500000. |
128 | 127 | //! vec_mut.try_push(3333333).unwrap(); // 3.333333. |
|
0 commit comments