fix conflict on key
This commit is contained in:
parent
7e02ccb622
commit
48873104b8
2 changed files with 30 additions and 24 deletions
|
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -71,34 +72,39 @@ public class FidNameEnricher implements Handler<SubjectPayload, SubjectPayload>
|
|||
AtomicInteger cacheHits = context.get(PackageVariable.cacheHits);
|
||||
AtomicInteger cacheMisses = context.get(PackageVariable.cacheMisses);
|
||||
|
||||
List<PhonesMap> subjectForSave = subjects.stream().flatMap(subject -> {
|
||||
Long phone = subject.getPhone();
|
||||
if (cachedRecords.containsKey(phone)) {
|
||||
cacheHits.incrementAndGet();
|
||||
fillByCache(subject, cachedRecords.get(phone));
|
||||
} else {
|
||||
cacheMisses.incrementAndGet();
|
||||
Name name = nameByPhone.get(CTUtil.normalizePhoneNumber(phone));
|
||||
if (name == null) {
|
||||
if (noFidsData.isEmpty()) {
|
||||
log.warn("Unexpected scenario...all recs are hit to cache, but nameData was trying to found in indic");
|
||||
Set<Long> seen = java.util.concurrent.ConcurrentHashMap.newKeySet();
|
||||
|
||||
List<PhonesMap> subjectForSave = subjects.stream()
|
||||
.flatMap(subject -> {
|
||||
Long phone = subject.getPhone();
|
||||
if (cachedRecords.containsKey(phone)) {
|
||||
cacheHits.incrementAndGet();
|
||||
fillByCache(subject, cachedRecords.get(phone));
|
||||
} else {
|
||||
cacheMisses.incrementAndGet();
|
||||
Name name = nameByPhone.get(CTUtil.normalizePhoneNumber(phone));
|
||||
if (name == null) {
|
||||
if (noFidsData.isEmpty()) {
|
||||
log.warn("Unexpected scenario...all recs are hit to cache, but nameData was trying to found in indic");
|
||||
}
|
||||
return Stream.of(PhonesMap.builder()
|
||||
.phone(phone)
|
||||
.build());
|
||||
}
|
||||
fillByName(subject, name);
|
||||
return Stream.of(PhonesMap.builder()
|
||||
.fid(subject.getFid())
|
||||
.phone(phone)
|
||||
.name1(name.getLast())
|
||||
.first(name.getFirst())
|
||||
.middle(name.getMiddle())
|
||||
.birthDt(name.getBirthDate())
|
||||
.build());
|
||||
}
|
||||
fillByName(subject, name);
|
||||
return Stream.of(PhonesMap.builder()
|
||||
.fid(subject.getFid())
|
||||
.phone(phone)
|
||||
.name1(name.getLast())
|
||||
.first(name.getFirst())
|
||||
.middle(name.getMiddle())
|
||||
.birthDt(name.getBirthDate())
|
||||
.build());
|
||||
}
|
||||
return Stream.empty();
|
||||
}).toList();
|
||||
return Stream.empty();
|
||||
})
|
||||
.filter(phonesMap -> seen.add(phonesMap.getPhone()))
|
||||
.toList();
|
||||
|
||||
packageRecordsService.saveToCache(subjectForSave);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
</appender>
|
||||
|
||||
<!--SQL запросы и результаты их выполнения-->
|
||||
<logger name="ru.nbch.credit_tracker.mapper" level="DEBUG" additivity="false">
|
||||
<logger name="ru.nbch.credit_tracker.mapper" level="INFO" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="FILE-JSON"/>
|
||||
</logger>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue