如何从现有的Cassandra DDL中创建Apache Ignite的持久性设置



我正在将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表所需的结果?

键和值需要单独的类。考虑在类SensorDataKey中拆分sensoridtimestamp并更新XML。

最新更新