Class UpsertTestFileUtil


  • @Internal
    public class UpsertTestFileUtil
    extends Object
    Collection uf utility methods for reading and writing files from the UpsertTestSink.
    • 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 the UpsertTestSinkWriter to the given File.
      static int getNumberOfRecords​(File file)
      Returns the total number of records written using the UpsertTestSinkWriter 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 the UpsertTestSinkWriter from the given InputStream and converts them using the provided DeserializationSchemas.
      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 the UpsertTestSinkWriter from the given File and converts them using the provided DeserializationSchemas.
      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 the UpsertTestSinkWriter 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 the UpsertTestSinkWriter to the given BufferedOutputStream.
        Parameters:
        bos - the BufferedOutputStream to write to
        records - 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 the UpsertTestSinkWriter 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 the UpsertTestSinkWriter 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 the UpsertTestSinkWriter from the given InputStream and converts them using the provided DeserializationSchemas.
        Parameters:
        bis - The BufferedInputStream to read from
        keyDeserializationSchema - The key's DeserializationSchema
        valueDeserializationSchema - 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 the UpsertTestSinkWriter from the given File and converts them using the provided DeserializationSchemas.
        Parameters:
        file - The File to read from
        keyDeserializationSchema - The key's DeserializationSchema
        valueDeserializationSchema - The value's DeserializationSchema
        Returns:
        Map containing the deserialized key-value pairs
        Throws:
        IOException