Github user 7shurik commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/68#discussion_r28529111
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java ---
@@ -561,6 +666,23 @@ public int estimateByteSize(int pos) {
}
@Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(TO_STRING_BEGIN);
+ boolean isFirst = true;
+ final Format defaultFormat = null;
+ for (Byte o : byteArr) {
+ if (isFirst) {
+ isFirst = false;
+ } else {
+ sb.append(TO_STRING_SEPARATOR);
+ }
+ sb.append(this.baseType.toStringLiteral(o,
defaultFormat));
--- End diff --
Good suggestion on toStringLiteral().
On the second comment.. I started to use PhoenixArray.toString() but that
doesn't work. Arrays in primitive array subclasses contain primitives and
there's an exception if
for(Object o : arr) { ... } is used. If arr consists of primitives (e.g.
ints), then for(Integer o : ints) works because type boxing/unboxing
automatically does the right cast.
I guess another way would be to have a method that converts from primitive
to object. Eg. int to Integer which would make toString generic.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. 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.
---