|
|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
package sig |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"fmt" |
|
|
|
|
"sig-pub/pkg/indicator" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
@ -22,30 +21,30 @@ func NewIndicatorSummary(summaryIndicatorNewer func() indicator.ISummaryIndicato
|
|
|
|
|
|
|
|
|
|
// Summary 0 10, 0 20, 1 30
|
|
|
|
|
func (s *IndicatorSummary) Summary(offset, count int16) (summary any, rok bool) { |
|
|
|
|
key := fmt.Sprintf("%d,%d", offset, count) |
|
|
|
|
summaryIndicator, ok := s.cachedSummaryIndicators[key] |
|
|
|
|
// key := fmt.Sprintf("%d,%d", offset, count)
|
|
|
|
|
// summaryIndicator, ok := s.cachedSummaryIndicators[key]
|
|
|
|
|
|
|
|
|
|
if ok { |
|
|
|
|
s.indicatorContext.AddOffset(offset + count + 1) |
|
|
|
|
eliminater, ok := summaryIndicator.(indicator.ISummaryIndicatorEliminater) |
|
|
|
|
if ok { |
|
|
|
|
eliminater.Eliminate(s.indicatorContext) |
|
|
|
|
} |
|
|
|
|
s.indicatorContext.AddOffset(-(offset + count + 1)) |
|
|
|
|
// if ok {
|
|
|
|
|
// s.indicatorContext.AddOffset(offset + count + 1)
|
|
|
|
|
// eliminater, ok := summaryIndicator.(indicator.ISummaryIndicatorEliminater)
|
|
|
|
|
// if ok {
|
|
|
|
|
// eliminater.Eliminate(s.indicatorContext)
|
|
|
|
|
// }
|
|
|
|
|
// s.indicatorContext.AddOffset(-(offset + count + 1))
|
|
|
|
|
|
|
|
|
|
s.indicatorContext.AddOffset(offset) |
|
|
|
|
summaryIndicator.Accumulate(s.indicatorContext) |
|
|
|
|
summary, ok = summaryIndicator.Summary(s.indicatorContext) |
|
|
|
|
s.indicatorContext.AddOffset(-offset) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
// s.indicatorContext.AddOffset(offset)
|
|
|
|
|
// summaryIndicator.Accumulate(s.indicatorContext)
|
|
|
|
|
// summary, ok = summaryIndicator.Summary(s.indicatorContext)
|
|
|
|
|
// s.indicatorContext.AddOffset(-offset)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 初始化, 计算全量数据
|
|
|
|
|
summaryIndicator = s.summaryIndicatorNewer() |
|
|
|
|
summaryIndicator := s.summaryIndicatorNewer() |
|
|
|
|
if err := summaryIndicator.Init(s.indicatorContext.Input()); err != nil { |
|
|
|
|
panic(err) |
|
|
|
|
} |
|
|
|
|
s.cachedSummaryIndicators[key] = summaryIndicator |
|
|
|
|
// s.cachedSummaryIndicators[key] = summaryIndicator
|
|
|
|
|
|
|
|
|
|
// 设置当前相对offset
|
|
|
|
|
offset = offset + count |
|
|
|
|
|