【发布时间】:2020-11-18 20:07:06
【问题描述】:
我正在将 Ignite 缓存与 Cassandra 集成。对于现有的 Cassandra 表,我有以下 DDL:
CREATE TABLE IF NOT EXISTS ignite.wgs_measurements
(
"conValue" double,
"location" text,
"rawValue" double,
"sensorid" text,
"timestamp" timestamp,
"type" text,
primary key (sensorid, timestamp)
) WITH CLUSTERING ORDER BY (timestamp DESC);
我创建了以下 persistence_settings.xml 文件来尝试匹配 cassandra 表。
<persistence keyspace="ignite" table="wgs_measurements" ttl="86400">
<keyspaceOptions>
REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 3}
AND DURABLE_WRITES = true
</keyspaceOptions>
<tableOption>
comment = 'Cache test'
AND read_repair_chance = 0.2
</tableOption>
<!-- Persistent settings for Ignite cache keys -->
<keyPersistence class="ignite.SensorData" strategy="POJO">
<!-- Partition key fields if POJO strategy used -->
<partitionKey>
<!-- Mapping from POJO field to Cassandra table column -->
<field name="sensorId" column="sensorid" />
<field name="timestamp" column="timestamp" />
</partitionKey>
</keyPersistence>
<valuePersistence class="ignite.SensorData"
strategy="POJO">
<!-- Mapping from POJO field to Cassandra table column -->
<field name="conValue" />
<field name="rawValue" />
<field name="location" />
<field name="type" />
</valuePersistence>
</persistence>
但是对这个 persistence_settings.xml 文件使用 Ignite Cassandra DDLGenerator 我得到了以下与我现有的 DDL 不匹配的 DDL。
create table if not exists "ignite"."wgs_measurements"
(
"sensorid" text,
"timestamp" timestamp,
"convalue" double,
"location" text,
"rawvalue" double,
"type" text,
primary key (("sensorid", "timestamp"), "convalue", "location", "rawvalue", "type")
);
在这里您也可以看到 SensorData 类:
public class SensorData {
public String type = "UNKNOWN";
public String sensorId;
public Date timestamp;
public String location = "UNKNOWN";
public double rawValue;
public double conValue = -1D;
/*All getters and setters are included here*/
}
如何调整持久性设置以获得创建现有 Cassandra 表所需的结果?
【问题讨论】: