naruto-lgtm opened a new pull request, #1570: URL: https://github.com/apache/poi/pull/1570
Repro: add 4,000 extra drawing relationships pointing at `../drawings/drawing1.xml` to the sheet .rels of an xlsx whose drawing has 50 text boxes (17 KB file). `XSSFEventBasedExcelExtractor.getText()` then takes 14.7 s and returns 1.16 MB of text instead of 297 characters in about 35 ms, and `SheetIterator.getShapes()` returns 200,050 shapes. Cause: `XSSFReader.getSheetDrawingParts` returns one entry per drawing relationship, so a part targeted by n relationships comes back n times and `getShapes()` parses it n times. The cost is relationships times drawing size, both chosen by the file, on the default event-API text extraction path (`includeTextBoxes` is on) and in anything else that reads shapes through `SheetIterator`, such as Tika. The loop also fetched each relationship by index, which walks the collection, so it was quadratic in the relationship count on its own. Fix: iterate the relationships once and skip part names that were already returned. A worksheet has at most one `<drawing>`, so valid files give the same result, and the usermodel already behaves this way because `POIXMLDocumentPart.read` maps each package part to a single document part. `TestXSSFReader.testDrawingTargetedByDuplicateRelationships` adds 100 duplicate relationships to WithTextBox.xlsx and fails before the change; the xssf eventusermodel and extractor suites pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
