def from_source(self,
                    source: Source,
                    watermark_strategy: WatermarkStrategy,
                    source_name: str,
                    type_info: TypeInformation = None) -> 'DataStream':
        """
        Adds a data :class:`~pyflink.datastream.connectors.Source` to the environment to get a
        :class:`~pyflink.datastream.DataStream`.

        The result will be either a bounded data stream (that can be processed in a batch way) or
        an unbounded data stream (that must be processed in a streaming way), based on the
        boundedness property of the source.

        This method takes an explicit type information for the produced data stream, so that
        callers can define directly what type/serializer will be used for the produced stream. For
        sources that describe their produced type, the parameter type_info should not be specified
        to avoid specifying the produced type redundantly.

        .. versionadded:: 1.13.0
        """
        if type_info:
            j_type_info = type_info.get_java_type_info()
        else:
            j_type_info = None
        j_data_stream = self._j_stream_execution_environment.fromSource(
            source.get_java_function(),
            watermark_strategy._j_watermark_strategy,
            source_name,
            j_type_info)
        return DataStream(j_data_stream=j_data_stream)
Beispiel #2
0
 def add_source(self, source: Source) -> 'HybridSourceBuilder':
     self._j_hybrid_source_builder.addSource(source.get_java_function())
     return self
Beispiel #3
0
 def builder(first_source: Source) -> 'HybridSourceBuilder':
     JHybridSource = get_gateway(
     ).jvm.org.apache.flink.connector.base.source.hybrid.HybridSource
     return HybridSourceBuilder(
         JHybridSource.builder(first_source.get_java_function()))