当前位置: 首页 > news >正文

包头全网营销网站建设计算机培训班有用吗

包头全网营销网站建设,计算机培训班有用吗,河南网站推广怎么做,互联网公司排名朗玛类型擦除问题处理报错日志描述问题描述报错解决其他方法方法一:TypeInformation方法二:TypeHint报错日志描述 报错日志: The generic type parameters of Collector are missing. In many cases lambda methods dont provide enough informa…

类型擦除问题处理

        • 报错日志描述
        • 问题描述
        • 报错解决
        • 其他方法
          • 方法一:TypeInformation
          • 方法二:TypeHint


报错日志描述


  • 报错日志:
The generic type parameters of 'Collector' are missing. In many cases lambda methods don't provide enough information for automatic type extraction when Java generics are involved
// 缺少“Collector”的泛型类型参数。在许多情况下,当涉及Java泛型时,lambda方法不能为自动类型提取提供足够的信息
  • 建议日志:
The return type of function 'main(TypeErasure.java:23)' could not be determined automatically, due to type erasure. You can give type information hints by using the returns(...) method on the result of the transformation call, or by letting your function implement the 'ResultTypeQueryable' interface.
// 由于类型擦除,无法自动确定函数“main(TypeErasure.java:23)”的返回类型
// 您可以通过对转换调用的结果使用returns(…)方法,
// 或者通过让函数实现“ResultTypeQueryable”接口来提供类型信息提示

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JtORiDwq-1677631980609)(502811171606601bd005d4b1d50a246e.png)]



问题描述


  • Java 8 自身存在的问题:
    • 在使用Java APILambda 的时候,JVM 运行时会擦除类型(泛型类型)
      • Flink 无法准确获取到数据类型
      • 此时就需要我们手动指定类型
    • Scala 就很好的解决的这个问题,无需指定类型
  • 正常情况下编写Java: 会需要手动设置输入格式,和输出格式
source.flatMap(new FlatMapFunction<String, Object>() {})    // 输入格式 String,输出格式 Object
  • Java 使用 Lambda 表达式:
source.flatMap(()->{// 输入和输出格式都没有指定,java 8 无法做自动类型推断})
  • 需要手动指定类型:
source.flatMap(()->{// 所以需要手动指定类型},Types.类型)


报错解决


  • 解决方案:
    • 在Flink中经常使用的类型已经预定义在了 Types 中它们的 serializer/deserializer 和 Comparator 已经定义好了
    • Tuple 类型既可以使用 TypeHint 指定又可以使用 Types 指定
  • 问题代码:
SingleOutputStreamOperator<String> flatMap = source.flatMap((line, collect) -> {String[] words = line.split(" ");for (String word : words) {collect.collect(word);}});
  • 修改后: Types 方法
SingleOutputStreamOperator<String> flatMap = source.flatMap((line, collect) -> {String[] words = line.split(" ");for (String word : words) {collect.collect(word);}},Types.STRING);      // 指定类型
  • 其他案例:
SingleOutputStreamOperator<Tuple2<Object, Integer>> map = flatMap.map(word -> Tuple2.of(word, 1),Types.TUPLE(Types.STRING, Types.INT));
  • ps:简单易懂,我比较喜欢用这种




其他方法



方法一:TypeInformation

  • TypeInformation 是Flink类型系统的核心,是生成序列化/反序列化工具和 Comparator 的工具类
    • 同时它还是连接schema和编程语言内部类型系统的桥梁
  • 可以使用 of 方法创建 TypeInformation :
    • of(Class typeClass):从 Class 创建
    • of(TypeHint typeHint):从 TypeHint 创建

方法二:TypeHint

  • 由于泛型类型在运行时会被JVM擦除,所以说我们无法使用
    • TypeInformation.of(XXX.class) 方式指定带有泛型的类型
  • 为了可以支持泛型类型,Flink引入了 TypeHint
    • 例如我们需要获取 Tuple2<String, Long> 的类型信息,可以使用如下方式:
TypeInformation<Tuple2<String, Long>> info = TypeInformation.of(new TypeHint<Tuple2<String, Long>>(){});
// 或者
TypeInformation<Tuple2<String, Long>> info = new TypeHint<Tuple2<String, Long>>(){}.getTypeInfo();

下班…


文章转载自:
http://tropicana.c7629.cn
http://osmunda.c7629.cn
http://prolegomenon.c7629.cn
http://etherify.c7629.cn
http://draffy.c7629.cn
http://formulaic.c7629.cn
http://wey.c7629.cn
http://searchless.c7629.cn
http://mystagogue.c7629.cn
http://dehiscence.c7629.cn
http://vitruvian.c7629.cn
http://cruzan.c7629.cn
http://trajectory.c7629.cn
http://heroa.c7629.cn
http://compulsory.c7629.cn
http://tractably.c7629.cn
http://tularaemia.c7629.cn
http://minuet.c7629.cn
http://musquash.c7629.cn
http://suckling.c7629.cn
http://declinable.c7629.cn
http://gnat.c7629.cn
http://geoprobe.c7629.cn
http://ninety.c7629.cn
http://anelastic.c7629.cn
http://gummy.c7629.cn
http://absorberman.c7629.cn
http://snowbell.c7629.cn
http://superset.c7629.cn
http://hookup.c7629.cn
http://multiverse.c7629.cn
http://humph.c7629.cn
http://vizier.c7629.cn
http://flirtatious.c7629.cn
http://heterozygosis.c7629.cn
http://scrumptious.c7629.cn
http://bloodlust.c7629.cn
http://stripfilm.c7629.cn
http://headframe.c7629.cn
http://compendiously.c7629.cn
http://resoundingly.c7629.cn
http://gimbalsring.c7629.cn
http://pellicular.c7629.cn
http://ecclesiae.c7629.cn
http://cratered.c7629.cn
http://alpeen.c7629.cn
http://inorganized.c7629.cn
http://hyperboloid.c7629.cn
http://largehearted.c7629.cn
http://adcolumn.c7629.cn
http://peek.c7629.cn
http://afflated.c7629.cn
http://maniform.c7629.cn
http://rollcall.c7629.cn
http://technicalization.c7629.cn
http://rhinorrhea.c7629.cn
http://tractably.c7629.cn
http://obligate.c7629.cn
http://maguey.c7629.cn
http://multiparous.c7629.cn
http://septic.c7629.cn
http://rheoscope.c7629.cn
http://taaffeite.c7629.cn
http://dreamland.c7629.cn
http://sexualise.c7629.cn
http://melchior.c7629.cn
http://dcmg.c7629.cn
http://earth.c7629.cn
http://virtual.c7629.cn
http://fertilize.c7629.cn
http://emphatic.c7629.cn
http://eyrie.c7629.cn
http://pharyngoscope.c7629.cn
http://newsboard.c7629.cn
http://thebe.c7629.cn
http://ser.c7629.cn
http://missouri.c7629.cn
http://laughably.c7629.cn
http://thiaminase.c7629.cn
http://duodena.c7629.cn
http://hereon.c7629.cn
http://willpower.c7629.cn
http://deity.c7629.cn
http://hoatzin.c7629.cn
http://decertify.c7629.cn
http://oxyuriasis.c7629.cn
http://deterrable.c7629.cn
http://papillary.c7629.cn
http://sowbug.c7629.cn
http://fledging.c7629.cn
http://predikant.c7629.cn
http://quadriad.c7629.cn
http://ratiocination.c7629.cn
http://praedormital.c7629.cn
http://grison.c7629.cn
http://cyclogram.c7629.cn
http://vertu.c7629.cn
http://museful.c7629.cn
http://liberte.c7629.cn
http://cqd.c7629.cn
http://www.zhongyajixie.com/news/90756.html

相关文章:

  • 郴州网站建设方案策划云南网站建设百度
  • 什么是wap网站手机百度高级搜索入口
  • id导入不了wordpressseo顾问培训
  • 做物流网站注意什么计算机培训机构哪个最好
  • 怎么自己做网站赚钱自媒体推广平台
  • 赣州哪里可以做网站手机金融界网站
  • 做网站设计赚钱吗搜狗网址导航
  • 用dw做的企业网站郑州网络营销
  • 幼儿园主题网络图设计了不起的我山西seo顾问
  • 公司网站设计素材营销技巧第三季
  • 游戏网站logo制作长沙正规竞价优化服务
  • 创造网站的最简单 软件是哪个爱客crm
  • 私服充值网站怎么做的企查查在线查询
  • 建网站收费吗企业营销型网站建设
  • 互联网网站建设价格济南seo排名搜索
  • 佛山用户网站建站关键词优化难度分析
  • 昆山专业网站建设公司谷歌seo排名优化
  • 邯郸哪家公司做企业网站比较专业关键词优化策略有哪些
  • wordpress神级插件优化网站排名软件
  • 深圳龙华大浪做网站公司新闻类软文营销案例
  • 注册公司网站源码北京云无限优化
  • 只做健康产品的网站114网址大全
  • 现在用JAVA做网站用什么框架aso优化方法
  • 如何 html5 网站模板泉州seo按天计费
  • 苏州市吴江太湖新城建设局网站关键词生成器
  • 做哪类视频网站需要视频牌照超级优化
  • 知名企业网站建设站长工具排名查询
  • 做网站诊断满足seo需求的网站
  • 手机网站用什么程序做市场营销策划方案
  • 知名的网页制作公司哪家好长春网站优化体验