This commit is contained in:
Rodrigo Racanicci 2023-03-07 16:22:22 -03:00
Родитель 7f7b25b849
Коммит b80855eba9
16 изменённых файлов: 70 добавлений и 61 удалений

2
.vscode/settings.json поставляемый
Просмотреть файл

@ -27,5 +27,5 @@
"[python]": {
"editor.defaultFormatter": "ms-python.python"
},
"cSpell.enabled": true
"rust-analyzer.check.command": "clippy"
}

Просмотреть файл

@ -17,7 +17,9 @@
"git:precommit": "lint-staged",
"git:ci": "run-s format:check lint:check test build",
"release:wasm": "npm-publish --access public --token ${NPM_TOKEN} ./target/wasm/package.json",
"release": "run-p release:wasm"
"release": "run-p release:wasm",
"rust:format": "cargo fmt --all --",
"rust:check": "cargo clippy -- -D warnings && cargo fmt --all -- --check && cargo test"
},
"prettier": "@essex/prettier-config",
"devDependencies": {

Просмотреть файл

@ -33,16 +33,19 @@ pub struct DataBlock {
pub records: DataBlockRecords,
}
impl DataBlock {
impl Default for DataBlock {
/// Returns a new DataBlock with default values
pub fn default() -> DataBlock {
DataBlock {
#[inline]
fn default() -> Self {
Self {
headers: DataBlockHeaders::default(),
multi_value_column_metadata_map: MultiValueColumnMetadataMap::default(),
records: DataBlockRecords::default(),
}
}
}
impl DataBlock {
/// Returns a new DataBlock
/// # Arguments
/// * `headers` - Vector of string representing the data headers

Просмотреть файл

@ -54,11 +54,11 @@ pub struct AggregatedData {
pub reporting_length: usize,
}
impl AggregatedData {
impl Default for AggregatedData {
/// Creates a new AggregatedData struct with default values
#[inline]
pub fn default() -> AggregatedData {
AggregatedData {
fn default() -> Self {
Self {
headers: DataBlockHeaders::default(),
multi_value_column_metadata_map: MultiValueColumnMetadataMap::default(),
number_of_records: 0,
@ -68,7 +68,9 @@ impl AggregatedData {
reporting_length: 0,
}
}
}
impl AggregatedData {
/// Creates a new AggregatedData struct
/// # Arguments:
/// * `headers` - Vector of strings representing the data headers

Просмотреть файл

@ -27,11 +27,11 @@ pub struct RecordsAnalysis {
pub percentage_of_records_with_risky_combinations: f64,
}
impl RecordsAnalysis {
#[inline]
impl Default for RecordsAnalysis {
/// Created a new RecordsAnalysis with default values
pub fn default() -> RecordsAnalysis {
RecordsAnalysis {
#[inline]
fn default() -> Self {
Self {
number_of_records_with_unique_combinations: 0,
percentage_of_records_with_unique_combinations: 0.0,
number_of_records_with_rare_combinations: 0,

Просмотреть файл

@ -19,13 +19,15 @@ pub struct ValueCombination {
combination: Vec<Arc<DataBlockValue>>,
}
impl ValueCombination {
#[inline]
impl Default for ValueCombination {
/// Creates a new ValueCombination with default values
pub fn default() -> ValueCombination {
ValueCombination::new(Vec::default())
#[inline]
fn default() -> Self {
Self::new(Vec::default())
}
}
impl ValueCombination {
#[inline]
/// Creates a new ValueCombination
/// # Arguments

Просмотреть файл

@ -16,12 +16,15 @@ use crate::processing::evaluator::preservation_by_length::PreservationByLengthBu
/// Evaluates aggregated, sensitive and synthesized data
pub struct Evaluator {}
impl Evaluator {
impl Default for Evaluator {
/// Returns a new Evaluator
pub fn default() -> Evaluator {
Evaluator {}
#[inline]
fn default() -> Self {
Self {}
}
}
impl Evaluator {
fn calc_combinations_abs_error_sum_count_by_len(
&self,
sensitive_aggregated_data: &AggregatedData,

Просмотреть файл

@ -18,10 +18,11 @@ pub struct PreservationBucket {
pub proportional_error_sum: f64,
}
impl PreservationBucket {
impl Default for PreservationBucket {
/// Return a new PreservationBucket with default values
pub fn default() -> PreservationBucket {
PreservationBucket {
#[inline]
fn default() -> Self {
Self {
size: 0,
preservation_sum: 0.0,
length_sum: 0,
@ -29,7 +30,9 @@ impl PreservationBucket {
proportional_error_sum: 0.0,
}
}
}
impl PreservationBucket {
/// Adds a new value to the bucket
/// # Arguments
/// * `preservation` - Preservation related to the value

Просмотреть файл

@ -27,15 +27,17 @@ pub struct PreservationByCountBuckets {
buckets_map: PreservationBucketsMap,
}
impl PreservationByCountBuckets {
impl Default for PreservationByCountBuckets {
/// Returns a new default PreservationByCountBuckets
#[inline]
pub fn default() -> PreservationByCountBuckets {
PreservationByCountBuckets {
fn default() -> Self {
Self {
buckets_map: PreservationBucketsMap::default(),
}
}
}
impl PreservationByCountBuckets {
#[inline]
pub(super) fn populate(
&mut self,

Просмотреть файл

@ -17,15 +17,17 @@ pub struct PreservationByLengthBuckets {
buckets_map: PreservationBucketsMap,
}
impl PreservationByLengthBuckets {
impl Default for PreservationByLengthBuckets {
/// Returns a new default PreservationByLengthBuckets
#[inline]
pub fn default() -> PreservationByLengthBuckets {
PreservationByLengthBuckets {
fn default() -> Self {
Self {
buckets_map: PreservationBucketsMap::default(),
}
}
}
impl PreservationByLengthBuckets {
#[inline]
pub(super) fn populate(
&mut self,

Просмотреть файл

@ -27,17 +27,19 @@ pub struct GeneratedData {
pub multi_value_column_metadata_map: MultiValueColumnMetadataMap,
}
impl GeneratedData {
impl Default for GeneratedData {
/// Returns a new GeneratedData struct with default values
#[inline]
pub fn default() -> GeneratedData {
GeneratedData {
fn default() -> Self {
Self {
synthetic_data: RawData::default(),
expansion_ratio: 0.0,
multi_value_column_metadata_map: MultiValueColumnMetadataMap::default(),
}
}
}
impl GeneratedData {
/// Returns a new GeneratedData struct
/// # Arguments
/// * `synthetic_data` - Synthesized data headers (index 0) and records indexes 1...

Просмотреть файл

@ -14,14 +14,16 @@ pub struct WasmAggregateResult {
pub(crate) aggregated_data: Arc<AggregatedData>,
}
impl WasmAggregateResult {
impl Default for WasmAggregateResult {
#[inline]
pub fn default() -> WasmAggregateResult {
WasmAggregateResult {
fn default() -> Self {
Self {
aggregated_data: Arc::new(AggregatedData::default()),
}
}
}
impl WasmAggregateResult {
#[inline]
pub fn new(aggregated_data: Arc<AggregatedData>) -> WasmAggregateResult {
WasmAggregateResult { aggregated_data }

Просмотреть файл

@ -5,6 +5,7 @@ use wasm_bindgen::{prelude::*, JsCast};
use crate::utils::js::{JsGenerateResult, JsResult};
#[derive(Default)]
#[wasm_bindgen]
pub struct WasmGenerateResult {
generated_data: GeneratedData,
@ -12,14 +13,6 @@ pub struct WasmGenerateResult {
}
impl WasmGenerateResult {
#[inline]
pub fn default() -> WasmGenerateResult {
WasmGenerateResult {
generated_data: GeneratedData::default(),
resolution: 0,
}
}
#[inline]
pub fn new(generated_data: GeneratedData, resolution: usize) -> WasmGenerateResult {
WasmGenerateResult {

Просмотреть файл

@ -36,10 +36,10 @@ pub struct WasmNavigateResult {
column_index_by_name: ColumnIndexByName,
}
impl WasmNavigateResult {
impl Default for WasmNavigateResult {
#[inline]
pub fn default() -> WasmNavigateResult {
WasmNavigateResult::new(
fn default() -> Self {
Self::new(
HeaderNames::default(),
Arc::new(DataBlock::default()),
AttributeRowsByColumnMap::default(),
@ -49,7 +49,9 @@ impl WasmNavigateResult {
ColumnIndexByName::default(),
)
}
}
impl WasmNavigateResult {
#[inline]
pub fn new(
header_names: HeaderNames,

Просмотреть файл

@ -28,6 +28,7 @@ use crate::{
},
};
#[derive(Default)]
#[wasm_bindgen]
pub struct WasmSdsContext {
sensitive_data_params: Option<WasmCsvDataParameters>,
@ -45,19 +46,8 @@ pub struct WasmSdsContext {
#[wasm_bindgen]
impl WasmSdsContext {
#[wasm_bindgen(constructor)]
pub fn default() -> Self {
WasmSdsContext {
sensitive_data_params: None,
sensitive_processor: None,
synthetic_processor: None,
sensitive_aggregate_result: None,
reportable_aggregate_result: None,
synthetic_aggregate_result: None,
generate_result: None,
pre_computed_aggregates: false,
evaluate_result: None,
navigate_result: None,
}
pub fn new_default() -> Self {
Self::default()
}
#[wasm_bindgen(js_name = "clear")]

Просмотреть файл

@ -29,9 +29,10 @@ pub struct WasmSdsProcessor {
pub(crate) data_block: Arc<DataBlock>,
}
impl WasmSdsProcessor {
pub fn default() -> WasmSdsProcessor {
WasmSdsProcessor {
impl Default for WasmSdsProcessor {
#[inline]
fn default() -> Self {
Self {
data_block: Arc::new(DataBlock::default()),
}
}