Github user JamesRTaylor commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/104#discussion_r36442491
--- Diff: phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
---
@@ -657,6 +660,22 @@ public static PName
padTenantIdIfNecessary(RowKeySchema schema, boolean isSalted
return tenantId;
}
+ public static byte[] getTenantIdBytes(RowKeySchema schema, boolean
isSalted, PName tenantId)
+ throws SQLException {
+ int pkPos = isSalted ? 1 : 0;
+ Field field = schema.getField(pkPos);
+ PDataType dataType = field.getDataType();
+ byte[] convertedValue;
+ try {
+ Object value = dataType.toObject(tenantId.getString());
+ convertedValue = dataType.toBytes(value);
--- End diff --
You can use the following code to pad the convertedValue (this will be a
noop for types that aren't padded):
ImmutableBytesWritable ptr = new ImmutableBytesWritable(convertedValue);
dataType.pad(ptr, field.getMaxLength(), field.getSortOrder());
convertedValue = ByteUtil.copyKeyBytesIfNecessary(ptr);
---
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.
---