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

Rationalize DataModel.getNumUsersWithPreferenceFor() API

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.5
    • 0.6
    • None

    Description

      DataModel has a method getNumUsersWithPreferenceFor(long... itemIDs). It does what it says. However I think this is a suboptimal API (for which we have me to blame).

      • All calls to this involve 1 or 2 arguments only
      • No implementation supports more than 2 arguments, which makes the signature misleading
      • All implementations internally have some logic like "if it's 1, do X, if it's args, do Y, otherwise fail"
      • Calling this method, which happens frequently, always incurs the overhead of allocating a long[]

      The change is simple: make this two methods, with one and two args respectively. Implementations would then just split their current implementation into these two methods.

      There is no API change for callers, at all, if invoked with 1 or 2 args. I assume callers are not trying 3+ args now, as it has never been supported.
      It does involve a straightforward change to implementors of DataModel.

      Open for comment?

      Attachments

        1. MAHOUT-764.patch
          15 kB
          Sean R. Owen

        Activity

          People

            srowen Sean R. Owen
            srowen Sean R. Owen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: