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 int
getNumberOfRecords(BufferedInputStream bis)
Returns the total number of records written using theUpsertTestSinkWriter
to the given File.static int
getNumberOfRecords(File file)
Returns the total number of records written using theUpsertTestSinkWriter
to 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 theUpsertTestSinkWriter
from the given InputStream and converts them using the providedDeserializationSchema
s.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 theUpsertTestSinkWriter
from the given File and converts them using the providedDeserializationSchema
s.static void
writeRecords(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 theUpsertTestSinkWriter
to 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 theUpsertTestSinkWriter
to 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 theUpsertTestSinkWriter
to 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 theUpsertTestSinkWriter
to 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 theUpsertTestSinkWriter
from the given InputStream and converts them using the providedDeserializationSchema
s.- 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 theUpsertTestSinkWriter
from the given File and converts them using the providedDeserializationSchema
s.- 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
-
-