Skip to content

Commit

Permalink
[core] Add type and classname in TypeHandle condition when throw Ille…
Browse files Browse the repository at this point in the history
…galArgumentException (#3698)
  • Loading branch information
xuzifu666 authored Jul 8, 2024
1 parent 2bffa69 commit 6f32c58
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ public static NullSetter createNullSetter(DataType elementType) {
case DOUBLE:
return BinaryArrayWriter::setNullDouble;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
elementType.getTypeRoot().toString(),
BinaryArrayWriter.class.getName());
throw new IllegalArgumentException(msg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ static ValueSetter createValueSetter(DataType elementType, Serializer<?> seriali
writer.writeRow(
pos, (InternalRow) value, (InternalRowSerializer) rowSerializer);
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
elementType.getTypeRoot().toString(), BinaryArray.class.getName());
throw new IllegalArgumentException(msg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ static ElementGetter createElementGetter(DataType elementType) {
elementGetter = (array, pos) -> array.getRow(pos, rowFieldCount);
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
elementType.getTypeRoot().toString(),
InternalArray.class.getName());
throw new IllegalArgumentException(msg);
}
if (!elementType.isNullable()) {
return elementGetter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ static FieldGetter createFieldGetter(DataType fieldType, int fieldPos) {
fieldGetter = row -> row.getRow(fieldPos, rowFieldCount);
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), InternalRow.class.getName());
throw new IllegalArgumentException(msg);
}
if (!fieldType.isNullable()) {
return fieldGetter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ private static FieldWriter createFieldWriter(DataType fieldType) {
(writer, pos, value) -> writer.writeRow((InternalRow) value, rowSerializer);
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(),
RowCompactedSerializer.class.getName());
throw new IllegalArgumentException(msg);
}

if (!fieldType.isNullable()) {
Expand Down Expand Up @@ -302,7 +307,12 @@ private static FieldReader createFieldReader(DataType fieldType) {
fieldReader = (reader, pos) -> reader.readRow(serializer);
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(),
RowCompactedSerializer.class.getName());
throw new IllegalArgumentException(msg);
}
if (!fieldType.isNullable()) {
return fieldReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public Object agg(Object accumulator, Object inputField) {
boolAnd = (boolean) accumulator && (boolean) inputField;
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return boolAnd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public Object agg(Object accumulator, Object inputField) {
boolOr = (boolean) accumulator || (boolean) inputField;
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return boolOr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public Object agg(Object accumulator, Object inputField) {
count = (long) accumulator + 1L;
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return count;
Expand All @@ -82,7 +86,11 @@ public Object retract(Object accumulator, Object inputField) {
count = (long) accumulator - 1L;
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ public Object agg(Object accumulator, Object inputField) {
mergeFieldSD, BinaryString.fromString(DELIMITER), inFieldSD);
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return concatenate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ public Object agg(Object accumulator, Object inputField) {
product = (double) accumulator * (double) inputField;
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return product;
Expand Down Expand Up @@ -124,7 +128,11 @@ public Object retract(Object accumulator, Object inputField) {
product = (double) accumulator / (double) inputField;
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return product;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public Object agg(Object accumulator, Object inputField) {
sum = (double) accumulator + (double) inputField;
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return sum;
Expand Down Expand Up @@ -125,7 +129,11 @@ public Object retract(Object accumulator, Object inputField) {
sum = (double) accumulator - (double) inputField;
break;
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
return sum;
Expand Down Expand Up @@ -153,7 +161,11 @@ private Object negative(Object value) {
case DOUBLE:
return -((double) value);
default:
throw new IllegalArgumentException();
String msg =
String.format(
"type %s not support in %s",
fieldType.getTypeRoot().toString(), this.getClass().getName());
throw new IllegalArgumentException(msg);
}
}
}

0 comments on commit 6f32c58

Please sign in to comment.