Skip to content

Commit

Permalink
adds exception guards to UpdateMatchingStatsSqlJob.java
Browse files Browse the repository at this point in the history
  • Loading branch information
awildturtok committed Nov 11, 2024
1 parent 1446b9a commit bc7539b
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public void cancel() {

public void calculateMatchingStats(final TreeConcept treeConcept) {

log.info("BEGIN fetching results for {}", treeConcept.getId());


final Map<Connector, Set<Field<?>>> relevantColumns = collectRelevantColumns(treeConcept);
final Map<Connector, List<ColumnDateRange>> validityDateMap = createColumnDateRanges(treeConcept);

Expand Down Expand Up @@ -175,10 +178,18 @@ public void calculateMatchingStats(final TreeConcept treeConcept) {

// not all dialects accept an empty group by () clause
final Select<Record> finalQuery = relevantColumnsAliased.isEmpty() ? query : query.groupBy(relevantColumnsAliased);

final ConceptTreeCache treeCache = new ConceptTreeCache(treeConcept);
executionService.fetchStream(finalQuery)
.forEach(record -> mapRecordToConceptElements(treeConcept, record, treeCache));

try {
executionService.fetchStream(finalQuery)
.forEach(record -> mapRecordToConceptElements(treeConcept, record, treeCache));

}
catch (RuntimeException exception) {
log.error("FAILED collecting results for {}", treeConcept.getId(), exception);
}

log.debug("DONE fetching results for {}", treeConcept.getId());
}

/**
Expand Down Expand Up @@ -292,7 +303,7 @@ private Condition toJooqCondition(final Connector connector, CTCondition childCo
* Select the minimum of the least start date and the maximum of the greatest end date of all validity dates of all connectors.
*/
private Field<String> toValidityDateExpression(final Map<Connector, List<ColumnDateRange>> validityDateMap) {
if (validityDateMap.isEmpty()){
if (validityDateMap.isEmpty()) {
return noField(String.class);
}

Expand All @@ -304,6 +315,7 @@ private Field<String> toValidityDateExpression(final Map<Connector, List<ColumnD
final List<Field<Date>> allStarts = validityDates.stream().map(ColumnDateRange::getStart).toList();
final List<Field<Date>> allEnds = validityDates.stream().map(ColumnDateRange::getEnd).toList();

//HANA does not like lest/greatest if a singleton
final Field<Date> startField = allStarts.size() > 1 ? functionProvider.least(allStarts) : allStarts.get(0);
final Field<Date> endField = allEnds.size() > 1 ? functionProvider.greatest(allEnds) : allEnds.get(0);

Expand Down

0 comments on commit bc7539b

Please sign in to comment.