Github user ramkrish86 commented on a diff in the pull request:
https://github.com/apache/incubator-phoenix/pull/8#discussion_r9980816
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/schema/PArrayDataType.java ---
@@ -77,9 +130,47 @@ public int toBytes(Object object, byte[] bytes, int
offset) {
if (array == null || array.baseType == null) {
return 0;
}
- return PDataType.fromTypeId((array.baseType.getSqlType() +
Types.ARRAY)).estimateByteSize(object);
+ return estimateByteSize(object, null,
PDataType.fromTypeId((array.baseType.getSqlType() + Types.ARRAY)));
}
+ // Estimates the size of the given array and also calculates the number
of nulls and its repetition factor
+ public int estimateByteSize(Object o, Pair<Integer, Integer>
nullsVsNullRepeationCounter, PDataType baseType) {
--- End diff --
I did this and removed that code because I felt we will not get the exact
size and we may need to do a byte copy for getting the exact length of the
byte[]. If not the byte[] that is used in recreation of the array would not
work correctly because we have moved the headers to the last. If not
TrustedByteArrayOutputSTream would have been fine. So let me calculate the
exact size considering nulls > 255.
---
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.
---