Skip to content

Commit

Permalink
add the convertion of bytes columns
Browse files Browse the repository at this point in the history
  • Loading branch information
hffariel committed Oct 9, 2021
1 parent cbc93b9 commit 4450cca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ private void validateStreamLoadUrl() {
private void validateRequired() {
final String[] requiredOptionKeys = new String[]{
KEY_USERNAME,
KEY_PASSWORD,
KEY_DATABASE,
KEY_TABLE,
KEY_COLUMN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
public class StarRocksBaseSerializer {

protected String fieldConvertion(Column col) {
if (null == col.getRawData()) {
if (null == col.getRawData() || Type.NULL == col.getType()) {
return null;
}
if (Type.BOOL == col.getType()) {
return String.valueOf(col.asLong());
}
if (Type.BYTES == col.getType()) {
byte[] bts = (byte[])col.getRawData();
long value = 0;
for (int i = 0; i < bts.length; i++) {
value += (bts[bts.length - i - 1] & 0xffL) << (8 * i);
}
return String.valueOf(value);
}
return col.asString();
}

}
}

0 comments on commit 4450cca

Please sign in to comment.