yahoNanJing commented on code in PR #501:
URL: https://github.com/apache/arrow-ballista/pull/501#discussion_r1017800494
##########
ballista/core/src/utils.rs:
##########
@@ -53,25 +56,86 @@ use log::error;
#[cfg(feature = "s3")]
use object_store::aws::AmazonS3Builder;
use object_store::ObjectStore;
+use std::collections::HashMap;
use std::io::{BufWriter, Write};
use std::marker::PhantomData;
+use std::ops::Deref;
use std::sync::atomic::{AtomicUsize, Ordering};
-use std::sync::Arc;
+use std::sync::{Arc, Mutex};
use std::time::Duration;
use std::{fs::File, pin::Pin};
use tonic::codegen::StdError;
use tonic::transport::{Channel, Error, Server};
use url::Url;
+pub trait SessionBuilder: Send + Sync {
+ fn build(&self, config: SessionConfig) ->
crate::error::Result<SessionState>;
+}
+
/// Default session builder using the provided configuration
-pub fn default_session_builder(config: SessionConfig) -> SessionState {
- SessionState::with_config_rt(
- config,
- Arc::new(
-
RuntimeEnv::new(with_object_store_provider(RuntimeConfig::default()))
- .unwrap(),
- ),
- )
+#[derive(Clone)]
+pub struct DefaultSessionBuilder {}
+
+impl SessionBuilder for DefaultSessionBuilder {
+ fn build(&self, config: SessionConfig) ->
crate::error::Result<SessionState> {
+ let rt_cfg = with_object_store_provider(RuntimeConfig::default());
+ let state =
+ SessionState::with_config_rt(config,
Arc::new(RuntimeEnv::new(rt_cfg)?));
+ Ok(state)
+ }
+}
+
+/// Session builder with custom table providers
+#[derive(Clone)]
+pub struct TableProviderSessionBuilder {
+ table_factories: Arc<Mutex<HashMap<String, Arc<dyn
TableProviderFactory>>>>,
Review Comment:
Should we use `DashMap` to replace the `Mutex<HashMap>`, since we have done
the similar change in other places and it will improve the performance under
high throughput scenarios.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]