Skip to content

Commit

Permalink
refactor: use binary as grpc value of json
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePieWw committed Aug 28, 2024
1 parent 5e9e417 commit 092ee0c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ etcd-client = { version = "0.13" }
fst = "0.4.7"
futures = "0.3"
futures-util = "0.3"
greptime-proto = { git = "https://github.com/CookiePieWw/greptime-proto.git", rev = "4346f484c14bb8a6711d10906ee6db54a896030a" }
greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "c437b55725b7f5224fe9d46db21072b4a682ee4b" }
humantime = "2.1"
humantime-serde = "1.1"
itertools = "0.10"
Expand Down
21 changes: 9 additions & 12 deletions src/api/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ impl From<ColumnDataTypeWrapper> for ConcreteDataType {
ConcreteDataType::decimal128_default_datatype()
}
}
ColumnDataType::Json => ConcreteDataType::json_datatype(),
}
}
}
Expand Down Expand Up @@ -237,7 +236,7 @@ impl TryFrom<ConcreteDataType> for ColumnDataTypeWrapper {
ConcreteDataType::UInt64(_) => ColumnDataType::Uint64,
ConcreteDataType::Float32(_) => ColumnDataType::Float32,
ConcreteDataType::Float64(_) => ColumnDataType::Float64,
ConcreteDataType::Binary(_) => ColumnDataType::Binary,
ConcreteDataType::Binary(_) | ConcreteDataType::Json(_) => ColumnDataType::Binary,
ConcreteDataType::String(_) => ColumnDataType::String,
ConcreteDataType::Date(_) => ColumnDataType::Date,
ConcreteDataType::DateTime(_) => ColumnDataType::Datetime,
Expand All @@ -259,7 +258,6 @@ impl TryFrom<ConcreteDataType> for ColumnDataTypeWrapper {
IntervalType::MonthDayNano(_) => ColumnDataType::IntervalMonthDayNano,
},
ConcreteDataType::Decimal128(_) => ColumnDataType::Decimal128,
ConcreteDataType::Json(_) => ColumnDataType::Json,
ConcreteDataType::Null(_)
| ConcreteDataType::List(_)
| ConcreteDataType::Dictionary(_)
Expand Down Expand Up @@ -397,10 +395,6 @@ pub fn values_with_capacity(datatype: ColumnDataType, capacity: usize) -> Values
decimal128_values: Vec::with_capacity(capacity),
..Default::default()
},
ColumnDataType::Json => Values {
json_values: Vec::with_capacity(capacity),
..Default::default()
},
}
}

Expand Down Expand Up @@ -575,7 +569,6 @@ pub fn pb_value_to_value_ref<'a>(
))
}
}
ValueData::JsonValue(v) => ValueRef::Json(v),
}
}

Expand Down Expand Up @@ -840,7 +833,12 @@ pub fn is_column_type_value_eq(
expect_type: &ConcreteDataType,
) -> bool {
ColumnDataTypeWrapper::try_new(type_value, type_extension)
.map(|wrapper| ConcreteDataType::from(wrapper) == *expect_type)
.map(|wrapper| {
let datatype = ConcreteDataType::from(wrapper);
(datatype == *expect_type)
|| (datatype == ConcreteDataType::binary_datatype()
&& *expect_type == ConcreteDataType::json_datatype())
})
.unwrap_or(false)
}

Expand Down Expand Up @@ -938,7 +936,7 @@ pub fn to_proto_value(value: Value) -> Option<v1::Value> {
value_data: Some(ValueData::Decimal128Value(convert_to_pb_decimal128(v))),
},
Value::Json(v) => v1::Value {
value_data: Some(ValueData::JsonValue(v.to_vec())),
value_data: Some(ValueData::BinaryValue(v.to_vec())),
},
Value::List(_) | Value::Duration(_) => return None,
};
Expand Down Expand Up @@ -978,7 +976,6 @@ pub fn proto_value_type(value: &v1::Value) -> Option<ColumnDataType> {
ValueData::IntervalDayTimeValue(_) => ColumnDataType::IntervalDayTime,
ValueData::IntervalMonthDayNanoValue(_) => ColumnDataType::IntervalMonthDayNano,
ValueData::Decimal128Value(_) => ColumnDataType::Decimal128,
ValueData::JsonValue(_) => ColumnDataType::Json,
};
Some(value_type)
}
Expand Down Expand Up @@ -1036,7 +1033,7 @@ pub fn value_to_grpc_value(value: Value) -> GrpcValue {
}
}),
Value::Decimal128(v) => Some(ValueData::Decimal128Value(convert_to_pb_decimal128(v))),
Value::Json(v) => Some(ValueData::JsonValue(v.to_vec())),
Value::Json(v) => Some(ValueData::BinaryValue(v.to_vec())),
Value::List(_) | Value::Duration(_) => unreachable!(),
},
}
Expand Down
1 change: 0 additions & 1 deletion src/operator/src/req_convert/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ fn push_column_to_rows(column: Column, rows: &mut [Row]) -> Result<()> {
interval_month_day_nano_values
),
(Decimal128, Decimal128Value, decimal128_values),
(Json, JsonValue, json_values),
);

Ok(())
Expand Down

0 comments on commit 092ee0c

Please sign in to comment.