Skip to content

Commit

Permalink
fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Skgland committed Jul 24, 2021
1 parent 2d4ebd7 commit 7436319
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
2 changes: 1 addition & 1 deletion rta-for-fps-latex-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn main() -> std::io::Result<()> {
servers[0].constraint_demand_curve_iter(),
));
let hp_load_first24 =
CurveSplitIterator::new(hp_load.clone(), limit).take_while(|window| window.end <= limit);
CurveSplitIterator::new(hp_load, limit).take_while(|window| window.end <= limit);

std::fs::write(
"latex/data/external_load.tex",
Expand Down
13 changes: 8 additions & 5 deletions rta-for-fps-lib/src/iterators/curve/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,10 @@ impl<S, D, SI, DI> CurveDeltaIterator<D, S, DI, SI> {

/// Turn the `CurveDeltaIterator` into a `CurveIterator` that returns only the Overlap Windows
#[must_use]
pub fn overlap<C: CurveType<WindowKind = Overlap<S, D>>>(
self,
) -> OverlapIterator<DI, SI, D, S, C>
pub fn overlap<C>(self) -> OverlapIterator<DI, SI, D, S, C>
where
Self: Iterator<Item = Delta<D, S, DI, SI>>,
Self: Clone + Debug,
Self: Iterator<Item = Delta<D, S, DI, SI>> + Debug,
C: CurveType<WindowKind = Overlap<S, D>>,
{
let fun: fn(_) -> _ = Delta::overlap;
let inner = self.filter_map(fun);
Expand All @@ -234,7 +232,11 @@ impl<S, D, SI, DI> CurveDeltaIterator<D, S, DI, SI> {
}
}

/// Iterator Adapter for filtering a `CurveDeltaIterator` into only the overlap
///
/// See [`CurveDeltaIterator::overlap`]
#[derive(Clone, Debug)]
#[allow(clippy::type_complexity)]
pub struct OverlapIterator<DI, SI, DW, SW, C>(
IterCurveWrapper<
FilterMap<
Expand Down Expand Up @@ -267,6 +269,7 @@ impl<DI: CurveIterator, SI: CurveIterator>
>
{
/// Create a new Iterator for computing the delta between the supply and demand curve
#[must_use]
pub fn new(supply: SI, demand: DI) -> Self {
CurveDeltaIterator {
demand: Some(Peeker::new(Box::new(demand).into_iterator())),
Expand Down
23 changes: 16 additions & 7 deletions rta-for-fps-lib/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ pub struct System<'a> {
/// The Servers of the System
servers: &'a [Server<'a>],
}

/**
A `CurveIterator` over a servers aggregated higher priority demand
*/
#[derive(Clone, Debug)]
pub struct AggregatedHPDemand<CSD>(
pub struct AggregatedHPServerDemand<CSD>(
ReclassifyIterator<
AggregationIterator<CSD, <ConstrainedServerDemand as CurveType>::WindowKind>,
HigherPriorityServerDemand,
>,
);

impl<CSD> CurveIterator for AggregatedHPDemand<CSD>
impl<CSD> CurveIterator for AggregatedHPServerDemand<CSD>
where
CSD: CurveIterator<CurveKind = ConstrainedServerDemand>,
{
Expand Down Expand Up @@ -68,9 +70,12 @@ impl CurveIterator for AggregatedHPExecution {
}
}

/**
A `CurveIterator` over a servers unconstrained execution using the original algorithm
*/
#[derive(Clone, Debug)]
pub struct OriginalUnconstrainedExecution(
InverseCurveIterator<AggregatedHPDemand<ConstrainedDemand>, UnconstrainedServerExecution>,
InverseCurveIterator<AggregatedHPServerDemand<ConstrainedDemand>, UnconstrainedServerExecution>,
);

impl CurveIterator for OriginalUnconstrainedExecution {
Expand All @@ -97,7 +102,11 @@ impl CurveIterator for FixedUnconstrainedExecution {
}
}

/**
A `CurveIterator` over a Servers actual execution using the original algorithm
*/
#[derive(Clone, Debug)]
#[allow(clippy::type_complexity)]
pub struct OriginalActualServerExecution(
ActualServerExecutionIterator<
CapacityCheckIterator<
Expand All @@ -118,7 +127,7 @@ impl CurveIterator for OriginalActualServerExecution {
}

/**
A `CurveIterator` over a Servers actual execution
A `CurveIterator` over a Servers actual execution using the fixed algorithm
*/
#[derive(Clone, Debug)]
#[allow(clippy::type_complexity)]
Expand Down Expand Up @@ -164,15 +173,15 @@ impl<'a> System<'a> {
#[must_use]
pub fn aggregated_higher_priority_demand_curve_iter<'b, CSDCI>(
constrained_demand_curves: CSDCI,
) -> AggregatedHPDemand<CSDCI::Item>
) -> AggregatedHPServerDemand<CSDCI::Item>
where
CSDCI::Item: CurveIterator<CurveKind = ConstrainedServerDemand> + Clone + 'b,
CSDCI: IntoIterator,
{
let ahpd = constrained_demand_curves
.into_iter()
.aggregate::<ReclassifyIterator<_, _>>();
AggregatedHPDemand(ahpd)
AggregatedHPServerDemand(ahpd)
}

/**
Expand Down
35 changes: 25 additions & 10 deletions rta-for-fps-lib/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub struct Task {
pub interval: TimeUnit,
}

/**
A `CurveIterator` over a tasks available execution curve
*/
#[derive(Clone, Debug)]
pub struct AvailableExecution<HPTD, ASEC>(
ReclassifyIterator<
Expand Down Expand Up @@ -78,11 +81,14 @@ where
}
}

/**
A `CurveIterator` over the actual task execution of a task using the original algorithm
*/
#[derive(Clone, Debug)]
pub struct OriginalActualTaskExecution(
OverlapIterator<
TaskDemandIterator,
AvailableExecution<AggregatedHPDemand, OriginalActualServerExecution>,
AvailableExecution<AggregatedHPTaskDemand, OriginalActualServerExecution>,
Demand,
<AvailableTaskExecution as CurveType>::WindowKind,
ActualTaskExecution,
Expand All @@ -97,11 +103,14 @@ impl CurveIterator for OriginalActualTaskExecution {
}
}

/**
A `CurveIterator` over the actual task execution of a task using the fixed algorithm
*/
#[derive(Clone, Debug)]
pub struct FixedActualTaskExecution(
OverlapIterator<
TaskDemandIterator,
AvailableExecution<AggregatedHPDemand, FixedActualExecution>,
AvailableExecution<AggregatedHPTaskDemand, FixedActualExecution>,
Demand,
<AvailableTaskExecution as CurveType>::WindowKind,
ActualTaskExecution,
Expand All @@ -116,12 +125,15 @@ impl CurveIterator for FixedActualTaskExecution {
}
}

/**
* A `CurveIterator` over a tasks aggregated higher priority task demand
*/
#[derive(Clone, Debug)]
pub struct AggregatedHPDemand(
pub struct AggregatedHPTaskDemand(
ReclassifyIterator<AggregationIterator<TaskDemandIterator, Demand>, HigherPriorityTaskDemand>,
);

impl CurveIterator for AggregatedHPDemand {
impl CurveIterator for AggregatedHPTaskDemand {
type CurveKind = HigherPriorityTaskDemand;

fn next_window(&mut self) -> Option<Window<<Self::CurveKind as CurveType>::WindowKind>> {
Expand Down Expand Up @@ -153,8 +165,11 @@ impl Task {
/// calculate the Higher Priority task Demand for the task with priority `index` as defined in Definition 14. (1) in the paper,
/// for a set of tasks indexed by their priority (lower index <=> higher priority) and up to the specified limit
#[must_use]
pub fn higher_priority_task_demand_iter(tasks: &[Self], index: usize) -> AggregatedHPDemand {
AggregatedHPDemand(
pub fn higher_priority_task_demand_iter(
tasks: &[Self],
index: usize,
) -> AggregatedHPTaskDemand {
AggregatedHPTaskDemand(
tasks[..index]
.iter()
.map(|task| task.into_iter())
Expand Down Expand Up @@ -192,8 +207,8 @@ impl Task {
///
/// Based on Definition 14. (3) of the paper
#[must_use]
pub fn original_actual_execution_curve_iter<'a>(
system: &'a System,
pub fn original_actual_execution_curve_iter(
system: &System,
server_index: usize,
task_index: usize,
) -> OriginalActualTaskExecution {
Expand All @@ -219,8 +234,8 @@ impl Task {
instead of aggregated higher priority server constrained demand for the computation
*/
#[must_use]
pub fn fixed_actual_execution_curve_iter<'a>(
system: &'a System,
pub fn fixed_actual_execution_curve_iter(
system: &System,
server_index: usize,
task_index: usize,
) -> FixedActualTaskExecution {
Expand Down

0 comments on commit 7436319

Please sign in to comment.