This commit is contained in:
2026-06-19 07:25:46 +03:00
parent 06823ee547
commit 2d73ce1727
52 changed files with 5173 additions and 547 deletions

View File

@@ -51,6 +51,7 @@ type ReplayMeasuresAppendWithGrowResult struct {
}
func (s *ReplayMetric) MeasuresAppendWithGrow(rec MeasuresAppendWithGrowRecord, isLastPacket bool) (_ ReplayMeasuresAppendWithGrowResult) {
//fmt.Printf("%#v\n", rec)
var (
reusedIndexPages int
reusedDataPages int
@@ -164,17 +165,34 @@ func (s *ReplayMetric) MeasuresAppendWithGrow(rec MeasuresAppendWithGrowRecord,
// HELPERS
func (s *ReplayMetric) composeHeadIndexPage(levelIdx int, head *IndexPageTail) PageToWrite {
level := s.IndexLevelTails[levelIdx]
// розраховую pos, з якого буду дописувати хвіст
pos := level.RecordsCount * IndexRecordSize
// створюю копію сторінки
page := make([]byte, IndexPageSize)
copy(page, level.Buffer[:pos]) // поточні дані
var (
page = make([]byte, IndexPageSize)
pos int
prevCount int
)
//fmt.Printf("composeHeadIndexPage: levels=%d\n", len(s.IndexLevelTails))
//fmt.Printf("head: % x\n", head.Records)
if levelIdx < len(s.IndexLevelTails) {
level := s.IndexLevelTails[levelIdx]
//fmt.Printf("level (%d): % x\n", level.RecordsCount, level.Buffer)
// розраховую pos, з якого буду дописувати хвіст
pos = level.RecordsCount * IndexRecordSize
// створюю копію сторінки
copy(page, level.Buffer[:pos]) // поточні дані
prevCount = level.RecordsCount
} else {
//
s.IndexLevelTails = append(s.IndexLevelTails, IndexLevelTail{
Buffer: page,
RecordsCount: len(head.Records) / IndexRecordSize,
})
}
copy(page[pos:], head.Records)
// запечатати сторінку
calculatedCRC := SealIndexPage(SealIndexPageIn{
Content: page,
RecordsCount: level.RecordsCount + len(head.Records)/IndexRecordSize,
RecordsCount: prevCount + len(head.Records)/IndexRecordSize,
ZeroLevel: levelIdx == 0,
})
// перевірка CRC