You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Dennis Gove (JIRA)" <ji...@apache.org> on 2017/05/09 00:27:04 UTC

[jira] [Commented] (SOLR-10617) JDBCStream: support more data types

    [ https://issues.apache.org/jira/browse/SOLR-10617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16001842#comment-16001842 ] 

Dennis Gove commented on SOLR-10617:
------------------------------------

I've only taken a quick look at this point, but I do want to point this out.

{code}
} else if (jdbcType == Types.DATE || jdbcType == Types.TIME || jdbcType == Types.TIMESTAMP) {
  valueSelectors[columnIdx] = new ResultSetValueSelector() {
    public Object selectValue(ResultSet resultSet) throws SQLException {
      if (jdbcType == Types.TIME) {
        Time sqlTime = resultSet.getTime(columnNumber);
        return resultSet.wasNull() ? null : sqlTime.toString();
      } else if (jdbcType == Types.DATE) {
        Date sqlDate = resultSet.getDate(columnNumber);
        return resultSet.wasNull() ? null : sqlDate.toString();
      } else {
        Timestamp sqlTimestamp = resultSet.getTimestamp(columnNumber);
        return resultSet.wasNull() ? null : sqlTimestamp.toInstant().toString();
      }
    }

    public String getColumnName() {
      return columnName;
    }
  };
}
{code}

The value selectors are constructed on open so that we can avoid executing the same conditional check on each row in the result set. By putting the jdbc type check inside of selectValue it is now repeating the same conditional for each row, even though every row will end up going down the same path.

While splitting these checks up does result in repeated code, the performance saving is well worth it.

> JDBCStream: support more data types
> -----------------------------------
>
>                 Key: SOLR-10617
>                 URL: https://issues.apache.org/jira/browse/SOLR-10617
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: SolrJ
>            Reporter: James Dyer
>            Assignee: James Dyer
>            Priority: Minor
>         Attachments: SOLR-10617.patch
>
>
> It would be nice if JDBCStream could support Decimal types as well as Timestamp-related types, and CLOBs.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org