Skip to content

Commit 5eb1677

Browse files
committed
add env vars for sort pruning and parquet creation
1 parent 16062ec commit 5eb1677

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/parseable/staging/writer.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use itertools::Itertools;
3838
use once_cell::sync::Lazy;
3939
use rand::distributions::{Alphanumeric, DistString};
4040
use tracing::error;
41+
use ulid::Ulid;
4142

4243
use crate::{
4344
parseable::{ARROW_FILE_EXTENSION, PART_FILE_EXTENSION},
@@ -68,6 +69,17 @@ static ARROW_FLUSH_SIZE_LIMIT: Lazy<usize> = Lazy::new(|| {
6869
}
6970
});
7071

72+
const ONE_PARQUET_PER_ARROW_VAR: &str = "ONE_PARQUET_PER_ARROW";
73+
static ONE_PARQUET_PER_ARROW: Lazy<bool> = Lazy::new(|| {
74+
if let Ok(var) = std::env::var(ONE_PARQUET_PER_ARROW_VAR)
75+
&& let Ok(var) = var.parse::<bool>()
76+
{
77+
var
78+
} else {
79+
false
80+
}
81+
});
82+
7183
#[derive(Default)]
7284
pub struct Writer {
7385
pub mem: MemWriter<4096>,
@@ -279,7 +291,15 @@ impl Drop for DiskWriter {
279291
}
280292

281293
let mut arrow_path = self.path.to_owned();
282-
arrow_path.set_extension(ARROW_FILE_EXTENSION);
294+
295+
// a rudimentary way to ensure one parquet per arrow file
296+
if *ONE_PARQUET_PER_ARROW {
297+
arrow_path.set_extension(Ulid::new().to_string());
298+
#[allow(clippy::incompatible_msrv)]
299+
arrow_path.add_extension(ARROW_FILE_EXTENSION);
300+
} else {
301+
arrow_path.set_extension(ARROW_FILE_EXTENSION);
302+
}
283303

284304
// If file exists, append a random string before .date to avoid overwriting
285305
if arrow_path.exists() {

src/parseable/streams.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ static DISK_WRITE_BATCH_ROWS: Lazy<usize> = Lazy::new(|| {
8585
}
8686
});
8787

88+
const SORT_FOR_METRIC_PRUNING_VAR: &str = "SORT_FOR_METRIC_PRUNING";
89+
static SORT_FOR_METRIC_PRUNING: Lazy<bool> = Lazy::new(|| {
90+
if let Ok(var) = std::env::var(SORT_FOR_METRIC_PRUNING_VAR)
91+
&& let Ok(var) = var.parse::<bool>()
92+
{
93+
var
94+
} else {
95+
true
96+
}
97+
});
98+
8899
const INPROCESS_DIR_PREFIX: &str = "processing_";
89100
const METRIC_ROW_GROUP_PREP_IN_FLIGHT: usize = 1;
90101

@@ -917,7 +928,7 @@ impl Stream {
917928
|s| s.as_str().to_string(),
918929
);
919930

920-
if sort_for_metric_pruning {
931+
if sort_for_metric_pruning && *SORT_FOR_METRIC_PRUNING {
921932
// Buffer batches up to the row-group target, then
922933
// concat + sort + write as a single contiguous batch. The
923934
// ArrowWriter splits the sorted batch into row groups at the

0 commit comments

Comments
 (0)