[ https://issues.apache.org/jira/browse/PHOENIX-1702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14349393#comment-14349393 ]
James Taylor edited comment on PHOENIX-1702 at 3/6/15 6:21 PM: --------------------------------------------------------------- Not crazy about the fix, but there are a couple of alternatives that would be better IMHO: - Ideally add a case statement in the necessary derived classes for the PDataType.toObject(Object o, PDataType actualType) method when actualType.isCoercibleTo(PVarChar.INSTANCE). This would just call through to PDataType.toObject(String value), as we already have methods for each PDataType that converts from a String to the Object. Ideally, we should have an abstract PNumberDataType that has these type of methods so we don't have to repeat the logic in each PDataType numeric concrete class (which wasn't possible before Nick improved our type system). - Less ideally, have an if statement like this in PhoenixPreparedStatement.setObject() instead: {code} @@ -441,7 +442,11 @@ public class PhoenixPreparedStatement extends PhoenixStatement implements Prepar public void setObject(int parameterIndex, Object o, int targetSqlType) throws SQLException { PDataType targetType = PDataType.fromTypeId(targetSqlType); PDataType sourceType = PDataType.fromLiteral(o); - o = targetType.toObject(o, sourceType); + if ( !sourceType.isCastableTo(targetType) && sourceType.isCoercibleTo(PVarChar.INSTANCE)) { + o = targetType.toObject((String)o); + } else { + o = targetType.toObject(o, sourceType); + } setParameter(parameterIndex, o); } {code} was (Author: jamestaylor): Not crazy about the fix, but there are a couple of alternatives that would be better IMHO: - Ideally add a case statement in the necessary derived classes for the PDataType.toObject(Object o, PDataType actualType) method when actualType.isCoercibleTo(PVarChar.INSTANCE). This would just call through to PDataType.toObject(String value), as we already have methods for each PDataType that converts from a String to the Object. Ideally, we should have an abstract PNumberDataType that has these type of methods so we don't have to repeat the logic in each PDataType numeric concrete class (which wasn't possible before Nick improved our type system). - Less ideally, have an if statement like this in PhoenixPreparedStatement.setObject() instead: {code} @@ -441,7 +442,11 @@ public class PhoenixPreparedStatement extends PhoenixStatement implements Prepar public void setObject(int parameterIndex, Object o, int targetSqlType) throws SQLException { PDataType targetType = PDataType.fromTypeId(targetSqlType); PDataType sourceType = PDataType.fromLiteral(o); - o = targetType.toObject(o, sourceType); + if ( !sourceType.isCoercibleTo(targetType) && sourceType.isCoercibleTo(PVarChar.INSTANCE)) { + o = targetType.toObject((String)o); + } else { + o = targetType.toObject(o, sourceType); + } setParameter(parameterIndex, o); } {code} > Allow Phoenix to be used from JMeter > ------------------------------------ > > Key: PHOENIX-1702 > URL: https://issues.apache.org/jira/browse/PHOENIX-1702 > Project: Phoenix > Issue Type: Improvement > Reporter: Nick Dimiduk > Assignee: Nick Dimiduk > Priority: Minor > Attachments: PHOENIX-1702.00.patch > > > Here's a simple patch to allow Phoenix to be invoked from jmeter. Perhaps it > should be made more robust re: additional data types. I've been using this > combination for some performance work recently. -- This message was sent by Atlassian JIRA (v6.3.4#6332)