Skip to content

Commit a71e257

Browse files
committed
chore: Virtual thread
1 parent ae394d7 commit a71e257

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

aggregates/account/src/main/java/org/cardanofoundation/ledgersync/account/storage/impl/AddressTxAmountStorageImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.cardanofoundation.ledgersync.account.storage.impl;
22

33
import com.bloxbean.cardano.yaci.store.account.AccountStoreProperties;
4+
import com.bloxbean.cardano.yaci.store.common.executor.ParallelExecutor;
45
import com.bloxbean.cardano.yaci.store.common.util.ListUtil;
56
import jakarta.annotation.PostConstruct;
67
import lombok.RequiredArgsConstructor;
@@ -30,6 +31,7 @@ public class AddressTxAmountStorageImpl implements AddressTxAmountStorage {
3031
private final DSLContext dsl;
3132
private final AccountStoreProperties accountStoreProperties;
3233
private final PlatformTransactionManager transactionManager;
34+
private final ParallelExecutor parallelExecutor;
3335

3436
private final AggrMapper aggrMapper = AggrMapper.INSTANCE;
3537
private TransactionTemplate transactionTemplate;
@@ -51,7 +53,7 @@ public void save(List<AddressTxAmount> addressTxAmount) {
5153

5254
if (accountStoreProperties.isParallelWrite()) {
5355
// transactionTemplate.execute(status -> {
54-
ListUtil.partitionAndApplyInParallel(addressTxAmtEntities, accountStoreProperties.getPerThreadBatchSize(), this::doSave);
56+
ListUtil.partitionAndApplyInParallel(addressTxAmtEntities, accountStoreProperties.getPerThreadBatchSize(), this::doSave, parallelExecutor.getVirtualThreadExecutor());
5557
// return null;
5658
// });
5759
} else {
@@ -98,6 +100,7 @@ private void doSave(List<AddressTxAmountEntity> addressTxAmountEntities) {
98100
dsl.batch(inserts).execute();
99101
**/
100102

103+
transactionTemplate.execute(status -> {
101104
dsl.batched(c -> {
102105
for (var addressTxAmount : addressTxAmountEntities) {
103106
c.dsl().insertInto(ADDRESS_TX_AMOUNT)
@@ -132,6 +135,8 @@ private void doSave(List<AddressTxAmountEntity> addressTxAmountEntities) {
132135
.execute();
133136
}
134137
});
138+
return null;
139+
});
135140

136141
}
137142

0 commit comments

Comments
 (0)