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

pub struct Json {
    type_code: JsonType,
    pub value: Vec<u8>,
}

Json implements type json used in tikv by Binary Json. The Binary Json format from MySQL 5.7 is in the following link: (https://github.com/mysql/mysql-server/blob/5.7/sql/json_binary.h#L52) The only difference is that we use large object or large array for the small corresponding ones. That means in our implementation there is no difference between small object and big object, so does array.

Fields

type_code: JsonTypevalue: Vec<u8>

The binary encoded json data in bytes

Implementations

impl Json[src]

pub fn merge(bjs: Vec<JsonRef<'_>>) -> Result<Json>[src]

merge is the implementation for JSON_MERGE in mysql https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-merge

The merge rules are listed as following:

  1. adjacent arrays are merged to a single array;
  2. adjacent object are merged to a single object;
  3. a scalar value is autowrapped as an array before merge;
  4. an adjacent array and object are merged by autowrapping the object as an array.

See MergeBinary() in TiDB json/binary_function.go

impl Json[src]

pub fn new(tp: JsonType, value: Vec<u8>) -> Self[src]

Creates a new JSON from the type and encoded bytes

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

Returns the JSON type

pub fn from_string(s: String) -> Result<Self>[src]

Creates a string JSON from a String

pub fn from_str_val(s: &str) -> Result<Self>[src]

Creates a string JSON from a &str

pub fn from_bool(b: bool) -> Result<Self>[src]

Creates a literal JSON from a bool

pub fn from_u64(v: u64) -> Result<Self>[src]

Creates a number JSON from a u64

pub fn from_f64(v: f64) -> Result<Self>[src]

Creates a number JSON from a f64

pub fn from_i64(v: i64) -> Result<Self>[src]

Creates a number JSON from an i64

pub fn from_ref_array(array: Vec<JsonRef<'_>>) -> Result<Self>[src]

Creates a array JSON from a collection of JsonRef

pub fn from_array(array: Vec<Json>) -> Result<Self>[src]

Creates a array JSON from a collection of Json

pub fn from_kv_pairs(entries: Vec<(&[u8], JsonRef<'_>)>) -> Result<Self>[src]

Creates a object JSON from key-value pairs

pub fn from_object(map: BTreeMap<String, Json>) -> Result<Self>[src]

Creates a object JSON from key-value pairs in BTreeMap

pub fn none() -> Result<Self>[src]

Creates a null JSON

pub fn as_ref(&self) -> JsonRef<'_>[src]

Returns a JsonRef points to the starting of encoded bytes

Trait Implementations

impl AsMySQLBool for Json[src]

impl ChunkedVec<Json> for ChunkedVecJson[src]

impl Clone for Json[src]

impl ConvertTo<Decimal> for Json[src]

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

Port from TiDB’s types.ConvertJSONToDecimal

impl ConvertTo<Json> for i64[src]

impl ConvertTo<Json> for f64[src]

impl ConvertTo<Json> for Real[src]

impl ConvertTo<Json> for Decimal[src]

impl ConvertTo<Json> for Time[src]

impl ConvertTo<Json> for Duration[src]

impl ConvertTo<f64> for Json[src]

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

Keep compatible with TiDB’s ConvertJSONToFloat function.

impl Debug for Json[src]

impl<'de> Deserialize<'de> for Json[src]

impl Display for Json[src]

impl Eq for Json[src]

impl EvaluableRet for Json[src]

type ChunkedType = ChunkedVecJson

impl From<Json> for ScalarValue[src]

impl From<Json> for Datum[src]

impl FromStr for Json[src]

type Err = Error

The associated error which can be returned from parsing.

impl Ord for Json[src]

impl PartialEq<Json> for Json[src]

impl PartialOrd<Json> for Json[src]

impl<'a> RawDatumDecoder<Json> for &'a [u8][src]

impl ToInt for Json[src]

impl ToString for Json[src]

impl VectorValueExt<Json> for VectorValue[src]

Auto Trait Implementations

impl RefUnwindSafe for Json

impl Send for Json

impl Sync for Json

impl Unpin for Json

impl UnwindSafe for Json

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<NotNan<f64>> for T where
    T: ConvertTo<f64> + EvaluableRet
[src]

impl<T> ConvertTo<String> for T where
    T: ToString + EvaluableRet
[src]

impl<T> ConvertTo<Vec<u8, Global>> for T where
    T: ToString + EvaluableRet
[src]

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

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

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[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> ToString for T where
    T: Display + ?Sized
[src]

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]