Skip to content

Commit

Permalink
Split processes for bulk and updates of sigel #462
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Aug 10, 2023
1 parent f96fa93 commit bf2d271
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
4 changes: 3 additions & 1 deletion app/transformation/TransformAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public static void process(String startOfUpdates, int intervalSize,
final String outputPath, String geoServer) throws IOException {
String dbsOutput = outputPath + "-dbs";
String sigelOutput = outputPath + "-sigel";
TransformSigel.process(startOfUpdates, intervalSize, sigelOutput,
TransformSigel.processBulk(startOfUpdates, intervalSize, sigelOutput,
geoServer);
TransformSigel.processUpdates(startOfUpdates, intervalSize, sigelOutput,
geoServer);
TransformDbs.process(dbsOutput, geoServer);
try (FileWriter resultWriter = new FileWriter(outputPath)) {
Expand Down
19 changes: 14 additions & 5 deletions app/transformation/TransformSigel.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,30 @@ public class TransformSigel {
"/*[local-name() = 'record']/*[local-name() = 'global']/*[local-name() = 'tag'][@id='008H']/*[local-name() = 'subf'][@id='e']";
static final String DUMP_XPATH = "/" + DUMP_TOP_LEVEL_TAG + "/" + XPATH;

static void process(String startOfUpdates, int intervalSize,
static void processBulk(String startOfUpdates, int intervalSize,
final String outputPath, String geoLookupServer) throws IOException {
final FileOpener splitFileOpener = new FileOpener();
final FileOpener dumpOpener = new FileOpener();
final FileOpener dumpOpener = new FileOpener();
PicaDecoder picaDecoder = new PicaDecoder();
picaDecoder.setNormalizeUTF8(true);
JsonEncoder encodeJson = new JsonEncoder();
encodeJson.setPrettyPrinting(true);
dumpOpener//
.setReceiver(new LineReader())//
.setReceiver(new PicaDecoder())//
.setReceiver(picaDecoder)//
.setReceiver(new Metafix("conf/fix-sigel.fix"))//
.setReceiver(TransformAll.fixEnriched(geoLookupServer))//
.setReceiver(encodeJson)//
.setReceiver(TransformAll.esBulk())//
.setReceiver(new ObjectWriter<>(outputPath));
dumpOpener.process(TransformAll.DATA_INPUT_DIR + "sigil.dat");
dumpOpener.closeStream();
}

static void processUpdates(String startOfUpdates, int intervalSize,
final String outputPath, String geoLookupServer) throws IOException {
final FileOpener splitFileOpener = new FileOpener();
JsonEncoder encodeJson = new JsonEncoder();
encodeJson.setPrettyPrinting(true);
ObjectWriter objectWriter = new ObjectWriter<>(outputPath);
objectWriter.setAppendIfFileExists(true);
splitFileOpener//
Expand All @@ -84,7 +92,8 @@ static void process(String startOfUpdates, int intervalSize,
.collect(Collectors.toList()).forEach(path -> {
splitFileOpener.process(path.toString());
});

splitFileOpener.closeStream();


}

Expand Down
Loading

0 comments on commit bf2d271

Please sign in to comment.