Files
qb/qb.go

134 lines
3.2 KiB
Go
Raw Normal View History

2026-02-23 11:02:29 +00:00
package qb
2026-02-10 14:02:11 +00:00
import (
"fmt"
2026-06-09 08:16:16 +03:00
"io"
2026-02-10 14:02:11 +00:00
"os"
)
type MetricType byte
type GroupBy byte
const (
Cumulative MetricType = 1
Instant MetricType = 2
MaxFracDigits byte = 7
GroupByHour GroupBy = 1
GroupByDay GroupBy = 2
GroupByMonth GroupBy = 3
AggregateMin byte = 1
AggregateMax byte = 2
AggregateAvg byte = 4
)
type TimestampCompressor interface {
2026-06-11 01:46:25 +00:00
// (tmp, timestamp)
Evaluate([]byte, uint32) TimeEvaluationReport
// (offset, tmp)
Append(int, []byte)
//Size() int
2026-06-07 21:27:18 +03:00
//Chunks() [][]byte
//DeleteLast()
2026-06-07 01:06:16 +00:00
CaptureState()
ForgetCapturedState()
2026-05-31 20:01:28 +00:00
CreateDecompressor() TimestampDecompressor
2026-06-09 08:16:16 +03:00
//Payload() []byte // для снапшота
2026-06-11 01:46:25 +00:00
// Offset() int
2026-06-09 08:16:16 +03:00
Rotate([]byte)
WritePayloadTo(io.Writer) error
LastTimestamp() uint32
ReplaceSinceWithUntil() uint32
2026-02-10 14:02:11 +00:00
}
2026-06-11 01:46:25 +00:00
type TimeEvaluationReport struct {
TotalSpace int
Offset int
ChangeSize int
}
2026-02-10 14:02:11 +00:00
type ValueCompressor interface {
2026-06-11 01:46:25 +00:00
// (tmp, value)
Evaluate([]byte, float64) ValueEvaluationReport
// (offset, tmp, delta)
Append(int, []byte, uint64)
//Size() int
2026-06-07 21:27:18 +03:00
//Chunks() [][]byte
//DeleteLast()
CaptureState()
ForgetCapturedState()
2026-05-31 20:01:28 +00:00
// fracDigits
2026-06-09 08:16:16 +03:00
CreateDecompressor() ValueDecompressor
//Payload() []byte // для снапшота
2026-06-11 01:46:25 +00:00
//Offset() int
2026-06-09 08:16:16 +03:00
Rotate([]byte)
WritePayloadTo(io.Writer) error
LastValue() float64
2026-02-10 14:02:11 +00:00
}
2026-06-11 01:46:25 +00:00
type ValueEvaluationReport struct {
TotalSpace int
Offset int
ChangeSize int
Delta uint64
}
2026-02-10 14:02:11 +00:00
type TimestampDecompressor interface {
NextValue() (uint32, bool)
}
type ValueDecompressor interface {
NextValue() (float64, bool)
}
type AbortCode int
const (
// Fatal errors
WrongPrevPageNo AbortCode = 1
WriteToAtreeFailed AbortCode = 2
MaxAtreeSizeExceeded AbortCode = 3
FailedWriteToTxLog AbortCode = 4
ReferenceCountBug AbortCode = 5
WrongResultCodeBug AbortCode = 6
RemoveREDOFileFailed AbortCode = 7
FailedAtreeRequest AbortCode = 8
2026-05-31 20:01:28 +00:00
FailedGetPageNumber AbortCode = 9
2026-02-10 14:02:11 +00:00
UnknownTxLogRecordTypeBug AbortCode = 11
HasTimestampNoValueBug AbortCode = 12
NoMetricBug AbortCode = 13
NoLockEntryBug AbortCode = 14
NoXLockBug AbortCode = 15
MetricAddedBug AbortCode = 16
NoRLockBug AbortCode = 17
XLockBug AbortCode = 18
FailedFreeListSerialize AbortCode = 19
UnknownWorkerQueueItemBug AbortCode = 20
UnknownMetricWaitQueueItemBug AbortCode = 21
2026-05-31 20:01:28 +00:00
RepeatableLock AbortCode = 22
2026-06-05 19:43:01 +00:00
NoSpaceOnIndexPage AbortCode = 23
2026-06-09 08:16:16 +03:00
WriteSnapshotFailed AbortCode = 24
2026-02-10 14:02:11 +00:00
//
GetRecoveryRecipeFailed AbortCode = 26
LoadSnapshotFailed AbortCode = 27
ReplayChangesFailed AbortCode = 28
CreateChangesWriterFailed AbortCode = 29
RemoveRecipeFileFailed AbortCode = 30
DumpSnapshotFailed AbortCode = 31
SearchREDOFilesFailed AbortCode = 32
ReplayREDOFileFailed AbortCode = 33
DeletePrevChangesFileFailed AbortCode = 34
DeletePrevSnapshotFileFailed AbortCode = 35
2026-06-09 08:16:16 +03:00
MetricNotFoundDuringReplay AbortCode = 36
2026-06-10 06:18:45 +03:00
WALReplayFailed AbortCode = 37
2026-02-10 14:02:11 +00:00
)
func Abort(code AbortCode, err error) {
fmt.Println(err)
os.Exit(int(code))
}