[
https://issues.apache.org/jira/browse/PHOENIX-2584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15111332#comment-15111332
]
James Taylor commented on PHOENIX-2584:
---------------------------------------
Patch looks fine, but would be nice if we didn't have to switch on every type
here:
{code}
+ private static Tuple newTuple(final ColumnInfo cinfo,Object object)
throws ExecException {
+ PDataType dataType = cinfo.getPDataType();
+ Tuple tuple = null;
+ if(PDataType.equalsAny(dataType, PDoubleArray.INSTANCE,
PUnsignedDoubleArray.INSTANCE)) {
+ double[] doubleArr = (double[])object;
+ int noOfElements = doubleArr.length;
+ tuple = TUPLE_FACTORY.newTuple(noOfElements);
+ for(int i = 0 ; i < noOfElements ; i++) {
+ tuple.set(i,(doubleArr[i]));
+ }
+ } else if (PDataType.equalsAny(dataType, PIntegerArray.INSTANCE,
PUnsignedIntArray.INSTANCE)) {
+ int[] intArr = (int[])object;
+ int noOfElements = intArr.length;
+ tuple = TUPLE_FACTORY.newTuple(noOfElements);
+ for(int i = 0 ; i < noOfElements ; i++) {
+ tuple.set(i,(intArr[i]));
+ }
+ } else if(PDataType.equalsAny(dataType, PTinyintArray.INSTANCE,
PUnsignedTinyintArray.INSTANCE)) {
{code}
Where are you getting object from? What's the declaration of Tuple.set(i,
value)? In Phoenix (and JDBC), an array value is represented by the Array
interface and backed in Phoenix by PhoenixArray. Through PhoenixArray, you can
iterate through the elements like this:
{code}
PhoenixArray array = (PhoenixArray)object;
for(int i = 0 ; i < array.getDimensions() ; i++) {
tuple.set(i,array.getElement(i));
}
{code}
Would something like that be able to replace the switch statement?
> Support Array datatype in phoenix-pig module
> --------------------------------------------
>
> Key: PHOENIX-2584
> URL: https://issues.apache.org/jira/browse/PHOENIX-2584
> Project: Phoenix
> Issue Type: Bug
> Reporter: maghamravikiran
> Assignee: maghamravikiran
> Fix For: 4.7.0
>
> Attachments: PHOENIX-2484-2.patch, PHOENIX-2584-1.patch,
> PHOENIX-2584.patch
>
>
> The plan is to map an array data type column to a Tuple in Pig.
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)