Skip to content

Commit

Permalink
Use std::thread::available_parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
Dandandan committed Nov 27, 2024
1 parent adcb76a commit 91aa989
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use std::{cmp, sync::Arc, thread::available_parallelism};
use std::{cmp, num::NonZero, sync::Arc, thread::available_parallelism};

use datafusion::{
datasource::MemTable,
Expand Down Expand Up @@ -73,7 +73,9 @@ impl SessionContextGenerator {
];

let max_batch_size = cmp::max(1, dataset_ref.total_rows_num);
let max_target_partitions = available_parallelism();
let max_target_partitions = available_parallelism()
.unwrap_or(NonZero::new(1).unwrap())
.get();

Self {
dataset: dataset_ref,
Expand Down

0 comments on commit 91aa989

Please sign in to comment.