org.apache.kafka.connect.data.Decimal.toLogical()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.apache.kafka.connect.data.Decimal.toLogical()方法的一些代码示例,展示了Decimal.toLogical()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Decimal.toLogical()方法的具体详情如下:
包路径:org.apache.kafka.connect.data.Decimal
类名称:Decimal
方法名:toLogical

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);

相关文章