-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
services/horizon: Use COPY to speed up ClaimableBalanceChangeProcessor (
- Loading branch information
Showing
12 changed files
with
362 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
services/horizon/internal/db2/history/claimable_balance_batch_insert_builder.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package history | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/stellar/go/support/db" | ||
) | ||
|
||
// ClaimableBalanceBatchInsertBuilder is used to insert claimable balance into the | ||
// claimable_balances table | ||
type ClaimableBalanceBatchInsertBuilder interface { | ||
Add(claimableBalance ClaimableBalance) error | ||
Exec(ctx context.Context) error | ||
} | ||
|
||
// ClaimableBalanceBatchInsertBuilder is a simple wrapper around db.FastBatchInsertBuilder | ||
type claimableBalanceBatchInsertBuilder struct { | ||
session db.SessionInterface | ||
builder db.FastBatchInsertBuilder | ||
table string | ||
} | ||
|
||
// NewClaimableBalanceBatchInsertBuilder constructs a new ClaimableBalanceBatchInsertBuilder instance | ||
func (q *Q) NewClaimableBalanceBatchInsertBuilder() ClaimableBalanceBatchInsertBuilder { | ||
return &claimableBalanceBatchInsertBuilder{ | ||
session: q, | ||
builder: db.FastBatchInsertBuilder{}, | ||
table: "claimable_balances", | ||
} | ||
} | ||
|
||
// Add adds a new claimable balance to the batch | ||
func (i *claimableBalanceBatchInsertBuilder) Add(claimableBalance ClaimableBalance) error { | ||
return i.builder.RowStruct(claimableBalance) | ||
} | ||
|
||
// Exec writes the batch of claimable balances to the database. | ||
func (i *claimableBalanceBatchInsertBuilder) Exec(ctx context.Context) error { | ||
return i.builder.Exec(ctx, i.session, i.table) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.