Class UpsertTestFileUtil
java.lang.Object
org.apache.flink.connector.upserttest.sink.UpsertTestFileUtil
Collection uf utility methods for reading and writing files from the
UpsertTestSink.-
Method Summary
Modifier and TypeMethodDescriptionstatic intReturns the total number of records written using theUpsertTestSinkWriterto the given File.static intgetNumberOfRecords(File file) Returns the total number of records written using theUpsertTestSinkWriterto the given File.static <K,V> Map<K, V> readRecords(BufferedInputStream bis, org.apache.flink.api.common.serialization.DeserializationSchema<K> keyDeserializationSchema, org.apache.flink.api.common.serialization.DeserializationSchema<V> valueDeserializationSchema) Reads records that were written using theUpsertTestSinkWriterfrom the given InputStream and converts them using the providedDeserializationSchemas.static <K,V> Map<K, V> readRecords(File file, org.apache.flink.api.common.serialization.DeserializationSchema<K> keyDeserializationSchema, org.apache.flink.api.common.serialization.DeserializationSchema<V> valueDeserializationSchema) Reads records that were written using theUpsertTestSinkWriterfrom the given File and converts them using the providedDeserializationSchemas.static voidwriteRecords(BufferedOutputStream bos, Map<org.apache.flink.connector.upserttest.sink.ImmutableByteArrayWrapper, org.apache.flink.connector.upserttest.sink.ImmutableByteArrayWrapper> records) Writes a Map of records serialized by theUpsertTestSinkWriterto the given BufferedOutputStream.
-
Method Details
-
writeRecords
public static void writeRecords(BufferedOutputStream bos, Map<org.apache.flink.connector.upserttest.sink.ImmutableByteArrayWrapper, org.apache.flink.connector.upserttest.sink.ImmutableByteArrayWrapper> records) throws IOExceptionWrites a Map of records serialized by theUpsertTestSinkWriterto the given BufferedOutputStream.- Parameters:
bos- the BufferedOutputStream to write torecords- the Map of records created by the UpsertTestSinkWriter- Throws:
IOException
-
getNumberOfRecords
Returns the total number of records written using theUpsertTestSinkWriterto the given File.- Parameters:
bis- The BufferedInputStream to read from- Returns:
- the number of records
- Throws:
IOException
-
getNumberOfRecords
Returns the total number of records written using theUpsertTestSinkWriterto the given File.- Parameters:
file- The File to read from- Returns:
- the number of records
- Throws:
IOException
-
readRecords
public static <K,V> Map<K,V> readRecords(BufferedInputStream bis, org.apache.flink.api.common.serialization.DeserializationSchema<K> keyDeserializationSchema, org.apache.flink.api.common.serialization.DeserializationSchema<V> valueDeserializationSchema) throws IOException Reads records that were written using theUpsertTestSinkWriterfrom the given InputStream and converts them using the providedDeserializationSchemas.- Parameters:
bis- The BufferedInputStream to read fromkeyDeserializationSchema- The key's DeserializationSchemavalueDeserializationSchema- The value's DeserializationSchema- Returns:
- Map containing the deserialized key-value pairs
- Throws:
IOException
-
readRecords
public static <K,V> Map<K,V> readRecords(File file, org.apache.flink.api.common.serialization.DeserializationSchema<K> keyDeserializationSchema, org.apache.flink.api.common.serialization.DeserializationSchema<V> valueDeserializationSchema) throws IOException Reads records that were written using theUpsertTestSinkWriterfrom the given File and converts them using the providedDeserializationSchemas.- Parameters:
file- The File to read fromkeyDeserializationSchema- The key's DeserializationSchemavalueDeserializationSchema- The value's DeserializationSchema- Returns:
- Map containing the deserialized key-value pairs
- Throws:
IOException
-