0
点赞
收藏
分享

微信扫一扫

机器人中的数值优化(四)—— 线搜索求步长(附程序实现)

搬砖的小木匠 2023-06-01 阅读 79

[root@master pyflink]# cat t201.py 
import argparse
import logging
import sys
from pyflink.common import WatermarkStrategy, Encoder, Types
from pyflink.datastream import StreamExecutionEnvironment, RuntimeExecutionMode
from pyflink.datastream.connectors.file_system import FileSource, StreamFormat, FileSink, OutputFileConfig, RollingPolicy
import time
word_count_data = ["  Hello all People this is Flink"]
env = StreamExecutionEnvironment.get_execution_environment()
env.set_runtime_mode(RuntimeExecutionMode.BATCH)
   # write all the data to one file
env.set_parallelism(1)
ds = env.from_collection(word_count_data)
print(ds)
print(dir(ds))
def split(line):
      yield from line.split()
# flatMap将列表中每个元素提取出来
ds = ds.flat_map(split).map(lambda i: (i, 1), output_type=Types.TUPLE([Types.STRING(), Types.INT()])) \
#print(ds.print())
print('1111111111111')
print(ds.print())
print('222222222222')
env.execute()
[root@master pyflink]# python t201.py 
<pyflink.datastream.data_stream.DataStream object at 0x7feb24133130>
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_align_output_type', '_apply_chaining_optimization', '_j_data_stream', 'add_sink', 'assign_timestamps_and_watermarks', 'broadcast', 'cache', 'connect', 'disable_chaining', 'execute_and_collect', 'filter', 'flat_map', 'force_non_parallel', 'forward', 'get_execution_config', 'get_execution_environment', 'get_name', 'get_side_output', 'get_type', 'key_by', 'map', 'name', 'partition_custom', 'print', 'process', 'project', 'rebalance', 'rescale', 'set_buffer_timeout', 'set_description', 'set_max_parallelism', 'set_parallelism', 'set_uid_hash', 'shuffle', 'sink_to', 'slot_sharing_group', 'start_new_chain', 'uid', 'union', 'window_all']
1111111111111
<pyflink.datastream.data_stream.DataStreamSink object at 0x7feb24133550>
222222222222
(Hello,1)
(all,1)
(People,1)
(this,1)
(is,1)
(Flink,1)

举报

相关推荐

0 条评论