Skip to content

Commit fb49c29

Browse files
authored
added limit on number of fields in record (#166)
1 parent 7e54801 commit fb49c29

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

coverage.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ echo "line_cov $line_cov"
1717

1818
# enable threshold
1919
#COVERAGE_THRESHOLD=80
20-
FUNC_COV_THRESHOLD=40
21-
LINE_COV_THRESHOLD=35
22-
REGION_COV_THRESHOLD=25
20+
FUNC_COV_THRESHOLD=60
21+
LINE_COV_THRESHOLD=53
22+
REGION_COV_THRESHOLD=40
2323

2424
# clean up
2525
# find ./target -name llvm-cov-target -type d|xargs rm -fR

src/infra/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ pub struct Limit {
196196
pub hb_interval: i64,
197197
// no need set by environment
198198
pub cpu_num: usize,
199+
#[env_config(name = "ZO_COLS_PER_RECORD_LIMIT")]
200+
pub req_cols_per_record_limit: usize,
199201
}
200202

201203
#[derive(Clone, Debug, EnvConfig)]
@@ -316,6 +318,10 @@ pub fn init() -> Config {
316318
panic!("data path config error: {}", e);
317319
}
318320

321+
if cfg.limit.req_cols_per_record_limit == 0 {
322+
cfg.limit.req_cols_per_record_limit = 1000;
323+
}
324+
319325
// check memeory cache
320326
if let Err(e) = check_memory_cache_config(&mut cfg) {
321327
panic!("memory cache config error: {}", e);

src/service/schema.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ pub async fn check_for_schema(
202202
return (true, None);
203203
}
204204

205+
if inferred_schema.fields.len() > CONFIG.limit.req_cols_per_record_limit {
206+
return (false, None);
207+
}
208+
205209
if schema == Schema::empty() {
206210
stream_schema_map.insert(stream_name.to_string(), inferred_schema.clone());
207211
db::schema::set(

0 commit comments

Comments
 (0)