Body (String)라는 데이터 프레임 열이 있습니다. 본문 열 데이터는 다음과 같습니다.Spark UDF 내에서 XML 문자열 처리 및 구조 필드 반환
<p>I want to use a track-bar to change a form's opacity.</p>
<p>This is my code:</p>
<pre><code>decimal trans = trackBar1.Value/5000;
this.Opacity = trans;
</code></pre>
<p>When I build the application, it gives the following error:</p>
<blockquote>
<p>Cannot implicitly convert type 'decimal' to 'double'.</p>
</blockquote>
<p>I tried using <code>trans</code> and <code>double</code> but then the
control doesn't work. This code worked fine in a past VB.NET project. </p>
,While applying opacity to a form should we use a decimal or double value?
본문 본문 두 개의 별도 코드 열과 텍스트를 준비하고 싶습니다. 코드는 code라는 요소 사이에 있고 text는 그 밖의 모든 것입니다.
나는이 작동하지 않습니다이
case class bodyresults(text:String,code:String)
val Body:String=>bodyresults=(body:String)=>{ val xmlbody=scala.xml.XML.loadString(body)
val code = (xmlbody \\ "code").toString;
val text = "I want every thing else as text. what should I do"
(text,code)
}
val bodyudf=udf(Body)
val posts5=posts4.withColumn("codetext",bodyudf(col("Body")))
처럼 보이는 UDF를 만들었습니다. 내 질문은 입니다. 1. 알 수 있듯이 데이터에는 루트 노드가 없습니다. 스칼라 XML 구문 분석을 계속 사용할 수 있습니까? 2. 코드를 제외한 나머지 모든 것을 텍스트로 구문 분석하는 방법.
뭔가 잘못 내 코드에있을 경우 나
예상 출력 알려 주시기 바랍니다 : 대신 교체하고, 당신은 또한 RewriteRule
를 사용하고 비워 XML 클래스의 transform
메소드를 오버라이드 (override) 할 수
(code,text)
code = decimal trans = trackBar1.Value/5000;this.Opacity = trans;trans double
text = everything else
오류 (있는 경우)? 예상되는 결과는 무엇입니까? – philantrovert
스파크 셸에서 오류 메시지가 표시되지 않습니다. UDF 본문에 잘못된 것이 있습니다. spark-shell은 함수를 생성하지 않습니다. – Makkena
좋습니다. 코드 태그는 여러 위치에 있습니다. 그들 모두를 원 하시겠습니까 아니면'pre '즉'decimal trans = ...'안에 넣으시겠습니까? – philantrovert