gpt4 book ai didi

mysql - 时间戳分区键上的 Spark JoinWithCassandraTable STUCK

转载 作者:可可西里 更新时间:2023-11-01 06:49:49 25 4
gpt4 key购买 nike

我正在尝试使用以下方法对巨大的 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';

问题是在 spark master ui 上没有错误地完成 println 后进程卡住。

[Stage 0:>                                                                                                                                (0 + 2) / 2]

Join 不会使用时间戳作为分区键吗?为什么会卡住?

最佳答案

通过使用:

sc.parallelize(startDate to endDate)

将 startData 和 endDate 作为从 Dates 生成的 Longs,格式如下:

("yyyy-MM-dd HH:mm:ss")

我用 spark 构建了一个巨大的数组(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")

现在可以了。

关于mysql - 时间戳分区键上的 Spark JoinWithCassandraTable STUCK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33329494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com