mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-04 16:51:11 +01:00
lib/storage: move common code to newRawRowsBlock() function
This commit is contained in:
parent
b5674164c6
commit
4128ad71e2
@ -473,8 +473,7 @@ func (rrs *rawRowsShard) addRows(pt *partition, rows []rawRow) {
|
|||||||
|
|
||||||
rrs.mu.Lock()
|
rrs.mu.Lock()
|
||||||
if cap(rrs.rows) == 0 {
|
if cap(rrs.rows) == 0 {
|
||||||
n := getMaxRawRowsPerShard()
|
rrs.rows = newRawRowsBlock()
|
||||||
rrs.rows = make([]rawRow, 0, n)
|
|
||||||
}
|
}
|
||||||
n := copy(rrs.rows[len(rrs.rows):cap(rrs.rows)], rows)
|
n := copy(rrs.rows[len(rrs.rows):cap(rrs.rows)], rows)
|
||||||
rrs.rows = rrs.rows[:len(rrs.rows)+n]
|
rrs.rows = rrs.rows[:len(rrs.rows)+n]
|
||||||
@ -484,8 +483,7 @@ func (rrs *rawRowsShard) addRows(pt *partition, rows []rawRow) {
|
|||||||
// Convert rrs.rows to rowsToFlush and convert it to a part,
|
// Convert rrs.rows to rowsToFlush and convert it to a part,
|
||||||
// then try moving the remaining rows to rrs.rows.
|
// then try moving the remaining rows to rrs.rows.
|
||||||
rowsToFlush = rrs.rows
|
rowsToFlush = rrs.rows
|
||||||
n = getMaxRawRowsPerShard()
|
rrs.rows = newRawRowsBlock()
|
||||||
rrs.rows = make([]rawRow, 0, n)
|
|
||||||
if len(rows) <= n {
|
if len(rows) <= n {
|
||||||
rrs.rows = append(rrs.rows[:0], rows...)
|
rrs.rows = append(rrs.rows[:0], rows...)
|
||||||
} else {
|
} else {
|
||||||
@ -500,6 +498,11 @@ func (rrs *rawRowsShard) addRows(pt *partition, rows []rawRow) {
|
|||||||
pt.flushRowsToParts(rowsToFlush)
|
pt.flushRowsToParts(rowsToFlush)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newRawRowsBlock() []rawRow {
|
||||||
|
n := getMaxRawRowsPerShard()
|
||||||
|
return make([]rawRow, 0, n)
|
||||||
|
}
|
||||||
|
|
||||||
func (pt *partition) flushRowsToParts(rows []rawRow) {
|
func (pt *partition) flushRowsToParts(rows []rawRow) {
|
||||||
maxRows := getMaxRawRowsPerShard()
|
maxRows := getMaxRawRowsPerShard()
|
||||||
wg := getWaitGroup()
|
wg := getWaitGroup()
|
||||||
|
Loading…
Reference in New Issue
Block a user