Skip to content

Commit

Permalink
Remove unneeded rwlock
Browse files Browse the repository at this point in the history
  • Loading branch information
emgeee committed Aug 22, 2024
1 parent 2e98b64 commit a009a1c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions crates/core/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::sync::Arc;
use tokio::sync::RwLock;

use datafusion::common::{DataFusionError, Result};
use datafusion::datasource::TableProvider;
Expand All @@ -16,7 +15,7 @@ use crate::utils::get_default_optimizer_rules;

#[derive(Clone)]
pub struct Context {
pub session_conext: Arc<RwLock<SessionContext>>,
pub session_conext: Arc<SessionContext>,
}

impl Context {
Expand Down Expand Up @@ -45,7 +44,7 @@ impl Context {
.build();

Ok(Self {
session_conext: Arc::new(RwLock::new(SessionContext::new_with_state(state))),
session_conext: Arc::new(SessionContext::new_with_state(state)),
})
}

Expand All @@ -57,8 +56,6 @@ impl Context {

let df = self
.session_conext
.read()
.await
.table(topic_name.as_str())
.await?;

Expand All @@ -75,8 +72,6 @@ impl Context {
table: Arc<impl TableProvider + 'static>,
) -> Result<(), DataFusionError> {
self.session_conext
.write()
.await
.register_table(name.as_str(), table.clone())?;

Ok(())
Expand Down

0 comments on commit a009a1c

Please sign in to comment.