Re-worked cache issues

This commit is contained in:
Timo 2021-04-17 09:55:46 +03:00
parent 8112f2035a
commit ed5686dc51
2 changed files with 7 additions and 9 deletions

View File

@ -59,9 +59,7 @@ public class RedactionController implements RedactionResource {
try (PDDocument pdDocument = PDDocument.load(storedObjectStream, MemoryUsageSetting.setupTempFileOnly())) {
pdDocument.setAllSecurityToBeRemoved(true);
pdDocument.setResourceCache(null);
pdDocument.setAllSecurityToBeRemoved(true);
dictionaryService.updateDictionary(redactionLog.getRuleSetId());
annotationService.annotate(pdDocument, redactionLog, sectionsGrid);

View File

@ -1,6 +1,5 @@
package com.iqser.red.service.redaction.v1.server.segmentation;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.redaction.v1.model.SectionArea;
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
import com.iqser.red.service.redaction.v1.server.classification.model.Page;
@ -44,7 +43,7 @@ import java.util.Map;
@RequiredArgsConstructor
public class PdfSegmentationService {
private final static int MAX_PAGES_BEFORE_GC = 200;
private final static int MAX_PAGES_BEFORE_GC = 250;
private final RulingCleaningService rulingCleaningService;
private final TableExtractionService tableExtractionService;
@ -52,7 +51,6 @@ public class PdfSegmentationService {
private final ClassificationService classificationService;
private final SectionsBuilderService sectionsBuilderService;
private final ImageClassificationService imageClassificationService;
private final ObjectMapper objectMapper;
private void postProcessSections(PDDocument pdDocument, List<SectionText> texts) {
@ -137,7 +135,7 @@ public class PdfSegmentationService {
// initialize required variables
Document document = new Document();
List<Page> pages = new ArrayList<>();
PDFLinesTextStripper stripper = new PDFLinesTextStripper();
PDDocument pdDocument = reinitializePDDocument(tempFile, null);
long pageCount = pdDocument.getNumberOfPages();
@ -148,7 +146,7 @@ public class PdfSegmentationService {
pdDocument = reinitializePDDocument(tempFile, pdDocument);
}
PDFLinesTextStripper stripper = new PDFLinesTextStripper();
PDPage pdPage = pdDocument.getPage(pageNumber - 1);
stripper.setPageNumber(pageNumber);
stripper.setStartPage(pageNumber);
@ -183,6 +181,8 @@ public class PdfSegmentationService {
imageClassificationService.classifyImages(page);
pages.add(page);
}
document.setPages(pages);
@ -213,7 +213,7 @@ public class PdfSegmentationService {
MemoryStats.printMemoryStats();
var newPDDocument = PDDocument.load(tempFile, MemoryUsageSetting.setupTempFileOnly());
newPDDocument.setResourceCache(null);
newPDDocument.setAllSecurityToBeRemoved(true);
return newPDDocument;
}