Stopwatch timer = Stopwatch.createStarted();
LenskitRecommenderEngine engine = builder.build();
timer.stop();
logger.info("built model in {}", timer);
File output = getOutputFile();
CompressionMode comp = CompressionMode.autodetect(output);
logger.info("writing model to {}", output);
Closer closer = Closer.create();
try {
OutputStream stream = closer.register(new FileOutputStream(output));
stream = closer.register(comp.wrapOutput(stream));
engine.write(stream);
} catch (Throwable th) {
throw closer.rethrow(th);
} finally {
closer.close();