-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If we want to keep opportunities to parallelize this code, all the errors related to the same object should be addressed together. It will become important when some `Operation::Update` will happen and need to be ordered correctly.
- Loading branch information
1 parent
84d57c2
commit 24faeea
Showing
10 changed files
with
490 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use super::{new_ref_fix_delete_pair, Fix}; | ||
use crate::schema::{ | ||
BufferStopCache, InfraError, InfraErrorType, OSRDObject as _, ObjectRef, ObjectType, | ||
}; | ||
use log::debug; | ||
use std::collections::HashMap; | ||
|
||
pub fn fix_buffer_stop( | ||
buffer_stop: &BufferStopCache, | ||
errors: impl Iterator<Item = InfraError>, | ||
) -> HashMap<ObjectRef, Fix> { | ||
errors | ||
.filter_map(|infra_error| match infra_error.get_sub_type() { | ||
InfraErrorType::OddBufferStopLocation | InfraErrorType::OutOfRange { .. } => { | ||
Some(new_ref_fix_delete_pair(buffer_stop)) | ||
} | ||
InfraErrorType::InvalidReference { reference } | ||
if reference.obj_type == ObjectType::TrackSection => | ||
{ | ||
Some(new_ref_fix_delete_pair(buffer_stop)) | ||
} | ||
_ => { | ||
debug!("error not (yet) fixable for '{}'", infra_error.get_type()); | ||
None | ||
} | ||
}) | ||
.collect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use super::{new_ref_fix_delete_pair, Fix}; | ||
use crate::schema::{Catenary, InfraError, InfraErrorType, OSRDObject as _, ObjectRef}; | ||
use log::debug; | ||
use std::collections::HashMap; | ||
|
||
pub fn fix_catenary( | ||
catenary: &Catenary, | ||
errors: impl Iterator<Item = InfraError>, | ||
) -> HashMap<ObjectRef, Fix> { | ||
errors | ||
.filter_map(|infra_error| match infra_error.get_sub_type() { | ||
InfraErrorType::EmptyObject => Some(new_ref_fix_delete_pair(catenary)), | ||
_ => { | ||
debug!("error not (yet) fixable for '{}'", infra_error.get_type()); | ||
None | ||
} | ||
}) | ||
.collect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use super::{new_ref_fix_delete_pair, Fix}; | ||
use crate::schema::{ | ||
DetectorCache, InfraError, InfraErrorType, OSRDObject as _, ObjectRef, ObjectType, | ||
}; | ||
use log::debug; | ||
use std::collections::HashMap; | ||
|
||
pub fn fix_detector( | ||
detector: &DetectorCache, | ||
errors: impl Iterator<Item = InfraError>, | ||
) -> HashMap<ObjectRef, Fix> { | ||
errors | ||
.filter_map(|infra_error| match infra_error.get_sub_type() { | ||
InfraErrorType::OutOfRange { .. } => Some(new_ref_fix_delete_pair(detector)), | ||
InfraErrorType::InvalidReference { reference } | ||
if reference.obj_type == ObjectType::TrackSection => | ||
{ | ||
Some(new_ref_fix_delete_pair(detector)) | ||
} | ||
_ => { | ||
debug!("error not (yet) fixable for '{}'", infra_error.get_type()); | ||
None | ||
} | ||
}) | ||
.collect() | ||
} |
Oops, something went wrong.