mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-04 10:25:17 -06:00
o/libraries/doltcore/table/editor: Add ability to configure map editor flush interval with environment variables.
This commit is contained in:
@@ -18,6 +18,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
@@ -49,7 +51,17 @@ type IndexEditor struct {
|
||||
flushMutex *sync.RWMutex
|
||||
}
|
||||
|
||||
const indexEditorMaxEdits = 16384
|
||||
var (
|
||||
indexEditorMaxEdits uint64 = 16384
|
||||
)
|
||||
|
||||
func init() {
|
||||
if maxOpsEnv := os.Getenv("DOLT_EDIT_INDEX_BUFFER_ROWS"); maxOpsEnv != "" {
|
||||
if v, err := strconv.ParseUint(maxOpsEnv, 10, 64); err == nil {
|
||||
indexEditorMaxEdits = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func NewIndexEditor(index schema.Index, indexData types.Map) *IndexEditor {
|
||||
return &IndexEditor{
|
||||
|
||||
@@ -243,7 +243,7 @@ func (kte *keylessTableEditor) Close() error {
|
||||
func (kte *keylessTableEditor) autoFlush(ctx context.Context) error {
|
||||
// work is proportional to number of deltas
|
||||
// not the number of row operations
|
||||
if len(kte.acc.deltas) >= tableEditorMaxOps {
|
||||
if len(kte.acc.deltas) >= int(tableEditorMaxOps) {
|
||||
return kte.flush(ctx)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -18,6 +18,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -32,10 +34,18 @@ import (
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
)
|
||||
|
||||
const (
|
||||
tableEditorMaxOps = 16384
|
||||
var (
|
||||
tableEditorMaxOps uint64 = 16384
|
||||
)
|
||||
|
||||
func init() {
|
||||
if maxOpsEnv := os.Getenv("DOLT_EDIT_TABLE_BUFFER_ROWS"); maxOpsEnv != "" {
|
||||
if v, err := strconv.ParseUint(maxOpsEnv, 10, 64); err == nil {
|
||||
tableEditorMaxOps = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type TableEditor interface {
|
||||
InsertRow(ctx context.Context, r row.Row) error
|
||||
UpdateRow(ctx context.Context, old, new row.Row) error
|
||||
|
||||
Reference in New Issue
Block a user