mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Merge pull request #7127 from Everlag/everlag/faster_deck_import_column
Deck import's performance improved (fixes #7126)
This commit is contained in:
commit
cb3bb63cdc
2 changed files with 8 additions and 2 deletions
|
@ -33,6 +33,12 @@ public class CardInfo {
|
|||
|
||||
@DatabaseField(indexName = "name_index")
|
||||
protected String name;
|
||||
/**
|
||||
* lower_name exists to speed up importing decks, specifically to provide an indexed column.
|
||||
* H2 does not support expressions in indices, so we need a physical column.
|
||||
*/
|
||||
@DatabaseField(indexName = "lower_name_index")
|
||||
protected String lower_name;
|
||||
@DatabaseField(indexName = "setCode_cardNumber_index")
|
||||
protected String cardNumber;
|
||||
@DatabaseField(indexName = "setCode_cardNumber_index")
|
||||
|
@ -107,6 +113,7 @@ public class CardInfo {
|
|||
|
||||
public CardInfo(Card card) {
|
||||
this.name = card.getName();
|
||||
this.lower_name = name.toLowerCase();
|
||||
this.cardNumber = card.getCardNumber();
|
||||
this.setCode = card.getExpansionSetCode();
|
||||
this.className = card.getClass().getCanonicalName();
|
||||
|
|
|
@ -58,7 +58,6 @@ public enum CardRepository {
|
|||
|
||||
TableUtils.createTableIfNotExists(connectionSource, CardInfo.class);
|
||||
cardDao = DaoManager.createDao(connectionSource, CardInfo.class);
|
||||
|
||||
eventSource.fireRepositoryDbLoaded();
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(CardRepository.class).error("Error creating card repository - ", ex);
|
||||
|
@ -490,7 +489,7 @@ public enum CardRepository {
|
|||
try {
|
||||
String sqlName = name.toLowerCase(Locale.ENGLISH).replaceAll("'", "''");
|
||||
GenericRawResults<CardInfo> rawResults = cardDao.queryRaw(
|
||||
"select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower(name) = '" + sqlName + '\'',
|
||||
"select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower_name = '" + sqlName + '\'',
|
||||
cardDao.getRawRowMapper());
|
||||
List<CardInfo> result = new ArrayList<>();
|
||||
for (CardInfo cardinfo : rawResults) {
|
||||
|
|
Loading…
Reference in a new issue