Files
qb/qb.go

106 lines
2.6 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"
"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 {
CalcRequiredSpace(uint32) int
Append(uint32)
Size() int
2026-05-14 16:06:37 +03:00
Chunks() [][]byte
2026-02-10 14:02:11 +00:00
DeleteLast()
2026-05-14 16:06:37 +03:00
Renew()
Lock()
Unlock()
2026-05-31 20:01:28 +00:00
CreateDecompressor() TimestampDecompressor
Snapshot() ([][]byte, int) // chunks, size
Offset() int
2026-02-10 14:02:11 +00:00
//LastTimestamp() uint32
}
type ValueCompressor interface {
CalcRequiredSpace(float64) int
Append(float64)
Size() int
2026-05-14 16:06:37 +03:00
Chunks() [][]byte
2026-02-10 14:02:11 +00:00
DeleteLast()
2026-05-14 16:06:37 +03:00
Renew() // створює новий conbuf, але не чіпає state
Lock()
Unlock()
2026-05-31 20:01:28 +00:00
// fracDigits
CreateDecompressor(byte) ValueDecompressor
Snapshot() ([][]byte, int) // chunks, size
Offset() int
2026-02-10 14:02:11 +00:00
//LastValue() float64
}
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-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
)
func Abort(code AbortCode, err error) {
fmt.Println(err)
os.Exit(int(code))
}