我正在使用jackson 2.2注释@JsonProperty,必需的设置为true.通过ObjectMapper readValue()方法反序列化不包含该属性的json文件时,不会抛出任何异常.是应该以不同的方式工作还是我错过了什么?
我的课程:
public class User {
public enum Gender {MALE, FEMALE}
;
public static class Name {
private String _first, _last;
public String getFirst() {
return _first;
}
public String getLast() {
return _last;
}
public void setFirst(String s) {
_first = s;
}
public void setLast(String s) {
_last = s;
}
}
private Gender _gender;
private Name _name;
private boolean _isVerified;
private byte[] _userImage;
@JsonProperty(value ="NAAME",required = true)
public Name getName() {
return _name;
}
@JsonProperty("VERIFIED") …Run Code Online (Sandbox Code Playgroud) 我想测试一个返回a的方法Future.我的尝试如下:
import org.specs2.mutable.Specification
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}
class AsyncWebClientSpec extends Specification{
"WebClient when downloading images" should {
"for a valid link return non-zero content " in {
val testImage = AsyncWebClient.get("https://www.google.cz/images/srpr/logo11ww.png")
testImage.onComplete { res =>
res match {
case Success(image) => image must not have length(0)
case _ =>
}
AsyncWebClient.shutDown
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
除了我无法使这个代码工作的事实,我想有一个更好的方法来测试一个Future定向匹配器的期货.
如何在specs2中正确完成?
我正在使用Puppet 2.7,我需要将数组转换为逗号分隔列表.
$hosts_fqdn= ['host1','host2','host3']
Run Code Online (Sandbox Code Playgroud)
我需要将其转换为所需的结果: 'host1,host2,host3'
我猜Puppet 3.2提供lambda表达式 - reduce.但不幸的是2.7不可能.
我试图在分布式模式下安装zookeeper和HBase,但是当我启动zookeeper仲裁的最后一个节点时,我得到的除外:
2013-09-05 12:02:09,230 - ERROR [main:QuorumPeer@171] - Setting LearnerType to PARTICIPANT but 4 not in QuorumPeers.
2013-09-05 12:02:09,246 - INFO [main:QuorumPeer@444] - acceptedEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation
2013-09-05 12:02:09,250 - ERROR [main:QuorumPeerMain@89] - Unexpected exception, exiting abnormally
java.lang.RuntimeException: My id 4 not in the peer list
at org.apache.zookeeper.server.quorum.QuorumPeer.startLeaderElection(QuorumPeer.java:479)
at org.apache.zookeeper.server.quorum.QuorumPeer.start(QuorumPeer.java:411)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:151)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:111)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Run Code Online (Sandbox Code Playgroud)
我将zookeeper仲裁设置为3 - 包含来自hadoop的master + 2data节点.zoo.cfg列出所有这些机器.并且它们将myid设置为1表示主机,3表示第一数据模式,4表示第二数据节点.主数据和第一个数据节点运行正常.
我正在使用scala 2.10,我想知道是否有一些包在处理文件时有异步IO?
我做了一些搜索这个主题,但大多数发现的例子如下
val file = new File(canonicalFilename)
val bw = new BufferedWriter(new FileWriter(file))
bw.write(text)
bw.close()
Run Code Online (Sandbox Code Playgroud)
什么本质上基本上java.io包与阻止IO操作 - 写,读等.我也发现scala-io项目有这个意图,但似乎该项目是死去的最后活动2012年.
这种情况下的最佳做法是什么?有没有任何scala包或常见的方法是将java.io代码包装到Futures和Observables?
我的用例是来自Akka actor需要操作本地或远程文件系统上的文件.需要避免阻塞.还是有更好的选择吗?
为了澄清这一点而深受欢迎
我正在使用playframework进行JSON解析,我正面临NullPointerException:
我的数据模型如下:
case class SearchLikeThisResult(total: Int, max_score: Double, hits: Seq[Hits])
case class Hits( index: String, typ: String, id: String, score: Double)
Run Code Online (Sandbox Code Playgroud)
我的读者如下:
object SearchLikeThisHits {
import play.api.libs.functional.syntax._
implicit val searchLikeThisResult: Reads[SearchLikeThisResult] = (
(JsPath \ "total").read[Int] and
(JsPath \ "max_score").read[Double] and
(JsPath \ "hits").read[Seq[Hits]]
)(SearchLikeThisResult.apply _)
implicit val hitsReads: Reads[Hits] = (
(JsPath \ "_index").read[String] and
(JsPath \ "_type").read[String] and
(JsPath \ "_id").read[String] and
(JsPath \ "_score").read[Double]
)(Hits.apply _)
}
Run Code Online (Sandbox Code Playgroud)
然后我有以下测试代码:
import play.api.libs.json.{JsValue, Json}
object Test extends App{
val str …Run Code Online (Sandbox Code Playgroud) 我试图从Windows机器上提交一个M/R作业到linux上的hadoop集群.我正在使用hadoop 2.2.0(HDP 2.0).
我收到以下错误:
2014-06-06 08:32:37,684 [main] INFO Job.monitorAndPrintJob - Job job_1399458460502_0053 running in uber mode : false
2014-06-06 08:32:37,704 [main] INFO Job.monitorAndPrintJob - map 0% reduce 0%
2014-06-06 08:32:37,717 [main] INFO Job.monitorAndPrintJob - Job job_1399458460502_0053 failed with state FAILED due to: Application application_1399458460502_0053 failed 2 times due to AM Container for appattempt_1399458460502_0053_000002 exited with exitCode: 1 due to: Exception from container-launch:
org.apache.hadoop.util.Shell$ExitCodeException: /bin/bash: line 0: fg: no job control
at org.apache.hadoop.util.Shell.runCommand(Shell.java:464)
at org.apache.hadoop.util.Shell.run(Shell.java:379)
at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:589)
at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:195)
at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:283) …Run Code Online (Sandbox Code Playgroud) 我对将 search_type 指定为 body 参数有点犹豫。作为一个很好的查询参数,但在手册中没有找到单个示例,其中将其指定为查询参数。
POST /index/type/_search
{
"search_type": {"query_then_fetch"},
"explain": false,
"query" : {
"query_string": {
"default_field": "adress.city",
"query": "London"
}
}
}
Run Code Online (Sandbox Code Playgroud)
任何提示?
谢谢
我只是碰到了"更像这样"的功能/ api.是否有可能将more_like_this的结果与一些额外的搜索约束相结合?
我有两个以下的ES查询工作:
POST /h/B/_search
{
"query": {
"more_like_this": {
"fields": [
"desc"
],
"ids": [
"511111260"
],
"min_term_freq": 1,
"max_query_terms": 25
}
}
}
Run Code Online (Sandbox Code Playgroud)
哪个回报
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"failed": 0
},
"hits": {
"total": 53,
"max_score": 3.2860293,
"hits": [
...
Run Code Online (Sandbox Code Playgroud)
哪个没问题,但是我需要在底层文档的其他字段中指定附加约束,它单独工作:
POST /h/B/_search
{
"query": {
"bool": {
"must": {
"match": {
"Kind": "Pen"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我希望将这两者结合起来,因为查询应该说明:"查找类似于用Pen标记的项目的项目".我尝试使用嵌套查询,但这给了我一些错误:
POST /h/B/_search
{
"query": {
"more_like_this": {
"fields": [
"desc"
], …Run Code Online (Sandbox Code Playgroud) 有人可以带来更多关于scala代码的内容,这对我来说并不完全清楚吗?我有以下功能定义
def ids(ids: String*) = {
_builder.ids(ids: _*)
this
}
Run Code Online (Sandbox Code Playgroud)
然后我试图将变量参数列表传递给此函数,如下所示:
def searchIds(kind: KindOfThing, adIds:String*) = {
...
ids(adIds)
}
Run Code Online (Sandbox Code Playgroud)
首先,ids(adIds)片段不起作用,最初有点奇怪,因为错误消息说:类型不匹配,预期:字符串,实际:Seq [String].这意味着变量参数列表不会被键入为集合或序列.
为了解决这个问题,使用技巧ids(adIds: _*).
我不是100%肯定如何:_*有效,有人可以放一些棚子吗?如果我没记错的话:意味着操作应用于右参数而不是左,_表示"应用"传递给元素,...我检查了字符串和序列scaladoc但是无法找到:_*方法.
有人可以解释一下吗?
谢谢