本文整理了Java中org.apache.kafka.connect.data.Decimal.toLogical()
方法的一些代码示例,展示了Decimal.toLogical()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Decimal.toLogical()
方法的具体详情如下:
包路径:org.apache.kafka.connect.data.Decimal
类名称:Decimal
方法名:toLogical
暂无
代码示例来源:origin: com.datamountaineer/kafka-connect-common
@Override
public Object convert(Schema schema, Object value) {
if (!(value instanceof byte[]))
throw new DataException("Invalid type for Decimal, underlying representation should be bytes but was " + value.getClass());
return Decimal.toLogical(schema, (byte[]) value);
}
});
代码示例来源:origin: com.github.jcustenborder.kafka.connect/connect-utils
static Object decimal(Schema schema, Object value) {
if (value instanceof byte[]) {
byte[] bytes = (byte[]) value;
return Decimal.toLogical(schema, bytes);
}
if (value instanceof BigDecimal) {
BigDecimal decimal = (BigDecimal) value;
final int scale = Integer.parseInt(schema.parameters().get(Decimal.SCALE_FIELD));
if (scale == decimal.scale()) {
return decimal;
} else {
return decimal.setScale(scale);
}
}
return value;
}
代码示例来源:origin: com.github.jcustenborder.kafka.connect/kafka-connect-cdc-test
static Object decimal(Schema schema, Object value) {
if (value instanceof byte[]) {
byte[] bytes = (byte[]) value;
return Decimal.toLogical(schema, bytes);
}
if (value instanceof BigDecimal) {
BigDecimal decimal = (BigDecimal) value;
final int scale = Integer.parseInt(schema.parameters().get(Decimal.SCALE_FIELD));
if (scale == decimal.scale()) {
return decimal;
} else {
return decimal.setScale(scale);
}
}
if (value instanceof Number) {
Number number = (Number) value;
int scale = Integer.parseInt(schema.parameters().get(Decimal.SCALE_FIELD));
BigDecimal decimal = BigDecimal.valueOf(number.longValue(), scale);
return decimal;
}
return value;
}
代码示例来源:origin: org.apache.kafka/connect-api
return Decimal.toLogical(toSchema, (byte[]) value);
内容来源于网络,如有侵权,请联系作者删除!