|
@@ -1374,8 +1374,7 @@ func (sasr *SummaryAllocationSetRange) AggregateBy(aggregateBy []string, options
|
|
|
|
|
|
|
|
// Append appends the given AllocationSet to the end of the range. It does not
|
|
// Append appends the given AllocationSet to the end of the range. It does not
|
|
|
// validate whether or not that violates window continuity.
|
|
// validate whether or not that violates window continuity.
|
|
|
-func (sasr *SummaryAllocationSetRange) Append(sas *SummaryAllocationSet) error {
|
|
|
|
|
-
|
|
|
|
|
|
|
+func (sasr *SummaryAllocationSetRange) Append(sas *SummaryAllocationSet) {
|
|
|
sasr.Lock()
|
|
sasr.Lock()
|
|
|
defer sasr.Unlock()
|
|
defer sasr.Unlock()
|
|
|
|
|
|
|
@@ -1394,8 +1393,6 @@ func (sasr *SummaryAllocationSetRange) Append(sas *SummaryAllocationSet) error {
|
|
|
if sasr.Window.End() == nil || (sas.Window.End() != nil && sas.Window.End().After(*sasr.Window.End())) {
|
|
if sasr.Window.End() == nil || (sas.Window.End() != nil && sas.Window.End().After(*sasr.Window.End())) {
|
|
|
sasr.Window.end = sas.Window.End()
|
|
sasr.Window.end = sas.Window.End()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return nil
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Each invokes the given function for each AllocationSet in the range
|
|
// Each invokes the given function for each AllocationSet in the range
|
|
@@ -1513,8 +1510,7 @@ func (sasr *SummaryAllocationSetRange) Accumulate(accumulateBy AccumulateOption)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (sasr *SummaryAllocationSetRange) accumulateByNone() (*SummaryAllocationSetRange, error) {
|
|
func (sasr *SummaryAllocationSetRange) accumulateByNone() (*SummaryAllocationSetRange, error) {
|
|
|
- result, err := sasr.clone()
|
|
|
|
|
- return result, err
|
|
|
|
|
|
|
+ return sasr.clone(), nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (sasr *SummaryAllocationSetRange) accumulateByAll() (*SummaryAllocationSetRange, error) {
|
|
func (sasr *SummaryAllocationSetRange) accumulateByAll() (*SummaryAllocationSetRange, error) {
|
|
@@ -1535,8 +1531,9 @@ func (sasr *SummaryAllocationSetRange) accumulateByHour() (*SummaryAllocationSet
|
|
|
return nil, fmt.Errorf("window duration must equal 1 hour; got:%s", sasr.SummaryAllocationSets[0].Window.Duration())
|
|
return nil, fmt.Errorf("window duration must equal 1 hour; got:%s", sasr.SummaryAllocationSets[0].Window.Duration())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- result, err := sasr.clone()
|
|
|
|
|
- return result, err
|
|
|
|
|
|
|
+ result := sasr.clone()
|
|
|
|
|
+
|
|
|
|
|
+ return result, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (sasr *SummaryAllocationSetRange) accumulateByDay() (*SummaryAllocationSetRange, error) {
|
|
func (sasr *SummaryAllocationSetRange) accumulateByDay() (*SummaryAllocationSetRange, error) {
|
|
@@ -1560,10 +1557,7 @@ func (sasr *SummaryAllocationSetRange) accumulateByDay() (*SummaryAllocationSetR
|
|
|
as = as.Clone()
|
|
as = as.Clone()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- err := toAccumulate.Append(as)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, fmt.Errorf("error building accumulation: %s", err)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ toAccumulate.Append(as)
|
|
|
sas, err := toAccumulate.accumulate()
|
|
sas, err := toAccumulate.accumulate()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("error accumulating result: %s", err)
|
|
return nil, fmt.Errorf("error accumulating result: %s", err)
|
|
@@ -1574,10 +1568,7 @@ func (sasr *SummaryAllocationSetRange) accumulateByDay() (*SummaryAllocationSetR
|
|
|
if length := len(toAccumulate.SummaryAllocationSets); length != 1 {
|
|
if length := len(toAccumulate.SummaryAllocationSets); length != 1 {
|
|
|
return nil, fmt.Errorf("failed accumulation, detected %d sets instead of 1", length)
|
|
return nil, fmt.Errorf("failed accumulation, detected %d sets instead of 1", length)
|
|
|
}
|
|
}
|
|
|
- err = result.Append(toAccumulate.SummaryAllocationSets[0])
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, fmt.Errorf("error building result accumulation: %s", err)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ result.Append(toAccumulate.SummaryAllocationSets[0])
|
|
|
toAccumulate = nil
|
|
toAccumulate = nil
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1601,10 +1592,7 @@ func (sasr *SummaryAllocationSetRange) accumulateByMonth() (*SummaryAllocationSe
|
|
|
as = as.Clone()
|
|
as = as.Clone()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- err := toAccumulate.Append(as)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, fmt.Errorf("error building monthly accumulation: %s", err)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ toAccumulate.Append(as)
|
|
|
|
|
|
|
|
sas, err := toAccumulate.accumulate()
|
|
sas, err := toAccumulate.accumulate()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -1618,10 +1606,7 @@ func (sasr *SummaryAllocationSetRange) accumulateByMonth() (*SummaryAllocationSe
|
|
|
if length := len(toAccumulate.SummaryAllocationSets); length != 1 {
|
|
if length := len(toAccumulate.SummaryAllocationSets); length != 1 {
|
|
|
return nil, fmt.Errorf("failed accumulation, detected %d sets instead of 1", length)
|
|
return nil, fmt.Errorf("failed accumulation, detected %d sets instead of 1", length)
|
|
|
}
|
|
}
|
|
|
- err = result.Append(toAccumulate.SummaryAllocationSets[0])
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, fmt.Errorf("error building result accumulation: %s", err)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ result.Append(toAccumulate.SummaryAllocationSets[0])
|
|
|
toAccumulate = nil
|
|
toAccumulate = nil
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1647,10 +1632,7 @@ func (sasr *SummaryAllocationSetRange) accumulateByWeek() (*SummaryAllocationSet
|
|
|
as = as.Clone()
|
|
as = as.Clone()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- err := toAccumulate.Append(as)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, fmt.Errorf("error building accumulation: %s", err)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ toAccumulate.Append(as)
|
|
|
sas, err := toAccumulate.accumulate()
|
|
sas, err := toAccumulate.accumulate()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("error accumulating result: %s", err)
|
|
return nil, fmt.Errorf("error accumulating result: %s", err)
|
|
@@ -1662,18 +1644,19 @@ func (sasr *SummaryAllocationSetRange) accumulateByWeek() (*SummaryAllocationSet
|
|
|
if length := len(toAccumulate.SummaryAllocationSets); length != 1 {
|
|
if length := len(toAccumulate.SummaryAllocationSets); length != 1 {
|
|
|
return nil, fmt.Errorf("failed accumulation, detected %d sets instead of 1", length)
|
|
return nil, fmt.Errorf("failed accumulation, detected %d sets instead of 1", length)
|
|
|
}
|
|
}
|
|
|
- err = result.Append(toAccumulate.SummaryAllocationSets[0])
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, fmt.Errorf("error building result accumulation: %s", err)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ result.Append(toAccumulate.SummaryAllocationSets[0])
|
|
|
toAccumulate = nil
|
|
toAccumulate = nil
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return result, nil
|
|
return result, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (sasr *SummaryAllocationSetRange) Clone() *SummaryAllocationSetRange {
|
|
|
|
|
+ return sasr.clone()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// clone returns a new SummaryAllocationSetRange cloned from the existing SASR
|
|
// clone returns a new SummaryAllocationSetRange cloned from the existing SASR
|
|
|
-func (sasr *SummaryAllocationSetRange) clone() (*SummaryAllocationSetRange, error) {
|
|
|
|
|
|
|
+func (sasr *SummaryAllocationSetRange) clone() *SummaryAllocationSetRange {
|
|
|
sasrSource := NewSummaryAllocationSetRange()
|
|
sasrSource := NewSummaryAllocationSetRange()
|
|
|
sasrSource.Window = sasr.Window.Clone()
|
|
sasrSource.Window = sasr.Window.Clone()
|
|
|
sasrSource.Step = sasr.Step
|
|
sasrSource.Step = sasr.Step
|
|
@@ -1685,11 +1668,8 @@ func (sasr *SummaryAllocationSetRange) clone() (*SummaryAllocationSetRange, erro
|
|
|
sasClone = sas.Clone()
|
|
sasClone = sas.Clone()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- err := sasrSource.Append(sasClone)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, err
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ sasrSource.Append(sasClone)
|
|
|
}
|
|
}
|
|
|
- return sasrSource, nil
|
|
|
|
|
|
|
|
|
|
|
|
+ return sasrSource
|
|
|
}
|
|
}
|