Struct tidb_query_datatype::codec::mysql::decimal::Decimal [−][src]
Decimal
represents a decimal value.
Fields
int_cnt: u8
The number of decimal digits before the point.
frac_cnt: u8
The number of decimal digits after the point.
result_frac_cnt: u8
The number of calculated or printed result fraction digits.
negative: bool
word_buf: [u32; 9]
An array of u32 words. A word is an u32 value can hold 9 digits.(0 <= word < wordBase)
Implementations
impl Decimal
[src]
pub fn abs(self) -> Res<Decimal>
[src]
abs the Decimal into a new Decimal.
pub fn ceil(&self) -> Res<Decimal>
[src]
ceil the Decimal into a new Decimal.
pub fn floor(&self) -> Res<Decimal>
[src]
floor the Decimal into a new Decimal.
fn new(int_cnt: u8, frac_cnt: u8, negative: bool) -> Decimal
[src]
create a new decimal for internal usage.
pub fn is_negative(&self) -> bool
[src]
pub fn zero() -> Decimal
[src]
Creates a new decimal which is zero.
fn remove_leading_zeroes(&self, prec: u8) -> (usize, u8)
[src]
Given a precision count ‘prec’, get:
- the index of first non-zero word in self.word_buf to hold the leading ‘prec’ number of digits
- the number of remained digits if we remove all leading zeros for the leading ‘prec’ number of digits
fn prepare_buf(&self) -> (Vec<u8>, usize, u8, u8, u8)
[src]
Prepare a buf for string output.
pub fn prec_and_frac(&self) -> (u8, u8)
[src]
Get the least precision and fraction count to encode this decimal completely.
fn digit_bounds(&self) -> (u8, u8)
[src]
digit_bounds
returns bounds of decimal digits in the number.
fn do_mini_left_shift(self, shift: u8, beg: u8, end: u8) -> Decimal
[src]
do_mini_left_shift
does left shift for alignment of data in buffer.
Result fitting in the buffer should be garanted. ‘shift’ have to be from 1 to DIGITS_PER_WORD - 1 (inclusive)
fn do_mini_right_shift(self, shift: u8, beg: u8, end: u8) -> Decimal
[src]
do_mini_right_shift
does right shift for alignment of data in buffer.
Result fitting in the buffer should be garanted. ‘shift’ have to be from 1 to DIGITS_PER_WORD - 1 (inclusive)
pub fn convert_to(
self,
ctx: &mut EvalContext,
flen: u8,
decimal: u8
) -> Result<Decimal>
[src]
self,
ctx: &mut EvalContext,
flen: u8,
decimal: u8
) -> Result<Decimal>
convert_to(ProduceDecWithSpecifiedTp in tidb)
produces a new decimal according to flen
and decimal
.
pub fn round(self, frac: i8, round_mode: RoundMode) -> Res<Decimal>
[src]
Round rounds the decimal to “frac” digits.
NOTES scale can be negative ! one TRUNCATED error (line XXX below) isn’t treated very logical :(
fn round_with_word_buf_len(
self,
frac: i8,
word_buf_len: u8,
round_mode: RoundMode
) -> Res<Decimal>
[src]
self,
frac: i8,
word_buf_len: u8,
round_mode: RoundMode
) -> Res<Decimal>
fn handle_incr(
res: Res<Decimal>,
int_word_cnt: u8,
frac_words_to: i8,
frac: i8,
frac_word_cnt: u8,
word_buf_len: u8,
round_mode: RoundMode
) -> Res<Decimal>
[src]
res: Res<Decimal>,
int_word_cnt: u8,
frac_words_to: i8,
frac: i8,
frac_word_cnt: u8,
word_buf_len: u8,
round_mode: RoundMode
) -> Res<Decimal>
fn handle_carry(
dec: Res<Decimal>,
to_idx: usize,
frac: i8,
frac_word_to: i8,
int_word_cnt: u8,
word_buf_len: u8
) -> Res<Decimal>
[src]
dec: Res<Decimal>,
to_idx: usize,
frac: i8,
frac_word_to: i8,
int_word_cnt: u8,
word_buf_len: u8
) -> Res<Decimal>
pub fn shift(self, shift: isize) -> Res<Decimal>
[src]
shift
shifts decimal digits in given number (with rounding if it need),
shift > 0 means shift to left shift, shift < 0 means right shift.
In fact it is multiplying on 10^shift.
fn shift_with_word_buf_len(self, shift: isize, word_buf_len: u8) -> Res<Decimal>
[src]
pub fn as_i64(&self) -> Res<i64>
[src]
as_i64
returns int part of the decimal.
pub fn as_i64_with_ctx(&self, ctx: &mut EvalContext) -> Result<i64>
[src]
as_i64_with_ctx
returns int part of the decimal.
pub fn as_u64(&self) -> Res<u64>
[src]
as_u64
returns int part of the decimal
pub fn from_f64(val: f64) -> Result<Decimal>
[src]
pub fn from_bytes(s: &[u8]) -> Result<Res<Decimal>>
[src]
Returns a Decimal
from a given bytes slice
Notes
An error will be returned if the given input is as follows:
- empty string
- string which cannot be converted to decimal
fn from_bytes_with_word_buf(s: &[u8], word_buf_len: u8) -> Result<Res<Decimal>>
[src]
Returns a Decimal
from a given bytes slice buffer and specified buffer length
Notes
An error will be returned if the given input is as follows:
- an empty string
- a string which cannot be converted to decimal
pub fn approximate_encoded_size(&self) -> usize
[src]
Get the approximate needed capacity to encode this decimal.
see also encode_decimal
.
fn div(&self, rhs: &Decimal, frac_incr: u8) -> Option<Res<Decimal>>
[src]
pub fn is_zero(&self) -> bool
[src]
Trait Implementations
impl<'a, 'b> Add<&'a Decimal> for &'b Decimal
[src]
type Output = Res<Decimal>
The resulting type after applying the +
operator.
fn add(self, rhs: &'a Decimal) -> Res<Decimal>
[src]
impl AsMySQLBool for Decimal
[src]
fn as_mysql_bool(&self, _ctx: &mut EvalContext) -> Result<bool>
[src]
impl Clone for Decimal
[src]
impl ConvertTo<Decimal> for i64
[src]
fn convert(&self, _: &mut EvalContext) -> Result<Decimal>
[src]
impl ConvertTo<Decimal> for u64
[src]
fn convert(&self, _: &mut EvalContext) -> Result<Decimal>
[src]
impl ConvertTo<Decimal> for Time
[src]
fn convert(&self, _: &mut EvalContext) -> Result<Decimal>
[src]
impl ConvertTo<Decimal> for f64
[src]
fn convert(&self, _: &mut EvalContext) -> Result<Decimal>
[src]
Convert a float number to decimal.
This function will use float’s canonical string representation rather than the accurate value the float represent.
impl ConvertTo<Decimal> for Real
[src]
fn convert(&self, ctx: &mut EvalContext) -> Result<Decimal>
[src]
impl ConvertTo<Decimal> for &[u8]
[src]
fn convert(&self, ctx: &mut EvalContext) -> Result<Decimal>
[src]
impl ConvertTo<Decimal> for Cow<'_, [u8]>
[src]
fn convert(&self, ctx: &mut EvalContext) -> Result<Decimal>
[src]
impl ConvertTo<Decimal> for Bytes
[src]
fn convert(&self, ctx: &mut EvalContext) -> Result<Decimal>
[src]
impl ConvertTo<Decimal> for Json
[src]
fn convert(&self, ctx: &mut EvalContext) -> Result<Decimal>
[src]
Port from TiDB’s types.ConvertJSONToDecimal
impl<'a> ConvertTo<Decimal> for JsonRef<'a>
[src]
fn convert(&self, ctx: &mut EvalContext) -> Result<Decimal>
[src]
Port from TiDB’s types.ConvertJSONToDecimal
impl ConvertTo<Decimal> for Duration
[src]
fn convert(&self, _: &mut EvalContext) -> Result<Decimal>
[src]
This function should not return err, if it return err, then the err is because of bug.
Port from TiDB’ Duration::ToNumber
impl ConvertTo<Json> for Decimal
[src]
fn convert(&self, ctx: &mut EvalContext) -> Result<Json>
[src]
impl ConvertTo<f64> for Decimal
[src]
fn convert(&self, _: &mut EvalContext) -> Result<f64>
[src]
This function should not return err, if it return err, then the err because of bug.
Port from TiDB’s MyDecimal::ToFloat64.
impl Copy for Decimal
[src]
impl Debug for Decimal
[src]
impl Display for Decimal
[src]
impl<'a, 'b> Div<&'a Decimal> for &'b Decimal
[src]
type Output = Option<Res<Decimal>>
The resulting type after applying the /
operator.
fn div(self, rhs: &'a Decimal) -> Self::Output
[src]
impl Eq for Decimal
[src]
impl Evaluable for Decimal
[src]
const EVAL_TYPE: EvalType
[src]
fn borrow_scalar_value(v: &ScalarValue) -> Option<&Self>
[src]
fn borrow_scalar_value_ref<'a>(v: ScalarValueRef<'a>) -> Option<&'a Self>
[src]
fn borrow_vector_value(v: &VectorValue) -> &ChunkedVecSized<Decimal>
[src]
impl EvaluableRet for Decimal
[src]
const EVAL_TYPE: EvalType
[src]
type ChunkedType = ChunkedVecSized<Self>
fn cast_chunk_into_vector_value(vec: ChunkedVecSized<Self>) -> VectorValue
[src]
impl From<Decimal> for ScalarValue
[src]
fn from(s: Decimal) -> ScalarValue
[src]
impl From<Decimal> for Datum
[src]
impl From<i16> for Decimal
[src]
impl From<i32> for Decimal
[src]
impl From<i64> for Decimal
[src]
impl From<i8> for Decimal
[src]
impl From<isize> for Decimal
[src]
impl From<u16> for Decimal
[src]
impl From<u32> for Decimal
[src]
impl From<u64> for Decimal
[src]
impl From<u8> for Decimal
[src]
impl From<usize> for Decimal
[src]
impl FromStr for Decimal
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Decimal>
[src]
impl Hash for Decimal
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, 'b> Mul<&'a Decimal> for &'b Decimal
[src]
type Output = Res<Decimal>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'a Decimal) -> Res<Decimal>
[src]
impl Neg for Decimal
[src]
impl Ord for Decimal
[src]
fn cmp(&self, right: &Decimal) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Decimal> for Decimal
[src]
fn eq(&self, right: &Decimal) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Decimal> for Decimal
[src]
fn partial_cmp(&self, right: &Decimal) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> RawDatumDecoder<Decimal> for &'a [u8]
[src]
impl<'a, 'b> Rem<&'a Decimal> for &'b Decimal
[src]
type Output = Option<Res<Decimal>>
The resulting type after applying the %
operator.
fn rem(self, rhs: &'a Decimal) -> Self::Output
[src]
impl Rem<Decimal> for Decimal
[src]
type Output = Option<Res<Decimal>>
The resulting type after applying the %
operator.
fn rem(self, rhs: Decimal) -> Option<Res<Decimal>>
[src]
impl<'a, 'b> Sub<&'a Decimal> for &'b Decimal
[src]
type Output = Res<Decimal>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a Decimal) -> Res<Decimal>
[src]
impl ToInt for Decimal
[src]
fn to_int(&self, ctx: &mut EvalContext, tp: FieldTypeTp) -> Result<i64>
[src]
fn to_uint(&self, ctx: &mut EvalContext, tp: FieldTypeTp) -> Result<u64>
[src]
impl ToString for Decimal
[src]
impl VectorValueExt<Decimal> for VectorValue
[src]
Auto Trait Implementations
impl RefUnwindSafe for Decimal
impl Send for Decimal
impl Sync for Decimal
impl Unpin for Decimal
impl UnwindSafe for Decimal
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<V, W> ConvertFrom<W> for V where
W: ConvertTo<V>,
[src]
W: ConvertTo<V>,
pub fn convert_from(&mut EvalContext, W) -> Result<V, Error>
[src]
impl<T> ConvertTo<NotNan<f64>> for T where
T: ConvertTo<f64> + EvaluableRet,
[src]
T: ConvertTo<f64> + EvaluableRet,
impl<T> ConvertTo<String> for T where
T: ToString + EvaluableRet,
[src]
T: ToString + EvaluableRet,
impl<T> ConvertTo<Vec<u8, Global>> for T where
T: ToString + EvaluableRet,
[src]
T: ToString + EvaluableRet,
impl<T> ConvertTo<i64> for T where
T: ToInt,
[src]
T: ToInt,
impl<T> ConvertTo<u64> for T where
T: ToInt,
[src]
T: ToInt,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,