Embedded Serving Layer

The Serving Layer can be embedded into another standalone Java application. This makes it possible to combine a Serving Layer into another application, or access it directly without having to go through a REST API. At its core, the Serving Layer is an instance of ServerRecommender. As of version 0.5, it can be configured as follows:

File localInputDir = ...;
ServerRecommender recommender = 
  new ServerRecommender(localInputDir);

recommender, being a ServerRecommender, implements Apache Mahout's Recommender and ItemBasedRecommender interfaces. It is thus a drop-in replacement for contexts that use a Mahout (non-distributed) API.

It also implements the extended API defined in MyrrixRecommender. It provides therefore a Java API analogous to the REST API -- in fact this is the implementation that underpins it. For example, the /recommend endpoint in the REST API corresponds to the recommend(long, int) Java API method.

// 10 recommendations for user 153
List recs = recommender.recommend(153, 10);

Adding To Your Project

All classes needed to use the Serving Layer are contained in myrrix-serving-x.y.jar. Simply add this JAR file to your classpath or project to use it as an embedded service.

If your project's build uses Apache Maven, simply depend on artifact myrrix-online-local from group ID net.myrrix:

<dependency>
  <groupId>net.myrrix</groupId>
  <artifactId>myrrix-online-local</artifactId>
  <version>x.y</version>
</dependency>

If you want to depend on all of the above, but also the actual web app source code, including JSPX files and servlet, then depend on artifact myrrix-web:

<dependency>
  <groupId>net.myrrix</groupId>
  <artifactId>myrrix-web</artifactId>
  <version>x.y</version>
</dependency>

Finally, to access SNAPSHOT versions of the next release, add the Sonatype OSS Public repository to your pom.xml file. This is not necessary to access stable release versions, which are synced to the Maven Central repository.

<repositories>
  ...
  <repository>
    <id>sonatype-oss-public</id>
    <url>https://oss.sonatype.org/content/groups/public/</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>
  ...
</repositories>