This commit is contained in:
2026-06-13 08:01:42 +03:00
parent bf22e9a85e
commit aca0252cfd
19 changed files with 2001 additions and 1240 deletions

View File

@@ -1,6 +1,8 @@
package storage
const (
import "gordenko.dev/dima/qb"
var (
//PageNoSize = 4
@@ -15,18 +17,106 @@ const (
prevPageIdx = DataPageSize - 12
// index page
IndexPageSize = 1024
IndexPageFooterSize = 7
IndexPageSize = 1024
IndexPageFooterSize = 7
//indexPageIncSize = IndexPageIncSize
indexCRC32Idx = IndexPageSize - 4
indexRecordsCountIdx = IndexPageSize - 6
isZeroLevelIdx = IndexPageSize - 7
indexRecordSize = 8
maxRecordsOnIndexPage = (IndexPageSize - IndexPageFooterSize) / indexRecordSize
//indexPageIncSize = IndexPageIncSize
indexCRC32Idx = IndexPageSize - 4
indexRecordsCountIdx = IndexPageSize - 6
isZeroLevelIdx = IndexPageSize - 7
// timestampSize = 4
// pairSize = timestampSize + PageNoSize
// indexFooterIdx = indexRecordsQtyIdx
// dataFooterIdx = timestampsSizeIdx
)
type IndexRecord struct {
Timestamp uint32
PageNo uint32
}
// TASKS FROM WORKER
type MetricAdd struct {
MetricID uint32
MetricType qb.MetricType
FracDigits byte
ResultCh chan struct{}
}
type MetricDelete struct {
MetricID uint32
FreeIndexPages []uint32
FreeDataPages []uint32
ResultCh chan struct{}
}
type MeasuresAppendWithGrow struct {
MetricID uint32
LastPageNo uint32
TimestampsRewindOffset int // offset on 1st page
Timestamps []byte
ValuesRewindOffset int // offset on 1st page
Values []byte
DataPages []DataPayload
TailTimestamps []byte // data level tail
TailValues []byte // data level tail
IndexLevelTails []IndexLevelTail
ResultCode byte
WrittenCount int
ResultCh chan struct{}
}
type MeasuresAppend struct {
MetricID uint32
TimestampsRewindOffset int // offset on 1st page
Timestamps []byte
ValuesRewindOffset int // offset on 1st page
Values []byte
ResultCode byte
WrittenCount int
ResultCh chan struct{}
}
type MeasuresDelete struct {
MetricID uint32
FreeIndexPages []uint32
FreeDataPages []uint32
ResultCh chan struct{}
}
// WRITE RESULTS
// результат
type MeasuresAppendCommited struct {
MetricID uint32
ResultCode byte
WrittenCount int
ResultCh chan struct{}
}
type MeasuresAppendWithGrowCommited struct {
MetricID uint32
LastPageNo uint32
Index []IndexLevelTail
ResultCode byte
WrittenCount int
ResultCh chan struct{}
}
type MeasuresDeleteCommited struct {
MetricID uint32
ResultCh chan struct{}
}
type MetricAddCommited struct {
MetricID uint32
ResultCh chan struct{}
}
type MetricDeleteCommited struct {
MetricID uint32
ResultCh chan struct{}
}