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

James Taylor commented on PHOENIX-2691:
---------------------------------------

When a value ends up as part of a row key (as is the case with GROUP BY), we 
have certain restrictions due to not being able to decode certain value types: 
namely VARBINARY and ARRAY. We restrict where you can place these in the 
primary key (only at the end, and only a single one). We need to enforce the 
same restriction for GROUP BY.

Currently the encode/decode code lives in RowKeySchema and RowKeyValueAccessor 
is a kind of simplified version of this (it could go away and we could 
exclusively use RowKeySchema). It would make sense if RowKeySchema lived in our 
type system, but we've only got one type system, so until we have more than 
one, I don't think it matters.

> Exception while unpacking resultset containing VARCHAR ARRAY of unspecified 
> length
> ----------------------------------------------------------------------------------
>
>                 Key: PHOENIX-2691
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2691
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.6.0, 4.7.0
>            Reporter: Nick Dimiduk
>
> I have an aggregation query that consistently throws with either an 
> IllegalArgumentException or an OutOfMemoryException, at the same place. 
> Either way, the stack trace is nearly identical:
> {noformat}
> java.lang.IllegalArgumentException                                            
>                                                      
>         at java.nio.Buffer.position(Buffer.java:244)                          
>                                                      
>         at 
> org.apache.phoenix.schema.types.PArrayDataType.createPhoenixArray(PArrayDataType.java:1098)
>                              
>         at 
> org.apache.phoenix.schema.types.PArrayDataType.toObject(PArrayDataType.java:339)
>                                         
>         at 
> org.apache.phoenix.schema.types.PVarcharArray.toObject(PVarcharArray.java:65) 
>                                           
>         at 
> org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:985)        
>                                           
>         at 
> org.apache.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:75)
>                                     
>         at 
> org.apache.phoenix.jdbc.PhoenixResultSet.getString(PhoenixResultSet.java:601) 
>                                           
>         at sqlline.Rows$Row.<init>(Rows.java:183)                             
>                                                      
>         at sqlline.BufferedRows.<init>(BufferedRows.java:38)                  
>                                                      
>         at sqlline.SqlLine.print(SqlLine.java:1650)                           
>                                                      
>         at sqlline.Commands.execute(Commands.java:833)                        
>                                                      
>         at sqlline.Commands.sql(Commands.java:732)                            
>                                                      
>         at sqlline.SqlLine.dispatch(SqlLine.java:808)                         
>                                                      
>         at sqlline.SqlLine.begin(SqlLine.java:681)                            
>                                                      
>         at sqlline.SqlLine.start(SqlLine.java:398)                            
>                                                      
>         at sqlline.SqlLine.main(SqlLine.java:292)
> {noformat}
> or
> {noformat}
> java.lang.OutOfMemoryError: Java heap space
>         at java.lang.reflect.Array.newArray(Native Method)
>         at java.lang.reflect.Array.newInstance(Array.java:75)
>         at 
> org.apache.phoenix.schema.types.PArrayDataType.createPhoenixArray(PArrayDataType.java:1091)
>         at 
> org.apache.phoenix.schema.types.PArrayDataType.toObject(PArrayDataType.java:339)
>         at 
> org.apache.phoenix.schema.types.PVarcharArray.toObject(PVarcharArray.java:65)
>         at 
> org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:985)
>         at 
> org.apache.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:75)
>         at 
> org.apache.phoenix.jdbc.PhoenixResultSet.getString(PhoenixResultSet.java:601)
>         at sqlline.Rows$Row.<init>(Rows.java:183)
>         at sqlline.BufferedRows.<init>(BufferedRows.java:38)
>         at sqlline.SqlLine.print(SqlLine.java:1650)
>         at sqlline.Commands.execute(Commands.java:833)
>         at sqlline.Commands.sql(Commands.java:732)
>         at sqlline.SqlLine.dispatch(SqlLine.java:808)
>         at sqlline.SqlLine.begin(SqlLine.java:681)
>         at sqlline.SqlLine.start(SqlLine.java:398)
>         at sqlline.SqlLine.main(SqlLine.java:292)
> {noformat}
> Stepping through with the debugger, it appears the {{VARCHAR ARRAY}} value is 
> not parsed correctly. The special case of two nulls is not accounted for in 
> {{RowKeyValueAccessor#getLength()}}. This results in the offsets being 
> slightly wrong and then the value cannot be materialized correctly. Depending 
> on what's in the adjacent bytes either an invalid {{position}} call is made, 
> resulting in the {{IllegalArgumentException}}, or 
> {{PArrayDataType.createPhoenixArray}} attempts to allocate an array of 
> ridiculous size, resulting in the OOM.
> It appears the types of the columns returned in the {{KeyValue}} in the 
> {{Tuple currentRow}} are ordered {{VARCHAR}}, {{VARCHAR ARRAY}}, {{INTEGER}}. 
> I can share the KeyValue bytes with you offline if that will help in 
> debugging.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to