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

x33g5p2x  于2022-01-30 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(223)

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

Struct.getInt16介绍

[英]Equivalent to calling #get(String) and casting the result to a Short.
[中]相当于调用#get(String)并将结果转换为短字符串。

代码示例

代码示例来源:origin: debezium/debezium

private void assertTinyintUnsigned(Struct value) {
  Struct after = value.getStruct(Envelope.FieldName.AFTER);
  Integer i = after.getInt32("id");
  assertThat(i).isNotNull();
  //Validate the schema first, we are expecting int-16 since we are dealing with unsignd-tinyint
  //So Unsigned TINYINT would be an INT16 type
  assertThat(after.schema().field("c1").schema()).isEqualTo(Schema.INT16_SCHEMA);
  assertThat(after.schema().field("c2").schema()).isEqualTo(Schema.INT16_SCHEMA);
  //Validate the schema first, we are expecting int-16 since we are dealing with signed-tinyint.
  // Note: the recommended mapping of Signed TINYINT is Short which is 16-bit. http://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html
  //So Signed TINYINT would be an INT16 type
  assertThat(after.schema().field("c3").schema()).isEqualTo(Schema.INT16_SCHEMA);
  //Validate candidates values
  switch (i) {
  case 1:
    assertThat(after.getInt16("c1")).isEqualTo((short)255);
    assertThat(after.getInt16("c2")).isEqualTo((short)(255));
    assertThat(after.getInt16("c3")).isEqualTo((short)127);
    break;
  case 2:
    assertThat(after.getInt16("c1")).isEqualTo((short)155);
    assertThat(after.getInt16("c2")).isEqualTo((short)155);
    assertThat(after.getInt16("c3")).isEqualTo((short)-100);
    break;
  case 3:
    assertThat(after.getInt16("c1")).isEqualTo((short)0);
    assertThat(after.getInt16("c2")).isEqualTo((short)0);
    assertThat(after.getInt16("c3")).isEqualTo((short)-128);
  }
}

代码示例来源:origin: debezium/debezium

private void assertSmallUnsigned(Struct value) {
  Struct after = value.getStruct(Envelope.FieldName.AFTER);
  Integer i = after.getInt32("id");
  assertThat(i).isNotNull();
  //Validate the schema first, we are expecting int-32 since we are dealing with unsignd-smallint
  //So Unsigned SMALLINT would be an int32 type
  assertThat(after.schema().field("c1").schema()).isEqualTo(Schema.INT32_SCHEMA);
  assertThat(after.schema().field("c2").schema()).isEqualTo(Schema.INT32_SCHEMA);
  //Validate the schema first, we are expecting int-16 since we are dealing with signed-smallint.
  //So Signed SMALLINT would be an INT16 type
  assertThat(after.schema().field("c3").schema()).isEqualTo(Schema.INT16_SCHEMA);
  //Validate candidates values
  switch (i) {
  case 1:
    assertThat(after.getInt32("c1")).isEqualTo(65535);
    assertThat(after.getInt32("c2")).isEqualTo(65535);
    assertThat(after.getInt16("c3")).isEqualTo((short)32767);
    break;
  case 2:
    assertThat(after.getInt32("c1")).isEqualTo(45535);
    assertThat(after.getInt32("c2")).isEqualTo(45535);
    assertThat(after.getInt16("c3")).isEqualTo((short)-12767);
    break;
  case 3:
    assertThat(after.getInt32("c1")).isEqualTo(0);
    assertThat(after.getInt32("c2")).isEqualTo(0);
    assertThat(after.getInt16("c3")).isEqualTo((short)-32768);
  }
}

代码示例来源:origin: DataReply/kafka-connect-mongodb

jsonMap.put(fieldName, struct.getInt16(fieldName));
  break;
case INT64:

代码示例来源:origin: io.debezium/debezium-connector-mysql

private void assertTinyintUnsigned(Struct value) {
  Struct after = value.getStruct(Envelope.FieldName.AFTER);
  Integer i = after.getInt32("id");
  assertThat(i).isNotNull();
  //Validate the schema first, we are expecting int-16 since we are dealing with unsignd-tinyint
  //So Unsigned TINYINT would be an INT16 type
  assertThat(after.schema().field("c1").schema()).isEqualTo(Schema.INT16_SCHEMA);
  assertThat(after.schema().field("c2").schema()).isEqualTo(Schema.INT16_SCHEMA);
  //Validate the schema first, we are expecting int-16 since we are dealing with signed-tinyint.
  // Note: the recommended mapping of Signed TINYINT is Short which is 16-bit. http://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html
  //So Signed TINYINT would be an INT16 type
  assertThat(after.schema().field("c3").schema()).isEqualTo(Schema.INT16_SCHEMA);
  //Validate candidates values
  switch (i) {
  case 1:
    assertThat(after.getInt16("c1")).isEqualTo((short)255);
    assertThat(after.getInt16("c2")).isEqualTo((short)(255));
    assertThat(after.getInt16("c3")).isEqualTo((short)127);
    break;
  case 2:
    assertThat(after.getInt16("c1")).isEqualTo((short)155);
    assertThat(after.getInt16("c2")).isEqualTo((short)155);
    assertThat(after.getInt16("c3")).isEqualTo((short)-100);
    break;
  case 3:
    assertThat(after.getInt16("c1")).isEqualTo((short)0);
    assertThat(after.getInt16("c2")).isEqualTo((short)0);
    assertThat(after.getInt16("c3")).isEqualTo((short)-128);
  }
}

代码示例来源:origin: io.debezium/debezium-connector-mysql

private void assertSmallUnsigned(Struct value) {
  Struct after = value.getStruct(Envelope.FieldName.AFTER);
  Integer i = after.getInt32("id");
  assertThat(i).isNotNull();
  //Validate the schema first, we are expecting int-32 since we are dealing with unsignd-smallint
  //So Unsigned SMALLINT would be an int32 type
  assertThat(after.schema().field("c1").schema()).isEqualTo(Schema.INT32_SCHEMA);
  assertThat(after.schema().field("c2").schema()).isEqualTo(Schema.INT32_SCHEMA);
  //Validate the schema first, we are expecting int-16 since we are dealing with signed-smallint.
  //So Signed SMALLINT would be an INT16 type
  assertThat(after.schema().field("c3").schema()).isEqualTo(Schema.INT16_SCHEMA);
  //Validate candidates values
  switch (i) {
  case 1:
    assertThat(after.getInt32("c1")).isEqualTo(65535);
    assertThat(after.getInt32("c2")).isEqualTo(65535);
    assertThat(after.getInt16("c3")).isEqualTo((short)32767);
    break;
  case 2:
    assertThat(after.getInt32("c1")).isEqualTo(45535);
    assertThat(after.getInt32("c2")).isEqualTo(45535);
    assertThat(after.getInt16("c3")).isEqualTo((short)-12767);
    break;
  case 3:
    assertThat(after.getInt32("c1")).isEqualTo(0);
    assertThat(after.getInt32("c2")).isEqualTo(0);
    assertThat(after.getInt16("c3")).isEqualTo((short)-32768);
  }
}

相关文章