@@ -7,31 +7,31 @@ source ./tools/tb_function.sh
77# We said that everything in TigerBeetle is batched for efficiency and performance
88# -- so let's take advantage of that!
99
10- # Let's go crazy here and create 8189 accounts in a single request!
11- # Why 8189? That 's the maximum number we can send in a request.
10+ # The maximum number of events we can send in a single request is 8189.
11+ # Let 's create 8189 accounts across two batches:
1212create_account_batch=" create_accounts "
13- for (( i= 0 ; i< 8189 ; i++ )) ; do
13+ for (( i= 0 ; i< 4000 ; i++ )) ; do
1414 create_account_batch+=" id=$(( 100000 + i)) code=10 ledger=100, "
1515done
16+ tb " ${create_account_batch% , } ;"
1617
17- # Create the accounts (removing the trailing comma and space)
18+ create_account_batch=" create_accounts "
19+ for (( i= 4000 ; i< 8189 ; i++ )) ; do
20+ create_account_batch+=" id=$(( 100000 + i)) code=10 ledger=100, "
21+ done
1822tb " ${create_account_batch% , } ;"
1923
2024# Now let's do the same for transfers!
25+ # (We have to split them into batches because of the REPL's command-line size limit.)
2126
2227create_transfer_batch=" create_transfers "
23- for (( i= 0 ; i< 8190 ; i++ )) ; do
24- create_transfer_batch+=" id=$(( 1000 + i)) \
25- debit_account_id=$(( 100000 + i)) \
26- credit_account_id=$(( 100000 + (1 + i) % 8189 )) \
27- amount=1 \
28- code=10 \
29- ledger=100, "
28+ for (( i= 0 ; i< 1400 ; i++ )) ; do
29+ create_transfer_batch+=" id=$(( 1000 + i)) debit_account_id=$(( 100000 + i)) credit_account_id=$(( 100000 + (1 + i) % 8189 )) amount=1 code=10 ledger=100, "
3030done
31-
3231tb " ${create_transfer_batch% , } ;"
33- # Uh oh! We might have gone a _little_ overboard and created one too many transfers!
3432
35- # (If you're running TigerBeetle using a debug build, you'll see that this error
36- # is triggered by an assertion failure in the client. TigerBeetle makes heavy use
37- # of assertions to ensure that it operates as expected.)
33+ create_transfer_batch=" create_transfers "
34+ for (( i= 1400 ; i< 2800 ; i++ )) ; do
35+ create_transfer_batch+=" id=$(( 1000 + i)) debit_account_id=$(( 100000 + i)) credit_account_id=$(( 100000 + (1 + i) % 8189 )) amount=1 code=10 ledger=100, "
36+ done
37+ tb " ${create_transfer_batch% , } ;"
0 commit comments