mirror of
https://github.com/roapi/roapi.git
synced 2026-06-05 21:04:02 +08:00
avoid schema_map deepcopy (#150)
This commit is contained in:
parent
03f07b3b27
commit
9cdfb4a555
@ -36,13 +36,6 @@ impl ColumnQ {
|
||||
&self.schema_map
|
||||
}
|
||||
|
||||
pub fn serializable_schema_map(&self) -> HashMap<&String, &arrow::datatypes::Schema> {
|
||||
self.schema_map
|
||||
.iter()
|
||||
.map(|(k, v)| (k, v.as_ref()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub async fn query_graphql(
|
||||
&self,
|
||||
query: &str,
|
||||
|
||||
@ -30,7 +30,7 @@ pin-project = "1"
|
||||
|
||||
env_logger = "0"
|
||||
log = "0"
|
||||
serde = "1"
|
||||
serde = { version = "1", features = ["rc"] }
|
||||
serde_json = "1"
|
||||
serde_derive = "1"
|
||||
serde_yaml = "0.8"
|
||||
|
||||
@ -8,7 +8,7 @@ pub async fn schema(
|
||||
state: extract::Extension<Arc<HandlerContext>>,
|
||||
) -> Result<impl IntoResponse, ApiErrResp> {
|
||||
let ctx = state.0;
|
||||
let schema = ctx.cq.serializable_schema_map();
|
||||
let schema = ctx.cq.schema_map();
|
||||
let payload = serde_json::to_vec(&schema)
|
||||
.map_err(columnq::error::ColumnQError::from)
|
||||
.map_err(ApiErrResp::json_serialization)?;
|
||||
@ -22,9 +22,10 @@ pub async fn get_by_table_name(
|
||||
let ctx = state.0;
|
||||
let payload = serde_json::to_vec(
|
||||
ctx.cq
|
||||
.serializable_schema_map()
|
||||
.schema_map()
|
||||
.get(&table_name)
|
||||
.ok_or_else(|| ApiErrResp::not_found("invalid table name"))?,
|
||||
.ok_or_else(|| ApiErrResp::not_found("invalid table name"))?
|
||||
.as_ref(),
|
||||
)
|
||||
.map_err(columnq::error::ColumnQError::from)
|
||||
.map_err(ApiErrResp::json_serialization)?;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user