error: No implicit Ordering defined for Any
scala中经常遇到最头疼的问题,就是类型不匹配或者带Any,Option的提示错误信息。
最近碰到的是取最大值,但是明明已经Long类型的,却提示下面这个错误信息。

相关的源程序如下:
// 获取offset
1. val beginOffsets = KafkaTool.getBeginningOffset(broker,group,topic).map(o=>{
(KafkaTool.getPath(baseOffsetPath,group,topic,o._1.partition) -> o._2)
}).toMap
// 根据partitionPath获取Map的值,这里返回的是一个Option[Long]类型
2. val b_offset = beginOffsets.get(partitionPath).getOrElse(0L)
// 比较最大值
3. val max = Seq(b_offset,offset.toLong).max
这里如果将上面的第2行添加返回类型,则会提示以下错误:

解决方法:
添加转换_.toLong
val b_offset = beginOffsets.get(partitionPath).map(_.toLong).getOrElse(0L)
error: No implicit Ordering defined for Any的更多相关文章
- 解决:Error: JAVA_HOME is not defined correctly
问题重现: Error: JAVA_HOME is not defined correctly. We cannot execute :/usr/lib/jvm/java-7-oracle 问题分析: ...
- Error: "DEVELOPER_DIR" is not defined at ./symbolicatecrash line 53
项目问题解析“Error: "DEVELOPER_DIR" is not defined at ./symbolicatecrash line 53.”这个问题是最近调试app的时 ...
- 记个maven无法识别JAVA_HOME的问题 Error: JAVA_HOME is not defined correctly.
Error: JAVA_HOME is not defined correctly. We cannot execute /Library/Java/JavaVirtualMachines/jdk1. ...
- ionic3 ionic serve build fail Error: webpackJsonP is not defined
ionic升级后发现 ionic serve 跑起来项目出现一下错误: Runtime Error: webpackJsonP is not definedStack: @http://localho ...
- wepy开发小程序eslint报错error 'getApp' is not defined no-undef
wepy开发小程序使用getApp().globalData保存全局数据很方便,但是会在控制台看到很多报错:“error 'getApp' is not defined no-undef”,这是esl ...
- Julia安装以及使用扩展包package(ERROR: UndefVarError: Pkg not defined)
刚刚安装好Julia1.0,想进行第一步尝试: Pkg.add("PyPlot") 却出现错误:ERROR: UndefVarError: Pkg not defined 问题描述 ...
- 微信小程序 thirdScriptError sdk uncaught third Error regeneratorRuntime is not defined ReferenceError: regeneratorRuntime is not defined
thirdScriptError sdk uncaught third Error regeneratorRuntime is not defined ReferenceError: regenera ...
- Vue中:error 'XXXXX' is not defined no-undef解决办法
Vue中:error 'XXXXX' is not defined no-undef解决办法 报错内容: × Client Compiled with some errors in 7.42s √ S ...
- VC中编译出现error LNK2005:xx already defined in xxx.obj问题解决。
网上百度说是在.h头文件中定义了全局变量,然后其他文件包括了该头文件的原因. 解决方法如下: 点击项目配置->linker->General->Force file Output设置 ...
随机推荐
- python3 http.client 网络请求
python3 http.client 网络请求 一:get 请求 ''' Created on 2014年4月21日 @author: dev.keke@gmail.com ''' import h ...
- 【转】使用python编写网络通信程序
文章主体现部分来自:http://openexperience.iteye.com/blog/145701 1. 背景知识 如果使用TCP协议来传递数据,客户端和服务器端需要分别经过以下步骤: ser ...
- Static Proxy (静态代理模式)
1.定义一个接口 ProxyInterface.java package com.staticproxy ; public interface ProxyInterface //就假设为 定义一个购 ...
- Java lock 能被中断, synchronized 不能被中断
1.lock是可中断锁,而synchronized 不是可中断锁 线程A和B都要获取对象O的锁定,假设A获取了对象O锁,B将等待A释放对O的锁定, 如果使用 synchronized ,如果A不释放, ...
- 〖Linux〗ltib的使用帮助
scue@Link:/home/work/ltib$ ./ltib --help This script is used to manage the building of BSPs with com ...
- springmvc sitemesh json问题
参考: 解决方法: <sitemesh> <mapping path="/*" decorator="/WEB-INF/views/template/t ...
- 【apache2】apache2查看错误日志、请求日志
1.一般存储路径在 [ /var/log/apache2/ ]下面, 2.错误日志和请求日志 必须要进行定期清理. 清理完成后,必须重启apache [ cd / ; service apac ...
- LibRec:一个实现推荐系统的Java库包
LibRec是一个用于实现推系统 RS 的Java库包,实现推荐系统的两个经典问题: rating prediction(评分排行预测) 和 item ranking (项目排行),其内置了经典的机器 ...
- HttpSolrServer 实例管理参考,来自org.eclipse.smila.solr
http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/core/org.eclipse.smila.solr/code/为什么要对实例管理 ...
- SQL server 存储过程 C#调用Windows CMD命令并返回输出结果 Mysql删除重复数据保留最小的id C# 取字符串中间文本 取字符串左边 取字符串右边 C# JSON格式数据高级用法
create proc insertLog@Title nvarchar(50),@Contents nvarchar(max),@UserId int,@CreateTime datetimeasi ...