Github user JamesRTaylor commented on a diff in the pull request:
https://github.com/apache/incubator-phoenix/pull/8#discussion_r9974767
--- 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 can see how getting the size of this buffer exactly correct will not be
easy. It's ok if you just use a TrustedByteArrayOutputStream with an estimated
size, as this is running client-side so it's not that big a deal (unlike the
Filter code).
---
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.
---