mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
CE-1955 Memoize groupByAllIndexesFromTable to avoid wasting lots of arrayLists; add todo about maybe only doing grouping if there is a mapped child table...
This commit is contained in:
@ -55,6 +55,7 @@ public class TallRowsToRecord implements RowsToRecordInterface
|
|||||||
private static final QLogger LOG = QLogger.getLogger(TallRowsToRecord.class);
|
private static final QLogger LOG = QLogger.getLogger(TallRowsToRecord.class);
|
||||||
|
|
||||||
private Memoization<Pair<String, String>, Boolean> shouldProcesssAssociationMemoization = new Memoization<>();
|
private Memoization<Pair<String, String>, Boolean> shouldProcesssAssociationMemoization = new Memoization<>();
|
||||||
|
private Memoization<String, List<Integer>> groupByAllIndexesFromTableMemoization = new Memoization<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -96,6 +97,10 @@ public class TallRowsToRecord implements RowsToRecordInterface
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// maybe todo - some version of - only do this if there are mapped children? //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if(rowsForCurrentRecord.isEmpty())
|
if(rowsForCurrentRecord.isEmpty())
|
||||||
{
|
{
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
@ -153,9 +158,12 @@ public class TallRowsToRecord implements RowsToRecordInterface
|
|||||||
**
|
**
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
private List<Integer> groupByAllIndexesFromTable(BulkInsertMapping mapping, QTableMetaData table, BulkLoadFileRow headerRow, String name) throws QException
|
private List<Integer> groupByAllIndexesFromTable(BulkInsertMapping mapping, QTableMetaData table, BulkLoadFileRow headerRow, String name) throws QException
|
||||||
|
{
|
||||||
|
return ((groupByAllIndexesFromTableMemoization.getResult(table.getName(), (n) ->
|
||||||
{
|
{
|
||||||
Map<String, Integer> fieldIndexes = mapping.getFieldIndexes(table, name, headerRow);
|
Map<String, Integer> fieldIndexes = mapping.getFieldIndexes(table, name, headerRow);
|
||||||
return new ArrayList<>(fieldIndexes.values());
|
return new ArrayList<>(fieldIndexes.values());
|
||||||
|
})).orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -166,6 +174,7 @@ public class TallRowsToRecord implements RowsToRecordInterface
|
|||||||
private QRecord makeRecordFromRows(QTableMetaData table, String associationNameChain, BulkInsertMapping mapping, BulkLoadFileRow headerRow, List<BulkLoadFileRow> rows) throws QException
|
private QRecord makeRecordFromRows(QTableMetaData table, String associationNameChain, BulkInsertMapping mapping, BulkLoadFileRow headerRow, List<BulkLoadFileRow> rows) throws QException
|
||||||
{
|
{
|
||||||
QRecord record = new QRecord();
|
QRecord record = new QRecord();
|
||||||
|
record.setTableName(table.getName());
|
||||||
BulkLoadRecordUtils.addBackendDetailsAboutFileRows(record, CollectionUtils.useOrWrap(rows, new TypeToken<ArrayList<BulkLoadFileRow>>() {}));
|
BulkLoadRecordUtils.addBackendDetailsAboutFileRows(record, CollectionUtils.useOrWrap(rows, new TypeToken<ArrayList<BulkLoadFileRow>>() {}));
|
||||||
|
|
||||||
Map<String, Integer> fieldIndexes = mapping.getFieldIndexes(table, associationNameChain, headerRow);
|
Map<String, Integer> fieldIndexes = mapping.getFieldIndexes(table, associationNameChain, headerRow);
|
||||||
@ -273,6 +282,10 @@ public class TallRowsToRecord implements RowsToRecordInterface
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// maybe todo - some version of - only do this if there are mapped children? //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
List<Serializable> rowGroupByValues = getGroupByValues(row, groupByIndexes);
|
List<Serializable> rowGroupByValues = getGroupByValues(row, groupByIndexes);
|
||||||
if(rowGroupByValues == null)
|
if(rowGroupByValues == null)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user