GitHub PullRequestReviewCommentEvent at 2014-04-02 18:00:57
Repository: lenskit
Actor: elehack
Payload: {"comment":{"url":"https://api.github.com/repos/grouplens/lenskit/pulls/comments/11218475","id":11218475,"diff_hunk":"@@ -0,0 +1,196 @@\n+/*\n+ * LensKit, an open source recommender systems toolkit.\n+ * Copyright 2010-2013 Regents of the University of Minnesota and contributors\n+ * Work on LensKit has been funded by the National Science Foundation under\n+ * grants IIS 05-34939, 08-08692, 08-12148, and 10-17697.\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU Lesser General Public License as\n+ * published by the Free Software Foundation; either version 2.1 of the\n+ * License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n+ * details.\n+ *\n+ * You should have received a copy of the GNU General Public License along with\n+ * this program; if not, write to the Free Software Foundation, Inc., 51\n+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n+ */\n+package org.grouplens.lenskit.data.sql;\n+\n+import com.google.common.base.Preconditions;\n+import com.google.common.cache.Cache;\n+import com.google.common.cache.CacheBuilder;\n+import com.google.common.cache.CacheBuilderSpec;\n+import org.grouplens.lenskit.data.event.Rating;\n+\n+import javax.annotation.Nonnull;\n+import javax.annotation.Nullable;\n+import java.sql.Connection;\n+import java.util.List;\n+\n+/**\n+ * Construct and configure a JDBC rating DAO. Get a builder with {@link JDBCRatingDAO#newBuilder()}.\n+ *\n+ * @author <a href=\"http://www.grouplens.org\">GroupLens Research</a>\n+ * @since 2.1\n+ */\n+public class JDBCRatingDAOBuilder {\n+    private SQLStatementFactory factory;\n+    private BasicSQLStatementFactory basicFactory;\n+    private boolean closeWhenClosed = true;\n+    private CacheBuilder<? super QueryKey, ? super List<?>> cacheBuilder;\n+    private Cache<QueryKey, List<Rating>> queryCache;\n+\n+    JDBCRatingDAOBuilder() {\n+        factory = basicFactory = new BasicSQLStatementFactory();\n+        cacheBuilder = CacheBuilder.newBuilder().softValues().maximumSize(1000);\n+    }\n+\n+    public String getTableName() {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        return basicFactory.getTableName();\n+    }\n+\n+    public JDBCRatingDAOBuilder setTableName(String table) {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        basicFactory.setTableName(table);\n+        return this;\n+    }\n+\n+    public String getUserColumn() {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        return basicFactory.getUserColumn();\n+    }\n+\n+    public JDBCRatingDAOBuilder setUserColumn(@Nonnull String col) {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        basicFactory.setUserColumn(col);\n+        return this;\n+    }\n+\n+    public String getItemColumn() {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        return basicFactory.getItemColumn();\n+    }\n+\n+    public JDBCRatingDAOBuilder setItemColumn(@Nonnull String col) {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        basicFactory.setItemColumn(col);\n+        return this;\n+    }\n+\n+    public String getRatingColumn() {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        return basicFactory.getRatingColumn();\n+    }\n+\n+    public JDBCRatingDAOBuilder setRatingColumn(@Nonnull String col) {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        basicFactory.setRatingColumn(col);\n+        return this;\n+    }\n+\n+    public String getTimestampColumn() {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        return basicFactory.getTimestampColumn();\n+    }\n+\n+    public JDBCRatingDAOBuilder setTimestampColumn(@Nullable String col) {\n+        Preconditions.checkState(basicFactory != null, \"statement factory has been explicitly set\");\n+        basicFactory.setTimestampColumn(col);\n+        return this;\n+    }\n+\n+    public boolean isCloseWhenClosed() {\n+        return closeWhenClosed;\n+    }\n+\n+    /**\n+     * Configure whether the the DAO should close the database connection.\n+     *\n+     * @param close {@code true} to close the database connection with the DAO, {@code false} to\n+     *              leave it open.\n+     * @return The builder (for chaining).\n+     */\n+    public JDBCRatingDAOBuilder setCloseWhenClosed(boolean close) {\n+        this.closeWhenClosed = close;\n+        return this;\n+    }\n+\n+    /**\n+     * Set the statement factory to be used by the DAO.\n+     * @param fac The statement factory.\n+     * @return The builder (for chaining).\n+     */\n+    public JDBCRatingDAOBuilder setStatementFactory(SQLStatementFactory fac) {\n+        factory = fac;\n+        basicFactory = null;","path":"lenskit-core/src/main/java/org/grouplens/lenskit/data/sql/JDBCRatingDAOBuilder.java","position":130,"original_position":130,"commit_id":"53284ddb89b6f0c8846cc4e39d6fbbd9c67c77f0","original_commit_id":"53284ddb89b6f0c8846cc4e39d6fbbd9c67c77f0","user":{"login":"elehack","id":186612,"avatar_url":"https://avatars.githubusercontent.com/u/186612?","gravatar_id":"ac3aecf907aaef0c19f5fa6d8ed2b31b","url":"https://api.github.com/users/elehack","html_url":"https://github.com/elehack","followers_url":"https://api.github.com/users/elehack/followers","following_url":"https://api.github.com/users/elehack/following{/other_user}","gists_url":"https://api.github.com/users/elehack/gists{/gist_id}","starred_url":"https://api.github.com/users/elehack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elehack/subscriptions","organizations_url":"https://api.github.com/users/elehack/orgs","repos_url":"https://api.github.com/users/elehack/repos","events_url":"https://api.github.com/users/elehack/events{/privacy}","received_events_url":"https://api.github.com/users/elehack/received_events","type":"User","site_admin":false},"body":"Not currently. I don't know that it's worth adding - maybe if you set the statement factory to `null`, though?","created_at":"2014-04-02T18:00:57Z","updated_at":"2014-04-02T18:00:57Z","html_url":"https://github.com/grouplens/lenskit/pull/551#discussion_r11218475","pull_request_url":"https://api.github.com/repos/grouplens/lenskit/pulls/551","_links":{"self":{"href":"https://api.github.com/repos/grouplens/lenskit/pulls/comments/11218475"},"html":{"href":"https://github.com/grouplens/lenskit/pull/551#discussion_r11218475"},"pull_request":{"href":"https://api.github.com/repos/grouplens/lenskit/pulls/551"}}}}