https://bz.apache.org/bugzilla/show_bug.cgi?id=64322

            Bug ID: 64322
           Summary: Very poor performance reading OLE2
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POIFS
          Assignee: dev@poi.apache.org
          Reporter: lfcnas...@gmail.com
  Target Milestone: ---

Created attachment 37154
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=37154&action=edit
Part 1 of 3

Attached file with 3.7MB takes more than 10min to be parsed with POI-4.0.1.
Profiling with jvisualvm, most time is spent in IOUtils.readFully() (360s),
FileBackedDataSource.size() (248s) and FileBackedDataSource.read() (88s). Code
to reproduce below:

    public static void main(String[] args) {

        File file = new File("F:\\teste-files\\thumbs.db\\New
Folder\\Thumbs.db");
        try (POIFSFileSystem poiFS = new POIFSFileSystem(file)) {
            recurseDir(poiFS.getRoot());

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void recurseDir(DirectoryEntry dir) {
        for (Entry entry : dir) {
            try {
                if (entry instanceof DirectoryEntry) {
                    recurseDir((DirectoryEntry) entry);
                }
                if (entry instanceof DocumentEntry) {
                    DocumentEntry de = (DocumentEntry) entry;
                    HashMap<String, String> props = new HashMap<>();
                    try (DocumentInputStream dis = new DocumentInputStream(de))
{
                        props.put("name", de.getName());

                        if (PropertySet.isPropertySetStream(dis)) {
                            dis.mark(10000000);
                            PropertySet ps = null;
                            try {
                                ps = new PropertySet(dis);

                            } catch (UnsupportedEncodingException e) {
                                // ignore
                            }
                            if (ps != null) {
                                for (Section section : ps.getSections()) {
                                    for (Property p : section.getProperties())
{
                                        String prop = section.getDictionary()
!= null
                                                ?
section.getDictionary().get(p.getID())
                                                : String.valueOf(p.getID());
                                        if (p.getValue() != null)
                                            props.put("property_" + prop,
p.getValue().toString());
                                    }
                                }
                            }
                            dis.reset();
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to