@Path("/hello")
public class Hello {
@POST
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public JSONObject sayPlainTextHello(@PathParam("id")JSONObject inputJsonObj) {
String input = (String) inputJsonObj.get("input");
String output="The input you sent is :"+input;
JSONObject outputJsonObj = new JSONObject();
outputJsonObj.put("output", output);
return outputJsonObj;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的webservice(我正在使用Jersey API).但我无法找到一种方法从java rest客户端调用此方法来发送和接收json数据.我尝试了以下方式来编写客户端
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
JSONObject inputJsonObj = new JSONObject();
inputJsonObj.put("input", "Value");
System.out.println(service.path("rest").path("hello").accept(MediaType.APPLICATION_JSON).entity(inputJsonObj).post(JSONObject.class,JSONObject.class));
Run Code Online (Sandbox Code Playgroud)
但这显示以下错误
Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class java.lang.Class, and MIME media …Run Code Online (Sandbox Code Playgroud) 我试图检索DataFrame列的值并将其存储在变量中.我试过这个:
val name=df.select("name")
val name1=name.collect()
Run Code Online (Sandbox Code Playgroud)
但以上都没有返回列"name"的值.
Spark版本:2.2.0 Scala版本:2.11.11
我正在尝试通过 imagemagick 包将动画保存为 gif。这就是我所做的
anim.save('animation.gif', writer='imagemagick', fps=10)
但我收到以下警告
MovieWriter imagemagick unavailable; trying to use <class 'matplotlib.animation.PillowWriter'> instead.
Run Code Online (Sandbox Code Playgroud)
由于 imagemagick 不是 python 包,我如何在 Google colab 中安装它?或者,是否有不同的包可以用来在 google colab 中将动画保存为 gif?
我有一个数据框,我必须在其中一列中生成一个唯一的 Id。此 id 必须使用偏移量生成。因为,我需要使用自动生成的 id 保留此数据帧,现在如果新数据进入自动生成的 id 不应与现有数据冲突。我检查了单调递增函数,但它不接受任何偏移量。这是我试过的:
df=df.coalesce(1);
df = df.withColumn(inputCol,functions.monotonically_increasing_id());
Run Code Online (Sandbox Code Playgroud)
但是有没有办法让 monotonically_increasing_id() 从起始偏移量开始?
我正在尝试从url https://someurl.com使用RESTful服务.我在代码中添加了以下属性:
Security.setProperty("ssl.SocketFactory.provider", "com.ibm.jsse2.SSLSocketFactoryImpl");
Security.setProperty("ssl.ServerSocketFactory.provider", "com.ibm.jsse2.SSLServerSocketFactoryImpl");
Security.setProperty("javax.net.ssl.trustStore", "cacerts.jks");
Security.setProperty("javax.net.ssl.keyStore", "keystore.jks");
Security.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
Security.setProperty("javax.net.ssl.trustStoreType", "JKS");
Run Code Online (Sandbox Code Playgroud)
到目前为止我所做的配置更改是:
com.ibm.websphere.ssl.retrieveLeafCert为true但我得到以下异常:
java.security.cert.CertPathValidatorException: Certificate chaining error
javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.h: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is:
java.security.cert.CertPathValidatorException: The certificate issued by CN=Walmart Root CA, O=Wal-Mart Stores Inc is not trusted; internal cause is:
java.security.cert.CertPathValidatorException: Certificate chaining error
at com.ibm.jsse2.o.a(o.java:22)
at com.ibm.jsse2.SSLSocketImpl.a(SSLSocketImpl.java:423)
at com.ibm.jsse2.kb.a(kb.java:192)
at com.ibm.jsse2.kb.a(kb.java:176)
at com.ibm.jsse2.lb.a(lb.java:53)
at com.ibm.jsse2.lb.a(lb.java:464)
at com.ibm.jsse2.kb.s(kb.java:545) …Run Code Online (Sandbox Code Playgroud) 我在列上使用分区来将数据存储在拼花中。但我看到没有。实木复合地板分区文件的编号与否不同。Rdd分区。rdd分区和镶木地板分区之间没有相关性吗?
当我将数据写入镶木地板分区并使用Rdd重新分区,然后从镶木地板分区读取数据时,读/写期间rdd分区号相同时是否有任何条件?
使用列ID存储数据框和通过相同的列ID重新分区数据框有何不同?
在考虑Spark中联接的性能时,我们应该考虑进行存储分区或重新分区(或两者都考虑)
在我的控制器中,我正在设置一个hashmap
@ModelAttribute("clientImpMap")
public Map<String,String> populateClientImpMap() throws MalformedURLException, IOException
{
Map<String,String> clientImpMap = new HashMap<String,String> ();
clientImpMap.put("1","High");
clientImpMap.put("2","Low");
return clientImpMap;
}
Run Code Online (Sandbox Code Playgroud)
现在我想用Thymeleaf标签填充这个hashmap.怎么做?使用核心Spring-mvc标签我可以做到这一点
<td>Client Importance :</td>
<td><form:select path="personBean.clientImpRef">
<form:option value="NONE" label="--- Select ---" />
<form:options items="${clientImpMap}" />
</form:select></td>
<td><form:errors path="personBean.clientImpRef" cssClass="error" /></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
百里香的相当于什么呢?
我正在尝试从 RDD 创建数据集。这是我的代码:
val word = lines.map(_.value())
word.print()
word.foreachRDD( rdd => {
for(item <- rdd.collect().toArray)
{
val s=item.split(",")
if(s.length ==37){
val collection = sc.parallelize(Seq((s(0),s(1),s(2),s(3),s(4),s(5),s(6),s(7),s(8),s(9),
s(10),s(11),s(12),s(29),s(30),s(31),s(32),s(33),s(34),s(35),s(36))));
val dataset = sc.parallelize(Seq((s(0),s(1),s(2),s(3),s(4),s(5),s(6),s(7),s(8),s(9),
s(10),s(11),s(12),s(13),s(14),s(15),s(16),s(17),s(18),s(19),s(20),s(21),s(22),s(23),s(24),
s(25),s(26),s(27),s(28)))
).toDS()
}
}
Run Code Online (Sandbox Code Playgroud)
当我编译上面的内容时,它抛出以下错误:too much elements for tuple 29, allowed 22 Scala version 2.11.11 Spark version 2.2.0
我安装了solr 4.9.1.这是我的schema.xml
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="ayan_schema" version="1.5">
<types>
<fieldType name="string" class="solr.StrField" />
<fieldType name="long" class="solr.TrieLongField"
precisionStep="0" positionIncrementGap="0" />
<fieldType name="text" class="solr.TextField">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory" />
</analyzer>
</fieldType>
<fieldtype name="syn" class="solr.TextField">
<analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="false" />
</analyzer>
</fieldtype>
</types>
<fields>
<field name="_version_" type="long" indexed="true" stored="true" />
<field name="id" type="string" indexed="true" stored="true" />
<field name="name" type="string" indexed="true" stored="true" />
<field name="email" type="string" indexed="true" stored="true" />
<field name="skype" type="string" indexed="true" stored="true" />
<field name="irc" type="string" indexed="true" …Run Code Online (Sandbox Code Playgroud) 我需要创建一个基于REST的Web服务,其中请求将异步处理.通过异步,我的意思是客户端将发出请求并继续执行而不等待服务的响应.是否可以实现此目的?我需要在WebSphere Application Server中部署该服务.
我正在尝试从 Spark Sql 将数据插入到 Hive 外部表中。我通过以下命令创建了 hive 外部表
CREATE EXTERNAL TABLE tab1 ( col1 type,col2 type ,col3 type) CLUSTERED BY (col1,col2) SORTED BY (col1) INTO 8 BUCKETS STORED AS PARQUET
Run Code Online (Sandbox Code Playgroud)
在我的 spark job 中,我编写了以下代码 Dataset df = session.read().option("header","true").csv(csvInput);
df.repartition(numBuckets, somecol)
.write()
.format("parquet")
.bucketBy(numBuckets,col1,col2)
.sortBy(col1)
.saveAsTable(hiveTableName);
Run Code Online (Sandbox Code Playgroud)
每次运行此代码时,都会出现以下异常
org.apache.spark.sql.AnalysisException: Table `tab1` already exists.;
at org.apache.spark.sql.DataFrameWriter.saveAsTable(DataFrameWriter.scala:408)
at org.apache.spark.sql.DataFrameWriter.saveAsTable(DataFrameWriter.scala:393)
at somepackage.Parquet_Read_WriteNew.writeToParquetHiveMetastore(Parquet_Read_WriteNew.java:100)
Run Code Online (Sandbox Code Playgroud) apache-spark ×5
scala ×2
asynchronous ×1
hive ×1
imagemagick ×1
java ×1
jersey ×1
json ×1
parquet ×1
rest ×1
solr ×1
spring-mvc ×1
thymeleaf ×1
web-services ×1
websphere-7 ×1