Skip to content

Commit

Permalink
move to lazy init
Browse files Browse the repository at this point in the history
  • Loading branch information
codingPF committed Aug 8, 2023
1 parent 2260ded commit dd2461f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public List<List<Film>> removeDuplicatesAndMerge(List<List<Film>> filmlist) thro

public <T> List<List<T>> partition(List<List<T>> inputList, int partitions){
if (PARTITION_SIZE <= 0 || partitions <= 0) {
return inputList;
LOG.info("no paritioned active");
return inputList;
}

List<List<T>> result = new ArrayList<>(partitions);
Expand All @@ -62,7 +63,7 @@ public <T> List<List<T>> partition(List<List<T>> inputList, int partitions){
for(int i = 0; i < inputList.size(); i++)
result.get(i % partitions).add(inputList.get(i).get(0));

LOG.info("paritioned into " + result.size() + " groups" );
LOG.info("paritioned into " + result.size() + " group(s)" );

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Film implements Serializable {
private Duration duration;

@Column
@OneToMany(mappedBy = "film", fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, orphanRemoval = true)
@OneToMany(mappedBy = "film", fetch = FetchType.LAZY, cascade = {CascadeType.ALL}, orphanRemoval = true)
@Where(clause = "type='FILM_URL'")
public Set<de.mediathekview.fimlistmerger.persistence.FilmUrl> urls;

Expand All @@ -53,25 +53,26 @@ public class Film implements Serializable {

@Column private LocalDateTime time;

@ElementCollection(fetch = FetchType.EAGER) @Column private List<GeoLocations> geoLocations;
@ElementCollection(fetch = FetchType.LAZY) @Column private List<GeoLocations> geoLocations;

@Column(columnDefinition = "TEXT") private String beschreibung;

@Column(length = 400) private String website;
@Column
private String website;

@Column private boolean neu;

@Column
@OneToMany(mappedBy = "film", fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
@OneToMany(mappedBy = "film", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
@Where(clause = "type='AUDIO_DESCRIPTION'")
private Set<de.mediathekview.fimlistmerger.persistence.FilmUrl> audioDescriptions;

@Column
@OneToMany(mappedBy = "film", fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
@OneToMany(mappedBy = "film", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
@Where(clause = "type='SIGN_LANGUAGE'")
private Set<de.mediathekview.fimlistmerger.persistence.FilmUrl> signLanguages;

@ElementCollection(fetch = FetchType.EAGER) @Column private Set<String> subtitles;
@ElementCollection(fetch = FetchType.LAZY) @Column private Set<String> subtitles;

@Override
public boolean equals(Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class FilmUrl {
@SequenceGenerator(name = "seqGen", sequenceName = "film_urls_id_seq", allocationSize = 100)
private long id;

@Column(length = 400) private String url;
@Column
private String url;

@Column
@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public void configure() {
simple("${body.getFilms().keySet().size()}"))
.to(Metrics.COUNTER_READ_FILMS_OLD_FORMAT_MAX.toString())
.process(filmlistSplitterBean)
.log(LoggingLevel.INFO, "Old filmlist make unique: ${body.size()}")
.log(LoggingLevel.INFO, "Unique body size: ${body.size()}")
.split(body())
.streaming()
.parallelProcessing()
//.log(LoggingLevel.INFO, "Old filmlist aggregated: ${body.size()}")
//.log(LoggingLevel.INFO, "Split into groups: ${body.size()}")
.to(FilmToDatabaseTargetRoute.ROUTE_FROM)
.id(SINGLE_OLD_FORMAT_FILM_ROUTING_TARGET);
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# General
camel.dataformat.json-jackson.auto-discover-object-mapper=true
camel.springboot.main-run-controller=true
camel.threadpool.pool-size = 50
camel.threadpool.pool-size = 100
camel.threadpool.max-pool-size = 100
FilmlistSplitterBean.messageChunkSize = 50
FilmlistSplitterBean.messageChunkSize = 100

logging.level.liquibase=WARN
logging.level.root=INFO
logging.level.org.apache.camel=INFO



spring.jpa.properties.hibernate.generate_statistics=true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
#spring.jpa.properties.hibernate.generate_statistics=true
#logging.level.org.hibernate.SQL=DEBUG
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

camel.component.metrics.enabled=true

Expand Down

0 comments on commit dd2461f

Please sign in to comment.