Re-worked cache issues
This commit is contained in:
parent
8112f2035a
commit
ed5686dc51
@ -59,9 +59,7 @@ public class RedactionController implements RedactionResource {
|
|||||||
|
|
||||||
try (PDDocument pdDocument = PDDocument.load(storedObjectStream, MemoryUsageSetting.setupTempFileOnly())) {
|
try (PDDocument pdDocument = PDDocument.load(storedObjectStream, MemoryUsageSetting.setupTempFileOnly())) {
|
||||||
pdDocument.setAllSecurityToBeRemoved(true);
|
pdDocument.setAllSecurityToBeRemoved(true);
|
||||||
pdDocument.setResourceCache(null);
|
|
||||||
|
|
||||||
pdDocument.setAllSecurityToBeRemoved(true);
|
|
||||||
dictionaryService.updateDictionary(redactionLog.getRuleSetId());
|
dictionaryService.updateDictionary(redactionLog.getRuleSetId());
|
||||||
annotationService.annotate(pdDocument, redactionLog, sectionsGrid);
|
annotationService.annotate(pdDocument, redactionLog, sectionsGrid);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server.segmentation;
|
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.model.SectionArea;
|
||||||
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
|
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
|
||||||
import com.iqser.red.service.redaction.v1.server.classification.model.Page;
|
import com.iqser.red.service.redaction.v1.server.classification.model.Page;
|
||||||
@ -44,7 +43,7 @@ import java.util.Map;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PdfSegmentationService {
|
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 RulingCleaningService rulingCleaningService;
|
||||||
private final TableExtractionService tableExtractionService;
|
private final TableExtractionService tableExtractionService;
|
||||||
@ -52,7 +51,6 @@ public class PdfSegmentationService {
|
|||||||
private final ClassificationService classificationService;
|
private final ClassificationService classificationService;
|
||||||
private final SectionsBuilderService sectionsBuilderService;
|
private final SectionsBuilderService sectionsBuilderService;
|
||||||
private final ImageClassificationService imageClassificationService;
|
private final ImageClassificationService imageClassificationService;
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
|
|
||||||
private void postProcessSections(PDDocument pdDocument, List<SectionText> texts) {
|
private void postProcessSections(PDDocument pdDocument, List<SectionText> texts) {
|
||||||
@ -137,7 +135,7 @@ public class PdfSegmentationService {
|
|||||||
// initialize required variables
|
// initialize required variables
|
||||||
Document document = new Document();
|
Document document = new Document();
|
||||||
List<Page> pages = new ArrayList<>();
|
List<Page> pages = new ArrayList<>();
|
||||||
PDFLinesTextStripper stripper = new PDFLinesTextStripper();
|
|
||||||
|
|
||||||
PDDocument pdDocument = reinitializePDDocument(tempFile, null);
|
PDDocument pdDocument = reinitializePDDocument(tempFile, null);
|
||||||
long pageCount = pdDocument.getNumberOfPages();
|
long pageCount = pdDocument.getNumberOfPages();
|
||||||
@ -148,7 +146,7 @@ public class PdfSegmentationService {
|
|||||||
pdDocument = reinitializePDDocument(tempFile, pdDocument);
|
pdDocument = reinitializePDDocument(tempFile, pdDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PDFLinesTextStripper stripper = new PDFLinesTextStripper();
|
||||||
PDPage pdPage = pdDocument.getPage(pageNumber - 1);
|
PDPage pdPage = pdDocument.getPage(pageNumber - 1);
|
||||||
stripper.setPageNumber(pageNumber);
|
stripper.setPageNumber(pageNumber);
|
||||||
stripper.setStartPage(pageNumber);
|
stripper.setStartPage(pageNumber);
|
||||||
@ -183,6 +181,8 @@ public class PdfSegmentationService {
|
|||||||
imageClassificationService.classifyImages(page);
|
imageClassificationService.classifyImages(page);
|
||||||
|
|
||||||
pages.add(page);
|
pages.add(page);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.setPages(pages);
|
document.setPages(pages);
|
||||||
@ -213,7 +213,7 @@ public class PdfSegmentationService {
|
|||||||
MemoryStats.printMemoryStats();
|
MemoryStats.printMemoryStats();
|
||||||
|
|
||||||
var newPDDocument = PDDocument.load(tempFile, MemoryUsageSetting.setupTempFileOnly());
|
var newPDDocument = PDDocument.load(tempFile, MemoryUsageSetting.setupTempFileOnly());
|
||||||
newPDDocument.setResourceCache(null);
|
newPDDocument.setAllSecurityToBeRemoved(true);
|
||||||
|
|
||||||
return newPDDocument;
|
return newPDDocument;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user