Search code examples
javaeclipsemahout

what causes the error like " the constructor is undefined"


I am trying to compile the example code of "Mahout in Action" in Eclipse. There is a java file titled as "LimitedMemoryDiffStorage.java". Which essentially just define a class

class LimitedMemoryDiffStorage {

Recommender buildRecommender(DataModel model) throws TasteException {
  DiffStorage diffStorage = new MemoryDiffStorage(
    model, Weighting.WEIGHTED, true, 10000000L);
  return new SlopeOneRecommender(
    model, Weighting.WEIGHTED, Weighting.WEIGHTED, diffStorage);
 }

}

But the eclipse compiler states

The constructor MemoryDiffStorage(DataModel, Weighting, boolean, long) is undefined

I think it is defined in the mahout-core library and has been included in the build path, why it still causes this kind of error?


Solution

  • Maybe you are using a version of the library that is different from the one described in the book. Many times it happens that some of the methods, constructors or even classes are changed or even removed. The best way to check this would be to check the sources of mahout-core library, or at least the byte code. To see the methods including constructor in Eclipse, open the specific MemoryDiffStorage class by pressing CTRL + SHIFT + T and typing in the class name. Then in the outline view you should see the actual constructors with their signatures.