Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/incubator-phoenix/pull/8#discussion_r9974790
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/schema/PArrayDataType.java ---
    @@ -146,11 +237,16 @@ public static void 
positionAtArrayElement(ImmutableBytesWritable ptr, int arrayI
                }
     
                if (baseDataType.getByteSize() == null) {
    -                   int offset = ptr.getOffset() + noOFElementsSize + 
Bytes.SIZEOF_BYTE;
    -                   int indexOffset = Bytes.toInt(bytes, offset) + 
ptr.getOffset();
    -                   int valArrayPostion = offset + Bytes.SIZEOF_INT;
    -                   offset += Bytes.SIZEOF_INT;
    +               int offset = ptr.getOffset();
    --- End diff --
    
    For retrieving an element from the array, you should be able to use the 
current offset and the next offset (from your offset array), subtracting one 
(due to the separator byte) from the difference to get the length. One 
exception is for null - if the first character at the offset is a null byte, 
then you know it's null (and don't even have to look at the next offset). The 
other exception is when you're getting the position of the last element in the 
array. In this case, you know the fixed length of the header, so you can 
calculate the length in this case as well. Any attempts to retrieve an element 
past the number of elements you've serialized returns null (that's why trailing 
nulls do not need to be kept).
    
    Is there a case I'm missing? You should have an offset for every array 
element, including null elements that are in the middle, so I think this will 
work.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. To do so, please top-post your response.
If your project does not have this feature enabled and wishes so, or if the
feature is enabled but not working, please contact infrastructure at
[email protected] or file a JIRA ticket with INFRA.
---

Reply via email to