Browse Source

Take pressure off GC by not creating/destroying HSQLDB sub-repositories all the time

split-DB
catbref 4 years ago
parent
commit
5cf5c1e1f7
  1. 44
      src/main/java/org/qortal/repository/hsqldb/HSQLDBRepository.java

44
src/main/java/org/qortal/repository/hsqldb/HSQLDBRepository.java

@ -53,12 +53,26 @@ public class HSQLDBRepository implements Repository {
private static final Logger LOGGER = LogManager.getLogger(HSQLDBRepository.class); private static final Logger LOGGER = LogManager.getLogger(HSQLDBRepository.class);
protected Connection connection; protected Connection connection;
protected Deque<Savepoint> savepoints = new ArrayDeque<>(3); protected final Deque<Savepoint> savepoints = new ArrayDeque<>(3);
protected boolean debugState = false; protected boolean debugState = false;
protected Long slowQueryThreshold = null; protected Long slowQueryThreshold = null;
protected List<String> sqlStatements; protected List<String> sqlStatements;
protected long sessionId; protected long sessionId;
protected Map<String, PreparedStatement> preparedStatementCache = new HashMap<>(); protected final Map<String, PreparedStatement> preparedStatementCache = new HashMap<>();
private final ATRepository atRepository = new HSQLDBATRepository(this);
private final AccountRepository accountRepository = new HSQLDBAccountRepository(this);
private final ArbitraryRepository arbitraryRepository = new HSQLDBArbitraryRepository(this);
private final AssetRepository assetRepository = new HSQLDBAssetRepository(this);
private final BlockRepository blockRepository = new HSQLDBBlockRepository(this);
private final ChatRepository chatRepository = new HSQLDBChatRepository(this);
private final CrossChainRepository crossChainRepository = new HSQLDBCrossChainRepository(this);
private final GroupRepository groupRepository = new HSQLDBGroupRepository(this);
private final MessageRepository messageRepository = new HSQLDBMessageRepository(this);
private final NameRepository nameRepository = new HSQLDBNameRepository(this);
private final NetworkRepository networkRepository = new HSQLDBNetworkRepository(this);
private final TransactionRepository transactionRepository = new HSQLDBTransactionRepository(this);
private final VotingRepository votingRepository = new HSQLDBVotingRepository(this);
// Constructors // Constructors
@ -92,67 +106,67 @@ public class HSQLDBRepository implements Repository {
@Override @Override
public ATRepository getATRepository() { public ATRepository getATRepository() {
return new HSQLDBATRepository(this); return this.atRepository;
} }
@Override @Override
public AccountRepository getAccountRepository() { public AccountRepository getAccountRepository() {
return new HSQLDBAccountRepository(this); return this.accountRepository;
} }
@Override @Override
public ArbitraryRepository getArbitraryRepository() { public ArbitraryRepository getArbitraryRepository() {
return new HSQLDBArbitraryRepository(this); return this.arbitraryRepository;
} }
@Override @Override
public AssetRepository getAssetRepository() { public AssetRepository getAssetRepository() {
return new HSQLDBAssetRepository(this); return this.assetRepository;
} }
@Override @Override
public BlockRepository getBlockRepository() { public BlockRepository getBlockRepository() {
return new HSQLDBBlockRepository(this); return this.blockRepository;
} }
@Override @Override
public ChatRepository getChatRepository() { public ChatRepository getChatRepository() {
return new HSQLDBChatRepository(this); return this.chatRepository;
} }
@Override @Override
public CrossChainRepository getCrossChainRepository() { public CrossChainRepository getCrossChainRepository() {
return new HSQLDBCrossChainRepository(this); return this.crossChainRepository;
} }
@Override @Override
public GroupRepository getGroupRepository() { public GroupRepository getGroupRepository() {
return new HSQLDBGroupRepository(this); return this.groupRepository;
} }
@Override @Override
public MessageRepository getMessageRepository() { public MessageRepository getMessageRepository() {
return new HSQLDBMessageRepository(this); return this.messageRepository;
} }
@Override @Override
public NameRepository getNameRepository() { public NameRepository getNameRepository() {
return new HSQLDBNameRepository(this); return this.nameRepository;
} }
@Override @Override
public NetworkRepository getNetworkRepository() { public NetworkRepository getNetworkRepository() {
return new HSQLDBNetworkRepository(this); return this.networkRepository;
} }
@Override @Override
public TransactionRepository getTransactionRepository() { public TransactionRepository getTransactionRepository() {
return new HSQLDBTransactionRepository(this); return this.transactionRepository;
} }
@Override @Override
public VotingRepository getVotingRepository() { public VotingRepository getVotingRepository() {
return new HSQLDBVotingRepository(this); return this.votingRepository;
} }
@Override @Override

Loading…
Cancel
Save