(loader) Tidy up code

This commit is contained in:
Viktor Lofgren 2024-07-28 21:36:42 +02:00
parent 7d51cf882f
commit afe56c7cf1

View File

@ -43,7 +43,8 @@ public class DomainLoaderService {
FETCH_ALL, FETCH_ALL,
DONE DONE
} }
/** Read the domain names from each parquet file
/** Read the domain names from each input file
* compare with SQL domain database, fetch those * compare with SQL domain database, fetch those
* that exist, insert those that don't. * that exist, insert those that don't.
*/ */
@ -54,11 +55,8 @@ public class DomainLoaderService {
DomainIdRegistry ret = new DomainIdRegistry(); DomainIdRegistry ret = new DomainIdRegistry();
try (var conn = dataSource.getConnection(); try (var conn = dataSource.getConnection();
var taskHeartbeat = heartbeat.createProcessTaskHeartbeat(Steps.class, "DOMAIN_IDS"); var taskHeartbeat = heartbeat.createProcessTaskHeartbeat(Steps.class, "DOMAIN_IDS"))
var selectStmt = conn.prepareStatement(""" {
SELECT ID, LOWER(DOMAIN_NAME) FROM EC_DOMAIN
""")
) {
taskHeartbeat.progress(Steps.PREP_DATA); taskHeartbeat.progress(Steps.PREP_DATA);
Collection<SlopPageRef<SlopDomainRecord>> domainPageRefs = inputData.listDomainPages(); Collection<SlopPageRef<SlopDomainRecord>> domainPageRefs = inputData.listDomainPages();
@ -128,6 +126,10 @@ public class DomainLoaderService {
} }
taskHeartbeat.progress(Steps.FETCH_ALL); taskHeartbeat.progress(Steps.FETCH_ALL);
// Fetch the ID for all domains that we have information about
try (var selectStmt = conn.prepareStatement("SELECT ID, LOWER(DOMAIN_NAME) FROM EC_DOMAIN")) {
selectStmt.setFetchSize(1000); selectStmt.setFetchSize(1000);
var rs = selectStmt.executeQuery(); var rs = selectStmt.executeQuery();
@ -138,6 +140,7 @@ public class DomainLoaderService {
ret.add(domain, rs.getInt(1)); ret.add(domain, rs.getInt(1));
} }
} }
}
taskHeartbeat.progress(Steps.DONE); taskHeartbeat.progress(Steps.DONE);
} }