Oh. Thanks a lot. do you have a snippet for generating composite key?
I’m sorry for my laziness. > On Aug 12, 2016, at 3:24 PM, vikashtalanki <vikashtala...@gmail.com> wrote: > > Hi Dong, > > If you still want to insert through hbase, you can use the below snippets > for encoding values as per phoenix. ---> import > org.apache.phoenix.schema.types.*; > > public static byte[] encodeDecimal(String value) > { > BigDecimal bigDecValue = new BigDecimal(value); > byte[] pDecimalByteArray = > PDecimal.INSTANCE.toBytes(bigDecValue); > return pDecimalByteArray; > } > > public static byte[] encodeDate(java.util.Date utilDate) > { > java.sql.Date sqlDate = new Date(utilDate.getTime()); > byte[] pDateByteArray = PDate.INSTANCE.toBytes(sqlDate); > return pDateByteArray; > } > > public static byte[] encodeTimestamp(String utilTS) > { > java.sql.Timestamp sqlDate = Timestamp.valueOf(utilTS); > byte[] pTSByteArray = PTimestamp.INSTANCE.toBytes(sqlDate); > return pTSByteArray; > } > > public static byte[] encodeLong(String value) > { > byte[] pLongByteArray = PLong.INSTANCE.toBytes(value); > return pLongByteArray; > } > > public static byte[] encodeChar(String value) > { > byte[] pCharByteArray = PChar.INSTANCE.toBytes(value); > return pCharByteArray; > } > > public static byte[] encodeVarchar(String value) > { > byte[] pVarcharByteArray = PVarchar.INSTANCE.toBytes(value); > return pVarcharByteArray; > } > > public static byte[] encodeShort(String value) > { > Short shortValue = Short.parseShort(value); > byte[] pShortByteArray = PSmallint.INSTANCE.toBytes(shortValue); > return pShortByteArray; > } > > public static byte[] encodeInteger(String value) > { > int intValue = Integer.parseInt(value); > byte[] pIntByteArray = PInteger.INSTANCE.toBytes(intValue); > return pIntByteArray; > } > > > > -- > View this message in context: > http://apache-phoenix-user-list.1124778.n5.nabble.com/ERROR-201-22000-illegal-data-error-expected-length-at-least-4-but-had-tp2170p2202.html > Sent from the Apache Phoenix User List mailing list archive at Nabble.com.