Documentation ¶
Index ¶
- Variables
- func RebuildAllIndexes(ctx context.Context, t *doltdb.Table, opts Options) (*doltdb.Table, error)
- func RebuildIndex(ctx context.Context, tbl *doltdb.Table, indexName string, opts Options) (types.Map, error)
- type BulkImportIEA
- func (iea *BulkImportIEA) Commit(ctx context.Context, nbf *types.NomsBinFormat) error
- func (iea *BulkImportIEA) Delete(ctx context.Context, keyHash, partialKeyHash hash.Hash, key, value types.Tuple) error
- func (iea *BulkImportIEA) Has(ctx context.Context, keyHash hash.Hash, key types.Tuple) (bool, error)
- func (iea *BulkImportIEA) HasPartial(ctx context.Context, idxSch schema.Schema, partialKeyHash hash.Hash, ...) ([]hashedTuple, error)
- func (iea *BulkImportIEA) Insert(ctx context.Context, keyHash, partialKeyHash hash.Hash, key, val types.Tuple) error
- func (iea *BulkImportIEA) MaterializeEdits(ctx context.Context, nbf *types.NomsBinFormat) (m types.Map, err error)
- func (iea *BulkImportIEA) Rollback(ctx context.Context) error
- type BulkImportTEA
- func (tea *BulkImportTEA) Commit(ctx context.Context, nbf *types.NomsBinFormat) error
- func (tea *BulkImportTEA) Delete(keyHash hash.Hash, key types.Tuple) error
- func (tea *BulkImportTEA) Get(ctx context.Context, keyHash hash.Hash, key types.Tuple) (*doltKVP, bool, error)
- func (tea *BulkImportTEA) Insert(keyHash hash.Hash, key types.Tuple, val types.Tuple) error
- func (tea *BulkImportTEA) MaterializeEdits(ctx context.Context, nbf *types.NomsBinFormat) (m types.Map, err error)
- func (tea *BulkImportTEA) Rollback(ctx context.Context) error
- type BulkImportTEAFactory
- type DbEaFactory
- type InMemDEAF
- type IndexEditAccumulator
- type IndexEditor
- func (ie *IndexEditor) Close() error
- func (ie *IndexEditor) DeleteRow(ctx context.Context, key, partialKey, value types.Tuple) error
- func (ie *IndexEditor) HasPartial(ctx context.Context, partialKey types.Tuple) (bool, error)
- func (ie *IndexEditor) Index() schema.Index
- func (ie *IndexEditor) InsertRow(ctx context.Context, key, partialKey types.Tuple, value types.Tuple) error
- func (ie *IndexEditor) Map(ctx context.Context) (types.Map, error)
- func (ie *IndexEditor) StatementFinished(ctx context.Context, errored bool) error
- func (ie *IndexEditor) StatementStarted(ctx context.Context)
- func (ie *IndexEditor) Undo(ctx context.Context)
- type Options
- type PKDuplicateErrFunc
- type TableEditAccumulator
- type TableEditor
Constants ¶
This section is empty.
Variables ¶
var (
ErrDuplicateKey = errors.New("duplicate key error")
)
Functions ¶
func RebuildAllIndexes ¶
Types ¶
type BulkImportIEA ¶
type BulkImportIEA struct {
// contains filtered or unexported fields
}
BulkImportIEA is a IndexEditAccumulator implementation used to improve the perf of bulk edits. It does not implement commit and rollback
func (*BulkImportIEA) Commit ¶
func (iea *BulkImportIEA) Commit(ctx context.Context, nbf *types.NomsBinFormat) error
Commit is the default behavior and does nothing
func (*BulkImportIEA) Delete ¶
func (iea *BulkImportIEA) Delete(ctx context.Context, keyHash, partialKeyHash hash.Hash, key, value types.Tuple) error
Delete adds a row to be deleted when these edits are eventually applied.
func (*BulkImportIEA) Has ¶
func (iea *BulkImportIEA) Has(ctx context.Context, keyHash hash.Hash, key types.Tuple) (bool, error)
Has returns true if the current TableEditAccumulator contains the given key, or it exists in the row data.
func (*BulkImportIEA) HasPartial ¶
func (iea *BulkImportIEA) HasPartial(ctx context.Context, idxSch schema.Schema, partialKeyHash hash.Hash, partialKey types.Tuple) ([]hashedTuple, error)
HasPartial returns true if the current TableEditAccumulator contains the given partialKey
func (*BulkImportIEA) Insert ¶
func (iea *BulkImportIEA) Insert(ctx context.Context, keyHash, partialKeyHash hash.Hash, key, val types.Tuple) error
Insert adds a row to be inserted when these edits are eventually applied.
func (*BulkImportIEA) MaterializeEdits ¶
func (iea *BulkImportIEA) MaterializeEdits(ctx context.Context, nbf *types.NomsBinFormat) (m types.Map, err error)
MaterializeEdits commits and applies the in memory edits to the row data
type BulkImportTEA ¶
type BulkImportTEA struct {
// contains filtered or unexported fields
}
BulkImportTEA is a TableEditAccumulator implementation used to improve the perf of bulk edits. It does not implement commit and rollback
func (*BulkImportTEA) Commit ¶
func (tea *BulkImportTEA) Commit(ctx context.Context, nbf *types.NomsBinFormat) error
Commit is the default behavior and does nothing
func (*BulkImportTEA) Delete ¶
Delete adds a row to be deleted when these edits are eventually applied. Updates are modeled as a delete and an insert
func (*BulkImportTEA) Get ¶
func (tea *BulkImportTEA) Get(ctx context.Context, keyHash hash.Hash, key types.Tuple) (*doltKVP, bool, error)
Get returns a *doltKVP if the current TableEditAccumulator contains the given key, or it exists in the row data. This assumes that the given hash is for the given key.
func (*BulkImportTEA) Insert ¶
Insert adds a row to be inserted when these edits are eventually applied. Updates are modeled as a delete and an insert.
func (*BulkImportTEA) MaterializeEdits ¶
func (tea *BulkImportTEA) MaterializeEdits(ctx context.Context, nbf *types.NomsBinFormat) (m types.Map, err error)
MaterializeEdits applies the in memory edits to the row data and returns types.Map
type BulkImportTEAFactory ¶
type BulkImportTEAFactory struct {
// contains filtered or unexported fields
}
func NewBulkImportTEAFactory ¶
func NewBulkImportTEAFactory(nbf *types.NomsBinFormat, vrw types.ValueReadWriter, directory string) *BulkImportTEAFactory
func (*BulkImportTEAFactory) NewIndexEA ¶
func (b *BulkImportTEAFactory) NewIndexEA(ctx context.Context, rowData types.Map) IndexEditAccumulator
func (*BulkImportTEAFactory) NewTableEA ¶
func (b *BulkImportTEAFactory) NewTableEA(ctx context.Context, rowData types.Map) TableEditAccumulator
type DbEaFactory ¶
type DbEaFactory interface { // NewTableEA creates a TableEditAccumulator NewTableEA(ctx context.Context, rowData types.Map) TableEditAccumulator // NewIndexEA creates an IndexEditAccumulator NewIndexEA(ctx context.Context, rowData types.Map) IndexEditAccumulator }
DbEaFactory is an interface for a factory object used to make table and index edit accumulators
func NewDbEaFactory ¶
func NewDbEaFactory(directory string, vrw types.ValueReadWriter) DbEaFactory
NewDbEaFactory creates a DbEaFatory which uses the provided directory to hold temp files
func NewInMemDeaf ¶
func NewInMemDeaf(nbf *types.NomsBinFormat) DbEaFactory
func NewInMemDeafWithMaxCapacity ¶
func NewInMemDeafWithMaxCapacity(nbf *types.NomsBinFormat, maxCapacity int64) DbEaFactory
type InMemDEAF ¶
type InMemDEAF struct {
// contains filtered or unexported fields
}
func (*InMemDEAF) NewIndexEA ¶
func (*InMemDEAF) NewTableEA ¶
type IndexEditAccumulator ¶
type IndexEditAccumulator interface { // Delete adds a row to be deleted when these edits are eventually applied. Delete(ctx context.Context, keyHash, partialKeyHash hash.Hash, key, value types.Tuple) error // Insert adds a row to be inserted when these edits are eventually applied. Insert(ctx context.Context, keyHash, partialKeyHash hash.Hash, key, value types.Tuple) error // Has returns true if the current TableEditAccumulator contains the given key, or it exists in the row data. Has(ctx context.Context, keyHash hash.Hash, key types.Tuple) (bool, error) // HasPartial returns true if the current TableEditAccumulator contains the given partialKey HasPartial(ctx context.Context, idxSch schema.Schema, partialKeyHash hash.Hash, partialKey types.Tuple) ([]hashedTuple, error) // Commit applies the in memory edits to the list of committed in memory edits Commit(ctx context.Context, nbf *types.NomsBinFormat) error // Rollback rolls back in memory edits until it reaches the state represented by the savedTea Rollback(ctx context.Context) error // MaterializeEdits commits and applies the in memory edits to the row data MaterializeEdits(ctx context.Context, nbf *types.NomsBinFormat) (types.Map, error) }
type IndexEditor ¶
type IndexEditor struct {
// contains filtered or unexported fields
}
IndexEditor takes in changes to an index map and returns the updated map if changes have been made. This type is thread-safe, and may be used in a multi-threaded environment.
func NewIndexEditor ¶
func NewIndexEditor(ctx context.Context, index schema.Index, indexData types.Map, tableSch schema.Schema, opts Options) *IndexEditor
NewIndexEditor creates a new index editor
func (*IndexEditor) Close ¶
func (ie *IndexEditor) Close() error
Close is a no-op for an IndexEditor.
func (*IndexEditor) HasPartial ¶
HasPartial returns whether the index editor has the given partial key.
func (*IndexEditor) Index ¶
func (ie *IndexEditor) Index() schema.Index
Index returns this editor's index.
func (*IndexEditor) InsertRow ¶
func (ie *IndexEditor) InsertRow(ctx context.Context, key, partialKey types.Tuple, value types.Tuple) error
InsertRow adds the given row to the index. If the row already exists and the index is unique, then an error is returned. Otherwise, it is a no-op.
func (*IndexEditor) StatementFinished ¶
func (ie *IndexEditor) StatementFinished(ctx context.Context, errored bool) error
StatementFinished is analogous to the TableEditor implementation, but specific to the IndexEditor.
func (*IndexEditor) StatementStarted ¶
func (ie *IndexEditor) StatementStarted(ctx context.Context)
StatementStarted is analogous to the TableEditor implementation, but specific to the IndexEditor.
func (*IndexEditor) Undo ¶
func (ie *IndexEditor) Undo(ctx context.Context)
Undo will cause the index editor to undo the last operation at the top of the stack. As Insert and Delete are called, they are added onto a limited-size stack, and Undo pops an operation off the top and undoes it. So if there was an Insert on a key, it will use Delete on that same key. The stack size is very small, therefore too many consecutive calls will cause the stack to empty. This should only be called in the event that an operation was performed that has failed for other reasons, such as an INSERT on the parent table failing on a separate index editor. In the event that Undo is called and there are no operations to undo OR the reverse operation fails (such as memory capacity reached), then we set a permanent error as the index editor is in an invalid state that cannot be corrected.
We don't return an error here as Undo will only be called when there's an error in a different editor. We allow the user to handle that initial error, as ALL further calls to this IndexEditor will return the error set here.
type Options ¶
type Options struct { //TODO: look into this ForeignKeyChecksDisabled bool // If true, then ALL foreign key checks AND updates (through CASCADE, etc.) are skipped Deaf DbEaFactory Tempdir string }
Options are properties that define different functionality for the tableEditSession.
func TestEditorOptions ¶
func TestEditorOptions(vrw types.ValueReadWriter) Options
func (Options) WithDeaf ¶
func (o Options) WithDeaf(deaf DbEaFactory) Options
WithDeaf returns a new Options with the given edit accumulator factory class
type PKDuplicateErrFunc ¶
type TableEditAccumulator ¶
type TableEditAccumulator interface { // Delete adds a row to be deleted when these edits are eventually applied. Updates are modeled as a delete and an insert Delete(keyHash hash.Hash, key types.Tuple) error // Insert adds a row to be inserted when these edits are eventually applied. Updates are modeled as a delete and an insert. Insert(keyHash hash.Hash, key types.Tuple, val types.Tuple) error // Get returns a *doltKVP if the current TableEditAccumulator contains the given key, or it exists in the row data. // This assumes that the given hash is for the given key. Get(ctx context.Context, keyHash hash.Hash, key types.Tuple) (*doltKVP, bool, error) // Commit applies the in memory edits to the list of committed in memory edits Commit(ctx context.Context, nbf *types.NomsBinFormat) error // Rollback rolls back in memory edits until it reaches the state represented by the savedTea Rollback(ctx context.Context) error // MaterializeEdits commits and applies the in memory edits to the row data MaterializeEdits(ctx context.Context, nbf *types.NomsBinFormat) (m types.Map, err error) }
type TableEditor ¶
type TableEditor interface { InsertKeyVal(ctx context.Context, key, val types.Tuple, tagToVal map[uint64]types.Value, errFunc PKDuplicateErrFunc) error DeleteByKey(ctx context.Context, key types.Tuple, tagToVal map[uint64]types.Value) error InsertRow(ctx context.Context, r row.Row, errFunc PKDuplicateErrFunc) error UpdateRow(ctx context.Context, old, new row.Row, errFunc PKDuplicateErrFunc) error DeleteRow(ctx context.Context, r row.Row) error // GetIndexedRows returns all matching rows for the given key on the index. The key is assumed to be in the format // expected of the index, similar to searching on the index map itself. GetIndexedRows(ctx context.Context, key types.Tuple, indexName string, idxSch schema.Schema) ([]row.Row, error) HasEdits() bool MarkDirty() SetConstraintViolation(ctx context.Context, k types.LesserValuable, v types.Valuable) error Table(ctx context.Context) (*doltdb.Table, error) Schema() schema.Schema Name() string Format() *types.NomsBinFormat ValueReadWriter() types.ValueReadWriter StatementStarted(ctx context.Context) StatementFinished(ctx context.Context, errored bool) error Close(ctx context.Context) error }