我试图通过使用:
过滤大型C *表的一小部分 val snapshotsFiltered = sc.parallelize(startDate to endDate).map(TableKey(_)).joinWithCassandraTable("listener","snapshots_tspark")
println("Done Join")
//*******
//get only the snapshots and create rdd temp table
val jsons = snapshotsFiltered.map(_._2.getString("snapshot"))
val jsonSchemaRDD = sqlContext.jsonRDD(jsons)
jsonSchemaRDD.registerTempTable("snapshots_json")
使用:
case class TableKey(created: Long) //(created, imei, when)--> created = partititon key | imei, when = clustering key
cassandra表架构是:
CREATE TABLE listener.snapshots_tspark (
created timestamp,
imei text,
when timestamp,
snapshot text,
PRIMARY KEY (created, imei, when) ) WITH CLUSTERING ORDER BY (imei ASC, when ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
问题是,在println完成后,进程冻结,并且在spark master ui上没有错误。
[Stage 0:> (0 + 2) / 2]
使用时间戳作为分区键赢取加入工作吗?为什么会冻结?
答案 0 :(得分:2)
使用:
sc.parallelize(startDate to endDate)
将startData和endDate设置为Dates,格式为:
("yyyy-MM-dd HH:mm:ss")
我制作了一个巨大的数组(100,000多个对象)以加入C *表并且它并没有完全陷入困境--C *努力使连接发生并返回数据。
最后,我将范围更改为:
case class TableKey(created_dh: String)
val data = Array("2015-10-29 12:00:00", "2015-10-29 13:00:00", "2015-10-29 14:00:00", "2015-10-29 15:00:00")
val snapshotsFiltered = sc.parallelize(data, 2).map(TableKey(_)).joinWithCassandraTable("listener","snapshots_tnew")
现在好了。