/** * Obtain a JSON string representation of the specified field. * * @param field the field; may not be null * @return the JSON string representation */ public static String asString(Field field) { return new RecordWriter().append(field).toString(); }
/** * Obtain a JSON string representation of the specified field. * * @param field the field; may not be null * @return the JSON string representation */ public static String asDetailedString(Field field) { return new RecordWriter().detailed(true).append(field).toString(); }
/** * Define the {@link Schema} used in the {@link FieldName#BEFORE} and {@link FieldName#AFTER} fields. * * @param schema the schema of the records, used in the {@link FieldName#BEFORE} and {@link FieldName#AFTER} fields; may * not be null * @return this builder so methods can be chained; never null */ default Builder withRecord(Schema schema) { return withSchema(schema, FieldName.BEFORE, FieldName.AFTER); }
/** * Verify that the given {@link SourceRecord} is a {@link Operation#CREATE INSERT/CREATE} record, and that the integer key * matches the expected value. * * @param record the source record; may not be null * @param pkField the single field defining the primary key of the struct; may not be null * @param pk the expected integer value of the primary key in the struct */ public static void isValidInsert(SourceRecord record, String pkField, int pk) { hasValidKey(record, pkField, pk); isValidInsert(record, true); }
/** * Verify that the given {@link SourceRecord} is a {@link Operation#UPDATE UPDATE} record, and that the integer key * matches the expected value. * * @param record the source record; may not be null * @param pkField the single field defining the primary key of the struct; may not be null * @param pk the expected integer value of the primary key in the struct */ public static void isValidUpdate(SourceRecord record, String pkField, int pk) { hasValidKey(record, pkField, pk); isValidUpdate(record, true); }
/** * Verify that the given {@link SourceRecord} is a valid tombstone, meaning it has a valid non-null key with key schema * but null value and value schema. * * @param record the source record; may not be null * @param pkField the single field defining the primary key of the struct; may not be null * @param pk the expected integer value of the primary key in the struct */ public static void isValidTombstone(SourceRecord record, String pkField, int pk) { hasValidKey(record, pkField, pk); isValidTombstone(record); }
/** * Verify that the given {@link SourceRecord} is a {@link Operation#DELETE DELETE} record, and that the integer key * matches the expected value. * * @param record the source record; may not be null * @param pkField the single field defining the primary key of the struct; may not be null * @param pk the expected integer value of the primary key in the struct */ public static void isValidDelete(SourceRecord record, String pkField, int pk) { hasValidKey(record, pkField, pk); isValidDelete(record, true); }
/** * Verify that the given {@link SourceRecord} is a {@link Operation#UPDATE UPDATE} record without PK. * * @param record the source record; may not be null * @param pkField the single field defining the primary key of the struct; may not be null * @param pk the expected integer value of the primary key in the struct */ public static void isValidUpdate(SourceRecord record) { isValidUpdate(record, false); }
/** * Assert that the supplied {@link Struct} is {@link Struct#validate() valid} and its {@link Struct#schema() schema} * matches that of the supplied {@code schema}. * * @param value the value with a schema; may not be null */ protected void assertSchemaMatchesStruct(SchemaAndValue value) { VerifyRecord.schemaMatchesStruct(value); }
/** * Verify that the given {@link SourceRecord} has the appropriate source query value. * * @param record the source record; may not be null * @param query the expected sql query value. */ public static void hasValidSourceQuery(final SourceRecord record, final String query) { assertValueField(record, "source/query", query); }
/** * Create a KeyValueStore that removes from the topic names the supplied prefix to obtain the {@link TableId}. * * @param prefix the prefix after which all of the topic name forms the table ID; may not be null * @return the key value store */ public static KeyValueStore createForTopicsBeginningWith(String prefix) { return new KeyValueStore(prefixedWith(prefix)); }
/** * Get the number of {@link Operation#UPDATE UPDATE} records {@link #add(SourceRecord) added} to this collection. * * @return the count; never negative */ public long numberOfUpdates() { return stats.numberOfUpdates(); }
/** * Get the number of {@link Operation#READ READ} records {@link #add(SourceRecord) added} to this collection. * * @return the count; never negative */ public long numberOfReads() { return stats.numberOfReads(); }
/** * Get the number of {@link Operation#CREATE CREATE} records {@link #add(SourceRecord) added} to this collection. * * @return the count; never negative */ public long numberOfCreates() { return stats.numberOfCreates(); }
/** * Get the number of {@link Operation#READ READ} records that were {@link #accept(SourceRecord) added} to this object. * * @return the count; never negative */ public long numberOfReads() { return numberOf(Operation.READ); }
/** * Obtain a JSON string representation of the specified {@link SourceRecord}. * * @param record the {@link SourceRecord}; may not be null * @return the JSON string representation */ public static String asDetailedString(SourceRecord record) { return new RecordWriter().detailed(true).append(record).toString(); }
/** * Obtain a JSON string representation of the specified {@link Schema}. * * @param schema the {@link Schema}; may not be null * @return the JSON string representation */ public static String asString(Schema schema) { return new RecordWriter().append(schema).toString(); }
/** * Assert that the supplied {@link Struct} is {@link Struct#validate() valid} and its {@link Struct#schema() schema} * matches that of the supplied {@code schema}. * * @param struct the {@link Struct} to validate; may not be null * @param schema the expected schema of the {@link Struct}; may not be null */ protected void assertSchemaMatchesStruct(Struct struct, Schema schema) { VerifyRecord.schemaMatchesStruct(struct, schema); }
/** * Define the {@link Schema} used in the {@link FieldName#SOURCE} field. * * @param sourceSchema the schema of the {@link FieldName#SOURCE} field; may not be null * @return this builder so methods can be chained; never null */ default Builder withSource(Schema sourceSchema) { return withSchema(sourceSchema, FieldName.SOURCE); }
/** * Obtain a JSON string representation of the specified {@link SourceRecord}. * * @param record the {@link SourceRecord}; may not be null * @return the JSON string representation */ public static String asString(SourceRecord record) { return new RecordWriter().append(record).toString(); }