GitHub PullRequestReviewCommentEvent at 2014-04-02 17:52:02
Repository: lenskit
Actor: kluver
Payload: {"comment":{"url":"https://api.github.com/repos/grouplens/lenskit/pulls/comments/11217956","id":11217956,"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;\n+        return this;\n+    }\n+\n+    /**\n+     * Get the statement factory the DAO will use.\n+     * @return The statement factory the DAO will use.\n+     */\n+    public SQLStatementFactory getStatementFactory() {\n+        return factory;","path":"lenskit-core/src/main/java/org/grouplens/lenskit/data/sql/JDBCRatingDAOBuilder.java","position":139,"original_position":139,"commit_id":"53284ddb89b6f0c8846cc4e39d6fbbd9c67c77f0","original_commit_id":"53284ddb89b6f0c8846cc4e39d6fbbd9c67c77f0","user":{"login":"kluver","id":5695556,"avatar_url":"https://avatars.githubusercontent.com/u/5695556?","gravatar_id":"a5777b010bf28de4f9d760838da69a1a","url":"https://api.github.com/users/kluver","html_url":"https://github.com/kluver","followers_url":"https://api.github.com/users/kluver/followers","following_url":"https://api.github.com/users/kluver/following{/other_user}","gists_url":"https://api.github.com/users/kluver/gists{/gist_id}","starred_url":"https://api.github.com/users/kluver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kluver/subscriptions","organizations_url":"https://api.github.com/users/kluver/orgs","repos_url":"https://api.github.com/users/kluver/repos","events_url":"https://api.github.com/users/kluver/events{/privacy}","received_events_url":"https://api.github.com/users/kluver/received_events","type":"User","site_admin":false},"body":"Shouldn't this be able to return basicFactory?","created_at":"2014-04-02T17:52:02Z","updated_at":"2014-04-02T17:52:02Z","html_url":"https://github.com/grouplens/lenskit/pull/551#discussion_r11217956","pull_request_url":"https://api.github.com/repos/grouplens/lenskit/pulls/551","_links":{"self":{"href":"https://api.github.com/repos/grouplens/lenskit/pulls/comments/11217956"},"html":{"href":"https://github.com/grouplens/lenskit/pull/551#discussion_r11217956"},"pull_request":{"href":"https://api.github.com/repos/grouplens/lenskit/pulls/551"}}}}