当我将Hadoop集群连接到Amazon存储并将文件下载到HDFS时,我发现s3://无法正常工作.在互联网上寻求帮助时,我发现我可以使用S3n.当我用S3n它工作.我不明白使用S3和S3n我的Hadoop集群之间的区别,有人可以解释一下吗?
我创建客户端和服务器,然后在添加客户端类的序列化的目的,然后简单地刚走到客户在我的硬盘驱动器的文件夹,并将其粘贴到服务器correponding位置,都classname.class和classname.java分别.
它在我自己的笔记本电脑上运行良好但是当我想继续我在其他系统上工作时,当我打开项目文件夹并在客户端尝试连接到服务器后,出现以下错误:
Exception in thread "main" java.io.InvalidClassException: projectname.clasname; local class incompatible: stream classdesc serialVersionUID = -6009442170907349114, local class serialVersionUID = 6529685098267757690
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
Run Code Online (Sandbox Code Playgroud)
到底是怎么回事?是因为我使用较旧版本的IDE运行程序?
import java.io.Serializable;
import java.net.URL;
public class KeyAdr implements Serializable {
private static final long serialVersionUID = 6529685098267757690L;
public URL adr;
public String key;
}
Run Code Online (Sandbox Code Playgroud) 我有一个df具有此架构的DataFrame :
root
|-- person.name: string (nullable = true)
|-- person: struct (nullable = true)
| |-- age: long (nullable = true)
| |-- name: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
当我这样做时,df.select("person.name")我显然name从中获取子字段person.我该如何选择列person.name?
我有一个简单的文件过滤器,基本上选择特定日期的文件.在Hadoop中,我会将PathFilter类设置为InputFormat参数setInputPathFilter.我怎样才能在Spark中执行此操作?
public class FilesFilter extends Configured implements PathFilter {
@Override
public boolean accept(Path path) {
try {
if (fs.isDirectory(path))
return true;
} catch (IOException e1) {
e1.printStackTrace();
return false;
}
String file_date = "01.30.2015";
SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy");
Date date = null;
try {
date = sdf.parse(file_date);
} catch (ParseException e1) {
e1.printStackTrace();
}
long dt = date.getTime()/(1000 * 3600 * 24);
try {
FileStatus file = fs.getFileStatus(path);
long time = file.getModificationTime() / …Run Code Online (Sandbox Code Playgroud) 我正在查看DataFrame API,我可以看到两种不同的方法具有相同的功能,用于从数据集中删除重复项。
我可以理解dropDuplicates(colNames)将仅考虑列的子集来删除重复项。
这两种方法之间还有其他区别吗?
我目前正在处理一个混合 Java 和 Scala (Spark) 的项目。好像这还不够,我的一些依赖项导入了另一个版本的 Spark 和 Scala(不兼容)......
总而言之,这就是我的依赖树可能的样子:
myProjectA
\_ myLibB
| \_ spark 1.5.2 (excluded in my pom.xml)
| \_ scala 2.10.4 (excluded in my pom.xml)
\_ spark 2.2.0 (with Scala 2.11)
| \_ scala 2.11.7
\_ scala 2.11.11
\_ java 8
Run Code Online (Sandbox Code Playgroud)
在我的项目中的地图上进行了一个小的修改后,编译不再起作用......仅供参考,修改包括在硬编码地图中添加一个元素。
因此,我正在寻找一种解决方案来编译我的项目。我目前正在使用此构建配置:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal> …Run Code Online (Sandbox Code Playgroud) 我有一个 Spark/Scala 工作,我这样做:
df1+cache到内存中df1用于计算dfAdf2(再次,它的大)+cache它执行 (3) 时,我不再需要df1. 我想确保它的空间得到释放。一世cached在 (1) 处,因为这个 DataFrame 在 (2) 中使用,这是确保我不会每次都重新计算它而只重新计算一次的唯一方法。
我需要释放它的空间并确保它被释放。我有哪些选择?
我想到了这些,但似乎还不够:
df=nulldf.unpersist()你能用适当的 Spark 文档链接记录你的答案吗?
如果存在,Card我希望能够获得下一个和前一个Cards.
使用next()和prev()函数的想法是它们分别返回下一个或前一个Suits.西装的顺序是:Hearts,Spades,Diamonds,Clubs.
为了更多说明,我应该这样做
// case class Card(n : Int, s : Suit)
// 1. define abstract case class Suit
// 2. define abstract case classes RedSuit and BlackSuit
// 3. define concrete case classes Hearts, Spades, Diamonds, Clubs
// 5. define abstract methods next():Suit and prev():Suit on Suit class
// 6. implement the next():Suite and prev():Suit on each of the Hearts, Diamonds,Spades …Run Code Online (Sandbox Code Playgroud) 我在我的 Maven 项目中发现了一个相关的错误Scala-maven-plugin。我有一个很长的特征序列(用于机器学习目的),我手动编码(74 个元素)。
我在序列中添加了一个元素,但它不再编译。如果我注释该序列的任何元素,元素数量就会减少并且可以编译。
有关更多信息,这是我编译的最终输出:
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.3.1:compile (default) on project SecretProject: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 240 (Exit value: 240) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] …Run Code Online (Sandbox Code Playgroud) 我有一个df具有以下架构的数据框:
root
|-- city_name: string (nullable = true)
|-- person: struct (nullable = true)
| |-- age: long (nullable = true)
| |-- name: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
我想做的是添加一个嵌套列,比如car_brand我的person结构。我该怎么做呢?
预期的最终架构如下所示:
root
|-- city_name: string (nullable = true)
|-- person: struct (nullable = true)
| |-- age: long (nullable = true)
| |-- name: string (nullable = true)
| |-- car_brand: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)