我有以下两种情况:
1. int值作为参数
int intNum = 2;
List<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
list.remove(intNum);
System.out.println(list.size());
// output: 2
Run Code Online (Sandbox Code Playgroud)
2.长值作为参数
long longNum = 2;
List<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
list.remove(longNum);
System.out.println(list.size());
// output: 3
Run Code Online (Sandbox Code Playgroud)
我在两种情况下都传递了2作为值,但是我得到了List的不同大小值.这种行为的实际原因是什么?
我是Apache Spark的新手.我实际上希望专注于基本的Spark API规范,并希望使用Spark API来理解和编写一些程序.我用Apache Spark编写了一个java程序来实现Joins概念.
当我使用Left Outer Join - leftOuterJoin()或Right Outer Join - rightOuterJoin()时,这两个方法都返回一个包含特殊类型Google Options的JavaPairRDD.但我不知道如何从Optional类型中提取原始值.
无论如何我想知道我可以使用相同的连接方法,以我自己的格式返回数据.我没有找到任何办法.意思是当我使用Apache Spark时,我无法以我自己的风格自定义代码,因为他们已经给出了所有预定义的东西.
请在下面找到代码
my 2 sample input datasets
customers_data.txt:
4000001,Kristina,Chung,55,Pilot
4000002,Paige,Chen,74,Teacher
4000003,Sherri,Melton,34,Firefighter
and
trasaction_data.txt
00000551,12-30-2011,4000001,092.88,Games,Dice & Dice Sets,Buffalo,New York,credit
00004811,11-10-2011,4000001,180.35,Outdoor Play Equipment,Water Tables,Brownsville,Texas,credit
00034388,09-11-2011,4000002,020.55,Team Sports,Beach Volleyball,Orange,California,cash
00008996,11-21-2011,4000003,121.04,Outdoor Recreation,Fishing,Colorado Springs,Colorado,credit
00009167,05-24-2011,4000003,194.94,Exercise & Fitness,Foam Rollers,El Paso,Texas,credit
Run Code Online (Sandbox Code Playgroud)
这是我的Java代码
**SparkJoins.java:**
public class SparkJoins {
@SuppressWarnings("serial")
public static void main(String[] args) throws FileNotFoundException {
JavaSparkContext sc = new JavaSparkContext(new SparkConf().setAppName("Spark Count").setMaster("local"));
JavaRDD<String> customerInputFile = sc.textFile("C:/path/customers_data.txt");
JavaPairRDD<String, String> customerPairs = customerInputFile.mapToPair(new …Run Code Online (Sandbox Code Playgroud) 当我执行时describe formatted table_name,我得到表的详细描述table_name.
我对该表的两个属性感兴趣,如下所示:
field.delimserialization.format
field.delim 是表的两个列字段之间的文件中的字段分隔符.
但是serialization.format表属性字段的含义是什么?
正如我们经常听到的apache zeppelin那样,我们脑海中浮现的问题很少:
在我的一个MapReduce任务中,我将BytesWritable重写为KeyBytesWritable,并将ByteWritable重写为ValueBytesWritable.然后我使用SequenceFileOutputFormat输出结果.
我的问题是,当我开始下一个MapReduce任务时,我想将此SequenceFile用作输入文件.那么我怎样才能设置jobclass,以及Mapper类如何识别我之前覆盖的SequenceFile中的键和值?
我明白我可以通过SequenceFile.Reader来读取键和值.
Configuration config = new Configuration();
Path path = new Path(PATH_TO_YOUR_FILE);
SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.get(config), path, config);
WritableComparable key = (WritableComparable) reader.getKeyClass().newInstance();
Writable value = (Writable) reader.getValueClass().newInstance();
while (reader.next(key, value))
Run Code Online (Sandbox Code Playgroud)
但我不知道如何使用此Reader将键和值作为参数传递给Mapper类.我怎样才能将conf.setInputFormat设置为SequenceFileInputFormat,然后让Mapper获取密钥和值?
谢谢
我使用下面的配置细节使用Flume将Twitter提要推送到HDFS,但是在Flume事件头中获得了预期的时间戳,但它是null
twitter.conf
TwitterAgent.sources = Twitter
TwitterAgent.channels = MemChannel
TwitterAgent.sinks = HDFS
TwitterAgent.sources.Twitter.type = org.apache.flume.source.twitter.TwitterSource
TwitterAgent.sources.Twitter.channels = MemChannel
TwitterAgent.sources.Twitter.consumerKey = xxxxxxxxxxxxxxxxxxxxx
TwitterAgent.sources.Twitter.consumerSecret = xxxxxxxxxxxxxxxxxxxxxxxx
TwitterAgent.sources.Twitter.accessToken = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TwitterAgent.sources.Twitter.accessTokenSecret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TwitterAgent.sources.Twitter.keywords = bigdata, hadoop, hive, hbase
TwitterAgent.sinks.HDFS.channel = MemChannel
TwitterAgent.sinks.HDFS.type = hdfs
TwitterAgent.sinks.HDFS.hdfs.path = /user/farooque/bigdata/tweets/%Y/%m/%d/%H/
TwitterAgent.sinks.HDFS.hdfs.fileType = DataStream
TwitterAgent.sinks.HDFS.hdfs.writeFormat = Text
TwitterAgent.sinks.HDFS.hdfs.batchSize = 10
TwitterAgent.sinks.HDFS.hdfs.rollSize = 0
TwitterAgent.sinks.HDFS.hdfs.rollCount = 10000
TwitterAgent.channels.MemChannel.type = memory
TwitterAgent.channels.MemChannel.capacity = 10000
TwitterAgent.channels.MemChannel.transactionCapacity = 100
Run Code Online (Sandbox Code Playgroud)
运行命令
$ flume-ng agent --conf-file twitter.conf --name TwitterAgent
Run Code Online (Sandbox Code Playgroud)
twitter.conf我的配置文件名在哪里
但是将错误视为:
java.lang.NullPointerException: …Run Code Online (Sandbox Code Playgroud) 我在下面有以下代码段及其输出:
串
System.out.println("A"); // output A
System.out.println("B"); // output B
System.out.println("A" + "B"); // output AB
Run Code Online (Sandbox Code Playgroud)
烧焦
System.out.println('A'); // output A
System.out.println('B'); // output B
System.out.println('A' + 'B'); // output 131
Run Code Online (Sandbox Code Playgroud)
将char的输出打印为单个char值的字符串的原因是什么?使用整数if +运算符?我在这篇文章中找不到这个答案.字符串联形成一个字符串给出了不同的结果
java ×3
apache-spark ×2
hadoop ×2
bigdata ×1
collections ×1
flume ×1
flume-ng ×1
hive ×1
join ×1
mapper ×1
optional ×1
sequencefile ×1