avoid schema_map deepcopy (#150)

This commit is contained in:
QP Hou 2022-02-25 23:44:06 -08:00 committed by GitHub
parent 03f07b3b27
commit 9cdfb4a555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 11 deletions

View File

@ -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,

View File

@ -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"

View File

@ -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)?;