Github user JamesRTaylor commented on a diff in the pull request:
https://github.com/apache/incubator-phoenix/pull/8#discussion_r10000934
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/schema/PArrayDataType.java ---
@@ -17,21 +17,31 @@
*/
package org.apache.phoenix.schema;
+import java.io.DataOutputStream;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.sql.Types;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Bytes;
-
+import org.apache.hadoop.hbase.util.Pair;
+import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.util.ByteUtil;
+import org.apache.phoenix.util.TrustedByteArrayOutputStream;
/**
- * The datatype for PColummns that are Arrays
+ * The datatype for PColummns that are Arrays.
+ * Any variable length array would follow the below order.
+ * Every element would be seperated by a seperator byte '0'.
+ * Null elements are counted and once a first non null element appears we
write the
+ * count of the nulls prefixed with a seperator byte Trailing nulls are
not taken into account.
+ * The last non null element is followed by two seperator bytes.
+ * For eg a, b, null, null, c, null -> 65 0 66 0 0 2 67 0 0 0
+ * a null null null b c null d -> 65 0 0 3 66 0 67 0 0 1 68 0 0 0
--- End diff --
Add: The reason we use this serialization format is to allow the byte array
of arrays of the same type to be directly comparable against each other. This
prevents a costly deserialization on compare and allows an array column to be
used as the last column in a primary key constraint.
---
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.
---