Update HbaseAbstractTask.java

修复hbase11xreader插件指定字段类型为boolean、short、int、long、float、double时转换失败问题,例如,当指定字段类型为int时,会报错:"exception":"offset (0)+Length (4)exceed the capacity of the array:1"
This commit is contained in:
airyv 2023-09-08 14:21:43 +08:00 committed by GitHub
parent 051fe821f2
commit 0cd1472bf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,22 +92,22 @@ public abstract class HbaseAbstractTask {
Column column;
switch (columnType) {
case BOOLEAN:
column = new BoolColumn(ArrayUtils.isEmpty(byteArray) ? null : Bytes.toBoolean(byteArray));
column = new BoolColumn(ArrayUtils.isEmpty(byteArray) ? null : Boolean.valueOf(Bytes.toString(byteArray)));
break;
case SHORT:
column = new LongColumn(ArrayUtils.isEmpty(byteArray) ? null : String.valueOf(Bytes.toShort(byteArray)));
column = new LongColumn(ArrayUtils.isEmpty(byteArray) ? null : Bytes.toString(byteArray));
break;
case INT:
column = new LongColumn(ArrayUtils.isEmpty(byteArray) ? null : Bytes.toInt(byteArray));
column = new LongColumn(ArrayUtils.isEmpty(byteArray) ? null : Integer.valueOf(Bytes.toString(byteArray)));
break;
case LONG:
column = new LongColumn(ArrayUtils.isEmpty(byteArray) ? null : Bytes.toLong(byteArray));
column = new LongColumn(ArrayUtils.isEmpty(byteArray) ? null : Long.valueOf(Bytes.toString(byteArray)));
break;
case FLOAT:
column = new DoubleColumn(ArrayUtils.isEmpty(byteArray) ? null : Bytes.toFloat(byteArray));
column = new DoubleColumn(ArrayUtils.isEmpty(byteArray) ? null : Float.valueOf(Bytes.toString(byteArray)));
break;
case DOUBLE:
column = new DoubleColumn(ArrayUtils.isEmpty(byteArray) ? null : Bytes.toDouble(byteArray));
column = new DoubleColumn(ArrayUtils.isEmpty(byteArray) ? null : Double.valueOf(Bytes.toString(byteArray)));
break;
case STRING:
column = new StringColumn(ArrayUtils.isEmpty(byteArray) ? null : new String(byteArray, encoding));