Github user ankitsinghal commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/329#discussion_r211060359
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java ---
@@ -303,6 +303,54 @@ public static long getSequenceNumber(List<Mutation>
tableMetaData) {
return getSequenceNumber(getPutOnlyTableHeaderRow(tableMetaData));
}
+ /**
+ * Returns the sequence number of the parent table if we have a
mutation that is updating the
+ * parent table's encoded column qualifier
+ */
+ public static long
getParentSequenceNumberForAddColumnMutations(List<Mutation> tableMetaData) {
+ byte[] parentTableRowKey = null;
+ for (Mutation tableMutation : tableMetaData) {
+ List<Cell> kvs =
+ tableMutation.getFamilyCellMap()
+
.get(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES);
+ if (kvs != null) {
+ for (Cell kv : kvs) {
+ if (Bytes.compareTo(kv.getQualifierArray(),
kv.getQualifierOffset(),
+ kv.getQualifierLength(),
PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES, 0,
+
PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES.length) == 0) {
+ parentTableRowKey = kv.getRow();
+ }
+ }
+ }
+ }
+ if (parentTableRowKey == null) {
+ throw new IllegalStateException(
+ "Could not find mutation to update the encoded column
qualifier of the parent table ");
+ }
+
+ byte[] rowKeyPrefix = ByteUtil.concat(parentTableRowKey,
ByteUtil.EMPTY_BYTE_ARRAY);
--- End diff --
wouldn't be rowKeyPrefix and parentTableRowkey equal here and so why two
separate loops? is it a typo error for SEPARATOR_BYTE?
---