rc2
This commit is contained in:
@@ -499,10 +499,11 @@ func (s *Database) AppendMeasures(req proto.AppendMeasuresReq) uint16 {
|
||||
|
||||
toAppendMeasures = nil
|
||||
}
|
||||
//fmt.Printf("APPEND DATA PAGE %d, %v\n", measure.Timestamp, measure.Value)
|
||||
report, err := s.atree.AppendDataPage(atree.AppendDataPageReq{
|
||||
MetricID: req.MetricID,
|
||||
Timestamp: until,
|
||||
Value: untilValue,
|
||||
Timestamp: measure.Timestamp,
|
||||
Value: measure.Value,
|
||||
Since: since,
|
||||
RootPageNo: rootPageNo,
|
||||
PrevPageNo: prevPageNo,
|
||||
@@ -607,7 +608,7 @@ func (s *Database) DeleteMeasures(req proto.DeleteMeasuresReq) uint16 {
|
||||
|
||||
case DeleteFromAtreeRequired:
|
||||
// собираю номера всех data и index страниц метрики (типа запись REDO лога).
|
||||
pageLists, err := s.atree.GetAllPages(req.MetricID)
|
||||
pageLists, err := s.atree.GetAllPages(result.RootPageNo)
|
||||
if err != nil {
|
||||
diploma.Abort(diploma.FailedAtreeRequest, err)
|
||||
}
|
||||
@@ -670,7 +671,7 @@ func (s *Database) ListInstantMeasures(conn net.Conn, req proto.ListInstantMeasu
|
||||
MetricID: req.MetricID,
|
||||
MetricType: diploma.Instant,
|
||||
Since: req.Since,
|
||||
Until: req.Until - 1,
|
||||
Until: req.Until,
|
||||
Conn: conn,
|
||||
ResponseWriter: responseWriter,
|
||||
})
|
||||
@@ -688,7 +689,7 @@ func (s *Database) ListCumulativeMeasures(conn net.Conn, req proto.ListCumulativ
|
||||
MetricID: req.MetricID,
|
||||
MetricType: diploma.Cumulative,
|
||||
Since: req.Since,
|
||||
Until: req.Until - 1,
|
||||
Until: req.Until,
|
||||
Conn: conn,
|
||||
ResponseWriter: responseWriter,
|
||||
})
|
||||
@@ -739,6 +740,7 @@ func (s *Database) ListCumulativePeriods(conn net.Conn, req proto.ListCumulative
|
||||
responseWriter, err := transform.NewCumulativePeriodsWriter(transform.CumulativePeriodsWriterOptions{
|
||||
Dst: conn,
|
||||
GroupBy: req.GroupBy,
|
||||
Since: uint32(since.Unix()),
|
||||
FirstHourOfDay: req.FirstHourOfDay,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -762,7 +764,7 @@ type rangeScanReq struct {
|
||||
Since uint32
|
||||
Until uint32
|
||||
Conn io.Writer
|
||||
ResponseWriter atree.PeriodsWriter
|
||||
ResponseWriter diploma.MeasureConsumer
|
||||
}
|
||||
|
||||
func (s *Database) rangeScan(req rangeScanReq) error {
|
||||
@@ -785,6 +787,7 @@ func (s *Database) rangeScan(req rangeScanReq) error {
|
||||
|
||||
case UntilFound:
|
||||
err := s.atree.ContinueRangeScan(atree.ContinueRangeScanReq{
|
||||
MetricType: req.MetricType,
|
||||
FracDigits: result.FracDigits,
|
||||
ResponseWriter: req.ResponseWriter,
|
||||
LastPageNo: result.LastPageNo,
|
||||
@@ -800,6 +803,7 @@ func (s *Database) rangeScan(req rangeScanReq) error {
|
||||
|
||||
case UntilNotFound:
|
||||
err := s.atree.RangeScan(atree.RangeScanReq{
|
||||
MetricType: req.MetricType,
|
||||
FracDigits: result.FracDigits,
|
||||
ResponseWriter: req.ResponseWriter,
|
||||
RootPageNo: result.RootPageNo,
|
||||
@@ -830,7 +834,7 @@ type fullScanReq struct {
|
||||
MetricID uint32
|
||||
MetricType diploma.MetricType
|
||||
Conn io.Writer
|
||||
ResponseWriter atree.PeriodsWriter
|
||||
ResponseWriter diploma.MeasureConsumer
|
||||
}
|
||||
|
||||
func (s *Database) fullScan(req fullScanReq) error {
|
||||
@@ -851,6 +855,7 @@ func (s *Database) fullScan(req fullScanReq) error {
|
||||
|
||||
case UntilFound:
|
||||
err := s.atree.ContinueFullScan(atree.ContinueFullScanReq{
|
||||
MetricType: req.MetricType,
|
||||
FracDigits: result.FracDigits,
|
||||
ResponseWriter: req.ResponseWriter,
|
||||
LastPageNo: result.LastPageNo,
|
||||
|
||||
@@ -14,11 +14,13 @@ func timeBoundsOfAggregation(since, until proto.TimeBound, groupBy diploma.Group
|
||||
switch groupBy {
|
||||
case diploma.GroupByHour, diploma.GroupByDay:
|
||||
s = time.Date(since.Year, since.Month, since.Day, 0, 0, 0, 0, time.Local)
|
||||
u = time.Date(until.Year, until.Month, until.Day, 0, 0, 0, 0, time.Local)
|
||||
u = time.Date(until.Year, until.Month, until.Day, 23, 59, 59, 0, time.Local)
|
||||
|
||||
case diploma.GroupByMonth:
|
||||
s = time.Date(since.Year, since.Month, 1, 0, 0, 0, 0, time.Local)
|
||||
u = time.Date(until.Year, until.Month, 1, 0, 0, 0, 0, time.Local)
|
||||
u = time.Date(until.Year, until.Month, 1, 23, 59, 59, 0, time.Local)
|
||||
u = u.AddDate(0, 1, 0)
|
||||
u = u.AddDate(0, 0, -1)
|
||||
}
|
||||
|
||||
if firstHourOfDay > 0 {
|
||||
@@ -26,8 +28,6 @@ func timeBoundsOfAggregation(since, until proto.TimeBound, groupBy diploma.Group
|
||||
s = s.Add(duration)
|
||||
u = u.Add(duration)
|
||||
}
|
||||
|
||||
u = u.Add(-1 * time.Second)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -65,10 +65,3 @@ func (s *Database) metricRUnlock(metricID uint32) {
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func correctToFHD(since, until uint32, firstHourOfDay int) (uint32, uint32) {
|
||||
duration := time.Duration(firstHourOfDay) * time.Hour
|
||||
since = uint32(time.Unix(int64(since), 0).Add(duration).Unix())
|
||||
until = uint32(time.Unix(int64(until), 0).Add(duration).Unix())
|
||||
return since, until
|
||||
}
|
||||
|
||||
@@ -528,6 +528,8 @@ func (s *Database) appendMeasureAfterOverflow(extended txlog.AppendedMeasureWith
|
||||
rec.MetricID))
|
||||
}
|
||||
|
||||
//fmt.Printf("reinit by: %d, %v\n", rec.Timestamp, rec.Value)
|
||||
|
||||
metric.ReinitBy(rec.Timestamp, rec.Value)
|
||||
if rec.IsRootChanged {
|
||||
metric.RootPageNo = rec.RootPageNo
|
||||
@@ -643,7 +645,7 @@ type tryRangeScanReq struct {
|
||||
Since uint32
|
||||
Until uint32
|
||||
MetricType diploma.MetricType
|
||||
ResponseWriter atree.WorkerMeasureConsumer
|
||||
ResponseWriter diploma.WorkerMeasureConsumer
|
||||
ResultCh chan rangeScanResult
|
||||
}
|
||||
|
||||
@@ -717,11 +719,20 @@ func (*Database) startRangeScan(metric *_metric, req tryRangeScanReq) bool {
|
||||
metric.Timestamps.Size(),
|
||||
)
|
||||
|
||||
valueDecompressor := chunkenc.NewReverseInstantDeltaDecompressor(
|
||||
metric.ValuesBuf,
|
||||
metric.Values.Size(),
|
||||
metric.FracDigits,
|
||||
)
|
||||
var valueDecompressor diploma.ValueDecompressor
|
||||
if metric.MetricType == diploma.Cumulative {
|
||||
valueDecompressor = chunkenc.NewReverseCumulativeDeltaDecompressor(
|
||||
metric.ValuesBuf,
|
||||
metric.Values.Size(),
|
||||
metric.FracDigits,
|
||||
)
|
||||
} else {
|
||||
valueDecompressor = chunkenc.NewReverseInstantDeltaDecompressor(
|
||||
metric.ValuesBuf,
|
||||
metric.Values.Size(),
|
||||
metric.FracDigits,
|
||||
)
|
||||
}
|
||||
|
||||
for {
|
||||
timestamp, done := timestampDecompressor.NextValue()
|
||||
@@ -763,7 +774,7 @@ func (*Database) startRangeScan(metric *_metric, req tryRangeScanReq) bool {
|
||||
type tryFullScanReq struct {
|
||||
MetricID uint32
|
||||
MetricType diploma.MetricType
|
||||
ResponseWriter atree.WorkerMeasureConsumer
|
||||
ResponseWriter diploma.WorkerMeasureConsumer
|
||||
ResultCh chan fullScanResult
|
||||
}
|
||||
|
||||
@@ -813,12 +824,21 @@ func (*Database) startFullScan(metric *_metric, req tryFullScanReq) bool {
|
||||
metric.TimestampsBuf,
|
||||
metric.Timestamps.Size(),
|
||||
)
|
||||
valueDecompressor := chunkenc.NewReverseInstantDeltaDecompressor(
|
||||
metric.ValuesBuf,
|
||||
metric.Values.Size(),
|
||||
metric.FracDigits,
|
||||
)
|
||||
|
||||
var valueDecompressor diploma.ValueDecompressor
|
||||
if metric.MetricType == diploma.Cumulative {
|
||||
valueDecompressor = chunkenc.NewReverseCumulativeDeltaDecompressor(
|
||||
metric.ValuesBuf,
|
||||
metric.Values.Size(),
|
||||
metric.FracDigits,
|
||||
)
|
||||
} else {
|
||||
valueDecompressor = chunkenc.NewReverseInstantDeltaDecompressor(
|
||||
metric.ValuesBuf,
|
||||
metric.Values.Size(),
|
||||
metric.FracDigits,
|
||||
)
|
||||
}
|
||||
for {
|
||||
timestamp, done := timestampDecompressor.NextValue()
|
||||
if done {
|
||||
|
||||
Reference in New Issue
Block a user