Uploaded image for project: 'Mahout'
  1. Mahout
  2. MAHOUT-1068

FileDataModel should ignore directories when reloading data

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.7
    • Fix Version/s: 0.8
    • Labels:
      None

      Description

      I work with a directory that contains :

      • a file test.csv (my data for recommendation)
      • a directory test (for other purpose ...)

      And surprinsigly i encountered the following error.java.io.FileNotFoundException: .../test (Is a directory)
      at java.io.FileInputStream.open(Native Method) ~[na:1.7.0_03]
      at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[na:1.7.0_03]
      at org.apache.mahout.common.iterator.FileLineIterator.getFileInputStream(FileLineIterator.java:98) ~[mahout-core-0.7.jar:0.7]
      at org.apache.mahout.common.iterator.FileLineIterator.<init>(FileLineIterator.java:79) ~[mahout-core-0.7.jar:0.7]
      at org.apache.mahout.common.iterator.FileLineIterator.<init>(FileLineIterator.java:67) ~[mahout-core-0.7.jar:0.7]
      at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.buildModel(FileDataModel.java:238) [mahout-core-0.7.jar:0.7]
      at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.reload(FileDataModel.java:207) [mahout-core-0.7.jar:0.7]
      at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:193) [mahout-core-0.7.jar:0.7]
      at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:148) [mahout-core-0.7.jar:0.7]

      After looking at the code, i saw that the method findUpdateFilesAfter doesn't filter directories.

      I proposed to add a test in the method :
      ...
      for (File updateFile : parentDir.listFiles()) {
      + if (!updateFile.isDirectory()) {
      String updateFileName = updateFile.getName();

        Activity

        Hide
        srowen Sean Owen added a comment -

        No problem, added (as a FileFilter).

        Show
        srowen Sean Owen added a comment - No problem, added (as a FileFilter).

          People

          • Assignee:
            srowen Sean Owen
            Reporter:
            yamo Yann Moisan
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development