使用 AllRowsReader 读取行但从特定行开始
Reading rows using AllRowsReader but starting from a specific row
我有一个批处理作业,它使用 AllRowsReader
中描述的 in the Astyanax wiki:
在 Cassandra 中读取大约 3300 万行
new AllRowsReader.Builder<>(getKeyspace(), columnFamily)
.withPageSize(100)
.withIncludeEmptyRows(false)
.withConcurrencyLevel(1)
.forEachRow(
row -> {
try {
return processRow(row);
} catch (Exception e) {
LOG.error("Error while processing row!", e);
return false;
}
}
)
.build()
.call();
如果某种错误停止了批处理作业,我希望能够从它停止的行开始并继续阅读,这样我就不必再次从第一行开始阅读。有没有快速简单的方法来做到这一点?
或者 AllRowsReader
不适合这种任务吗?
既然没有人回答让我试试这个。 Cassandra 使用分区器来确定应该将行放置在哪个节点中。
主要有两种类型的分区器:
1) 订购
2) 无序
https://docs.datastax.com/en/cassandra/2.2/cassandra/architecture/archPartitionerAbout.html
如果是 Ordered Partitioner,行是根据字典顺序放置的 order.But 如果是 Unordered Partitioner,您无法知道顺序。
Ordered Partitioner 在 cassandra 中被视为反模式,因为它使集群分布变得非常困难。
https://docs.datastax.com/en/cassandra/2.2/cassandra/planning/planPlanningAntiPatterns.html
我假设您应该在代码中使用无序分区程序。所以目前没有办法告诉 cassandra 哪个正在使用从这个特定行开始的无序分区程序。
我希望这能回答您的问题
我有一个批处理作业,它使用 AllRowsReader
中描述的 in the Astyanax wiki:
new AllRowsReader.Builder<>(getKeyspace(), columnFamily)
.withPageSize(100)
.withIncludeEmptyRows(false)
.withConcurrencyLevel(1)
.forEachRow(
row -> {
try {
return processRow(row);
} catch (Exception e) {
LOG.error("Error while processing row!", e);
return false;
}
}
)
.build()
.call();
如果某种错误停止了批处理作业,我希望能够从它停止的行开始并继续阅读,这样我就不必再次从第一行开始阅读。有没有快速简单的方法来做到这一点?
或者 AllRowsReader
不适合这种任务吗?
既然没有人回答让我试试这个。 Cassandra 使用分区器来确定应该将行放置在哪个节点中。 主要有两种类型的分区器: 1) 订购 2) 无序
https://docs.datastax.com/en/cassandra/2.2/cassandra/architecture/archPartitionerAbout.html
如果是 Ordered Partitioner,行是根据字典顺序放置的 order.But 如果是 Unordered Partitioner,您无法知道顺序。
Ordered Partitioner 在 cassandra 中被视为反模式,因为它使集群分布变得非常困难。 https://docs.datastax.com/en/cassandra/2.2/cassandra/planning/planPlanningAntiPatterns.html
我假设您应该在代码中使用无序分区程序。所以目前没有办法告诉 cassandra 哪个正在使用从这个特定行开始的无序分区程序。
我希望这能回答您的问题