Struct tidb_query_datatype::codec::mysql::json::JsonRef[][src]

pub struct JsonRef<'a> {
    type_code: JsonType,
    value: &'a [u8],
}

Represents a reference of JSON value aiming to reduce memory copy.

Fields

type_code: JsonTypevalue: &'a [u8]

Implementations

impl<'a> JsonRef<'a>[src]

pub fn array_get_elem(&self, idx: usize) -> Result<JsonRef<'a>>[src]

Gets the ith element in JsonRef

See arrayGetElem() in TiDB json/binary.go

pub fn object_get_key(&self, i: usize) -> &'a [u8][src]

Return the ith key in current Object json

See arrayGetElem() in TiDB json/binary.go

pub fn object_get_val(&self, i: usize) -> Result<JsonRef<'a>>[src]

Returns the JsonRef of ith value in current Object json

See arrayGetElem() in TiDB json/binary.go

pub fn object_search_key(&self, key: &[u8]) -> Option<usize>[src]

Searches the value index by the give key in Object.

See objectSearchKey() in TiDB json/binary_function.go

pub fn val_entry_get(&self, val_entry_off: usize) -> Result<JsonRef<'a>>[src]

Gets the value (JsonRef) by the given offset of the value entry

See arrayGetElem() in TiDB json/binary.go

pub(super) fn as_ptr(&self) -> *const u8[src]

Returns a raw pointer to the underlying values buffer.

pub(super) fn as_literal(&self) -> Result<u8>[src]

Returns the literal value of JSON document

pub fn binary_len(&self) -> usize[src]

Returns the encoding binary length of self

impl<'a> JsonRef<'a>[src]

fn get_precedence(&self) -> i32[src]

fn as_f64(&self) -> Result<f64>[src]

impl<'a> JsonRef<'a>[src]

fn encoded_len(&self) -> usize[src]

impl<'a> JsonRef<'a>[src]

pub fn depth(&self) -> Result<i64>[src]

Returns maximum depth of JSON document

impl<'a> JsonRef<'a>[src]

pub fn extract(&self, path_expr_list: &[PathExpression]) -> Result<Option<Json>>[src]

extract receives several path expressions as arguments, matches them in j, and returns the target JSON matched any path expressions, which may be autowrapped as an array. If there is no any expression matched, it returns None.

See Extract() in TiDB json.binary_function.go

impl<'a> JsonRef<'a>[src]

pub fn keys(&self, path_expr_list: &[PathExpression]) -> Result<Option<Json>>[src]

Evaluates a (possibly empty) list of values and returns a JSON array containing those values specified by path_expr_list

impl<'a> JsonRef<'a>[src]

fn len(&self) -> i64[src]

pub fn json_length(
    &self,
    path_expr_list: &[PathExpression]
) -> Result<Option<i64>>
[src]

json_length is the implementation for JSON_LENGTH in mysql https://dev.mysql.com/doc/refman/5.7/en/json-attribute-functions.html#function_json-length

impl<'a> JsonRef<'a>[src]

pub fn modify(
    &self,
    path_expr_list: &[PathExpression],
    values: Vec<Json>,
    mt: ModifyType
) -> Result<Json>
[src]

Modifies a Json object by insert, replace or set. All path expressions cannot contain * or ** wildcard. If any error occurs, the input won’t be changed.

See Modify() in TiDB json/binary_function.go

impl<'a> JsonRef<'a>[src]

pub fn remove(&self, path_expr_list: &[PathExpression]) -> Result<Json>[src]

Removes elements from Json, All path expressions cannot contain * or ** wildcard. If any error occurs, the input won’t be changed.

impl<'a> JsonRef<'a>[src]

pub fn json_type(&self) -> &'static [u8][src]

impl<'a> JsonRef<'a>[src]

pub fn unquote(&self) -> Result<String>[src]

unquote recognizes the escape sequences shown in: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html json-unquote-character-escape-sequences

See Unquote() in TiDB json/binary_function.go

impl<'a> JsonRef<'a>[src]

pub fn new(type_code: JsonType, value: &[u8]) -> JsonRef<'_>[src]

pub fn to_owned(&self) -> Json[src]

Returns an owned Json via copying

pub fn get_type(&self) -> JsonType[src]

Returns the JSON type

pub fn value(&self) -> &'a [u8][src]

Returns the underlying value slice

pub(crate) fn get_u64(&self) -> u64[src]

pub(crate) fn get_i64(&self) -> i64[src]

pub(crate) fn get_double(&self) -> f64[src]

pub(crate) fn get_elem_count(&self) -> usize[src]

pub(crate) fn get_literal(&self) -> Option<bool>[src]

pub(crate) fn get_str_bytes(&self) -> Result<&'a [u8]>[src]

pub(crate) fn get_str(&self) -> Result<&'a str>[src]

pub(crate) fn is_zero(&self) -> bool[src]

Trait Implementations

impl<'a> AsMySQLBool for JsonRef<'a>[src]

impl<'a> ChunkRef<'a, JsonRef<'a>> for &'a ChunkedVecJson[src]

impl<'a> Clone for JsonRef<'a>[src]

impl<'a> ConvertTo<Decimal> for JsonRef<'a>[src]

fn convert(&self, ctx: &mut EvalContext) -> Result<Decimal>[src]

Port from TiDB’s types.ConvertJSONToDecimal

impl<'a> ConvertTo<NotNan<f64>> for JsonRef<'a>[src]

impl<'a> ConvertTo<String> for JsonRef<'a>[src]

impl<'a> ConvertTo<Vec<u8, Global>> for JsonRef<'a>[src]

impl<'a> ConvertTo<f64> for JsonRef<'a>[src]

fn convert(&self, ctx: &mut EvalContext) -> Result<f64>[src]

Keep compatible with TiDB’s ConvertJSONToFloat function.

impl<'a> Copy for JsonRef<'a>[src]

impl<'a> Debug for JsonRef<'a>[src]

impl<'a> Eq for JsonRef<'a>[src]

impl<'a> EvaluableRef<'a> for JsonRef<'a>[src]

type EvaluableType = Json

type ChunkedType = &'a ChunkedVecJson

impl<'a> Ord for JsonRef<'a>[src]

impl<'a> PartialEq<JsonRef<'a>> for JsonRef<'a>[src]

impl<'a> PartialOrd<JsonRef<'a>> for JsonRef<'a>[src]

impl<'a> Serialize for JsonRef<'a>[src]

impl<'a> ToInt for JsonRef<'a>[src]

impl<'a> ToString for JsonRef<'a>[src]

fn to_string(&self) -> String[src]

This function is a simple combination and rewrite of serde_json’s to_writer_pretty

impl<'a> UnsafeRefInto<JsonRef<'static>> for JsonRef<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for JsonRef<'a>

impl<'a> Send for JsonRef<'a>

impl<'a> Sync for JsonRef<'a>

impl<'a> Unpin for JsonRef<'a>

impl<'a> UnwindSafe for JsonRef<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<V, W> ConvertFrom<W> for V where
    W: ConvertTo<V>, 
[src]

impl<T> ConvertTo<i64> for T where
    T: ToInt
[src]

impl<T> ConvertTo<u64> for T where
    T: ToInt
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> Sealed<T> for T where
    T: ?Sized
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]