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

Nick Dimiduk commented on PHOENIX-1514:
---------------------------------------

Here's an implementation of PArrayDataType#isSizeCompatible that allows ArrayIT 
to pass. It uses reflection to handle the primitive array case so I don't know 
how much slower it is. {{Array}} here is {{java.lang.reflect.Array}}. Running 
the rest of the verify suite with this plus the above resolutions to the equals 
discussion.

{noformat}
  @Override
        public boolean isSizeCompatible(ImmutableBytesWritable ptr, Object 
value,
      PDataType srcType, Integer maxLength, Integer scale,
      Integer desiredMaxLength, Integer desiredScale) {
    if (value == null) return true;
                PhoenixArray pArr = (PhoenixArray) value;
    PDataType baseType = PDataType.fromTypeId(srcType.getSqlType() - 
PDataType.ARRAY_TYPE_BASE);
    if (pArr.isPrimitiveType()) {
      int len = Array.getLength(pArr.array);
      for (int i = 0; i < len; i++) {
        if (!baseType.isSizeCompatible(ptr, Array.get(pArr.array, i), baseType,
            srcType.getMaxLength(Array.get(pArr.array, i)), scale, 
desiredMaxLength,
            desiredScale)) {
          return false;
        }
      }
    } else {
      Object[] arr = (Object[]) pArr.array;
      for (int i = 0 ; i < arr.length; i++) {
        if (!baseType.isSizeCompatible(ptr, arr[i], baseType, 
srcType.getMaxLength(arr[i]),
            scale, desiredMaxLength, desiredScale)) {
          return false;
        }
      }
                }
                return true;
        }
{noformat}

> Break up PDataType Enum
> -----------------------
>
>                 Key: PHOENIX-1514
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1514
>             Project: Phoenix
>          Issue Type: Sub-task
>    Affects Versions: 5.0.0
>            Reporter: Nick Dimiduk
>            Assignee: Nick Dimiduk
>             Fix For: 5.0.0
>
>         Attachments: PHOENIX-1514.00.patch, PHOENIX-1514.01.patch, 
> PHOENIX-1514.02.patch, hung-phoenix-verify.txt, stack.txt
>
>
> A first step in adopting (a portion of) HBase's type encodings is to break up 
> the PDataType enum into an interface. This will pave the way for more 
> flexibility going forward.



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

Reply via email to