org.apache.avro.message.SchemaStore Java Examples

The following examples show how to use org.apache.avro.message.SchemaStore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestSingleMessageEncoding.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompatibleReadWithSchemaFromLookup() throws Exception {
  MessageEncoder<Record> v1Encoder = new IcebergEncoder<>(SCHEMA_V1);

  SchemaStore.Cache schemaCache = new SchemaStore.Cache();
  schemaCache.addSchema(AvroSchemaUtil.convert(SCHEMA_V1, "table"));
  IcebergDecoder<Record> v2Decoder = new IcebergDecoder<>(SCHEMA_V2, schemaCache);

  ByteBuffer v1Buffer = v1Encoder.encode(V1_RECORDS.get(2));

  Record record = v2Decoder.decode(v1Buffer);

  Assert.assertEquals(v2Record(4L, "m-4", null), record);
}
 
Example #2
Source File: TestSingleMessageEncoding.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompatibleReadWithSchemaFromLookup() throws Exception {
  MessageEncoder<Record> v1Encoder = new IcebergEncoder<>(SCHEMA_V1);

  SchemaStore.Cache schemaCache = new SchemaStore.Cache();
  schemaCache.addSchema(AvroSchemaUtil.convert(SCHEMA_V1, "table"));
  IcebergDecoder<Record> v2Decoder = new IcebergDecoder<>(SCHEMA_V2, schemaCache);

  ByteBuffer v1Buffer = v1Encoder.encode(V1_RECORDS.get(2));

  Record record = v2Decoder.decode(v1Buffer);

  Assert.assertEquals(v2Record(4L, "m-4", null), record);
}
 
Example #3
Source File: Address.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<Address> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<Address>(MODEL$, SCHEMA$, resolver);
}
 
Example #4
Source File: User.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<User> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<User>(MODEL$, SCHEMA$, resolver);
}
 
Example #5
Source File: TweetMsg.java    From mongo-kafka with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link
 * SchemaStore}.
 *
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<TweetMsg> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<TweetMsg>(MODEL$, SCHEMA$, resolver);
}
 
Example #6
Source File: IcebergDecoder.java    From iceberg with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new decoder that constructs datum instances described by an
 * {@link org.apache.iceberg.Schema Iceberg schema}.
 * <p>
 * The {@code readSchema} is as used the expected schema (read schema). Datum instances created
 * by this class will are described by the expected schema.
 * <p>
 * The schema used to decode incoming buffers is determined by the schema fingerprint encoded in
 * the message header. This class can decode messages that were encoded using the
 * {@code readSchema} and other schemas that are added using
 * {@link #addSchema(org.apache.iceberg.Schema)}.
 * <p>
 * Schemas may also be returned from an Avro {@link SchemaStore}. Avro Schemas from the store
 * must be compatible with Iceberg and should contain id properties and use only Iceberg types.
 *
 * @param readSchema the {@link Schema} used to construct datum instances
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public IcebergDecoder(org.apache.iceberg.Schema readSchema, SchemaStore resolver) {
  this.readSchema = readSchema;
  this.resolver = resolver;
  addSchema(this.readSchema);
}
 
Example #7
Source File: HasUnions18.java    From avro-util with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<HasUnions> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<HasUnions>(MODEL$, SCHEMA$, resolver);
}
 
Example #8
Source File: BookingOrder.java    From Mastering-Microservices-with-Java-9-Second-Edition with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<BookingOrder> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<BookingOrder>(MODEL$, SCHEMA$, resolver);
}
 
Example #9
Source File: BookingOrder.java    From Mastering-Microservices-with-Java-9-Second-Edition with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<BookingOrder> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<BookingOrder>(MODEL$, SCHEMA$, resolver);
}
 
Example #10
Source File: IcebergDecoder.java    From iceberg with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new decoder that constructs datum instances described by an
 * {@link com.netflix.iceberg.Schema Iceberg schema}.
 * <p>
 * The {@code readSchema} is as used the expected schema (read schema). Datum instances created
 * by this class will are described by the expected schema.
 * <p>
 * The schema used to decode incoming buffers is determined by the schema fingerprint encoded in
 * the message header. This class can decode messages that were encoded using the
 * {@code readSchema} and other schemas that are added using
 * {@link #addSchema(com.netflix.iceberg.Schema)}.
 * <p>
 * Schemas may also be returned from an Avro {@link SchemaStore}. Avro Schemas from the store
 * must be compatible with Iceberg and should contain id properties and use only Iceberg types.
 *
 * @param readSchema the {@link Schema} used to construct datum instances
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public IcebergDecoder(com.netflix.iceberg.Schema readSchema, SchemaStore resolver) {
  this.readSchema = readSchema;
  this.resolver = resolver;
  addSchema(this.readSchema);
}
 
Example #11
Source File: TweetMsg.java    From kafka-connect-mongodb with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<TweetMsg> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<TweetMsg>(MODEL$, SCHEMA$, resolver);
}
 
Example #12
Source File: User.java    From yuzhouwan with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 *
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<User> createDecoder(SchemaStore resolver) {
    return new BinaryMessageDecoder<User>(MODEL$, SCHEMA$, resolver);
}
 
Example #13
Source File: Address.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<Address> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<Address>(MODEL$, SCHEMA$, resolver);
}
 
Example #14
Source File: AvroHttpRequest.java    From tutorials with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<AvroHttpRequest> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<AvroHttpRequest>(MODEL$, SCHEMA$, resolver);
}
 
Example #15
Source File: ClientIdentifier.java    From tutorials with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<ClientIdentifier> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<ClientIdentifier>(MODEL$, SCHEMA$, resolver);
}
 
Example #16
Source File: AvroHttpRequest.java    From tutorials with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<AvroHttpRequest> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<AvroHttpRequest>(MODEL$, SCHEMA$, resolver);
}
 
Example #17
Source File: ClientIdentifier.java    From tutorials with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<ClientIdentifier> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<ClientIdentifier>(MODEL$, SCHEMA$, resolver);
}
 
Example #18
Source File: BillingBookingResponse.java    From Mastering-Microservices-with-Java-Third-Edition with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<BillingBookingResponse> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<BillingBookingResponse>(MODEL$, SCHEMA$, resolver);
}
 
Example #19
Source File: Address.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<Address> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<Address>(MODEL$, SCHEMA$, resolver);
}
 
Example #20
Source File: InnerPayLoadAvro.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<InnerPayLoadAvro> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<InnerPayLoadAvro>(MODEL$, SCHEMA$, resolver);
}
 
Example #21
Source File: ComplexPayloadAvro.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<ComplexPayloadAvro> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<ComplexPayloadAvro>(MODEL$, SCHEMA$, resolver);
}
 
Example #22
Source File: Address.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<Address> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<Address>(MODEL$, SCHEMA$, resolver);
}
 
Example #23
Source File: SimpleRecord.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<SimpleRecord> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<SimpleRecord>(MODEL$, SCHEMA$, resolver);
}
 
Example #24
Source File: User.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<User> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<User>(MODEL$, SCHEMA$, resolver);
}
 
Example #25
Source File: SimpleUser.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<SimpleUser> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<SimpleUser>(MODEL$, SCHEMA$, resolver);
}
 
Example #26
Source File: Address.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<Address> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<Address>(MODEL$, SCHEMA$, resolver);
}
 
Example #27
Source File: SchemaRecord.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<SchemaRecord> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<SchemaRecord>(MODEL$, SCHEMA$, resolver);
}
 
Example #28
Source File: DifferentSchemaRecord.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<DifferentSchemaRecord> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<DifferentSchemaRecord>(MODEL$, SCHEMA$, resolver);
}
 
Example #29
Source File: BookingOrder.java    From Mastering-Microservices-with-Java-Third-Edition with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<BookingOrder> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<BookingOrder>(MODEL$, SCHEMA$, resolver);
}
 
Example #30
Source File: BookingOrder.java    From Mastering-Microservices-with-Java-Third-Edition with MIT License 2 votes vote down vote up
/**
 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
 */
public static BinaryMessageDecoder<BookingOrder> createDecoder(SchemaStore resolver) {
  return new BinaryMessageDecoder<BookingOrder>(MODEL$, SCHEMA$, resolver);
}