我在读取包含>800 k行的表时遇到了问题。我需要从上到下读取行,以便处理它们。
我使用Scala和Phantom来实现这个目的。
这是我桌子的样子。
CREATE TABLE raw (
id uuid PRIMARY KEY,
b1 text,
b2 timestamp,
b3 text,
b4 text,
b5 text
) WITH bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
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';到目前为止,我尝试使用以下方法读取该表:
def getAllRecords : Future[Seq[row]] = select.fetch或者更花哨的枚举器,并将其与Iteratee结合起来。
def getAllRecords : Enumerator = select.fetchEnumrator这一切都没有用,似乎卡桑德拉/司机/我的程序总是试着预先读取所有的记录,我在这里遗漏了什么?
发布于 2016-03-09 23:35:10
你试过在更大的阅读测试中检查代码吗?
class IterateeBigReadPerformanceTest extends BigTest with ScalaFutures {
it should "read the correct number of records found in the table" in {
val counter: AtomicLong = new AtomicLong(0)
val result = TestDatabase.primitivesJoda.select
.fetchEnumerator run Iteratee.forEach {
r => counter.incrementAndGet()
}
result.successful {
query => {
info(s"done, reading: ${counter.get}")
counter.get() shouldEqual 2000000
}
}
}
}这不是会预先阅读你的记录的东西。事实上,我们有超过一个小时的测试来保证足够的GC暂停,没有GC开销,permgen/metaspace压力保持在范围内,等等。
如果真的有什么改变的话,那只是错误,但这仍然是可行的。
https://stackoverflow.com/questions/35086735
复制相似问题