Class UpsertTestFileUtil
- java.lang.Object
-
- org.apache.flink.connector.upserttest.sink.UpsertTestFileUtil
-
@Internal public class UpsertTestFileUtil extends Object
Collection uf utility methods for reading and writing files from theUpsertTestSink.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intgetNumberOfRecords(BufferedInputStream bis)Returns 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 Detail
-
writeRecords
public static void writeRecords(BufferedOutputStream bos, Map<org.apache.flink.connector.upserttest.sink.ImmutableByteArrayWrapper,org.apache.flink.connector.upserttest.sink.ImmutableByteArrayWrapper> records) throws IOException
Writes 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
public static int getNumberOfRecords(BufferedInputStream bis) throws IOException
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
public static int getNumberOfRecords(File file) throws IOException
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
-
-