wp
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user