如何从现有的CassandraDDL为ApacheIgnite创建持久性设置?
我正在将Ignite cache与Cassandra集成。对于现有的Cassandra表,我有以下DDL:如何从现有的CassandraDDL为ApacheIgnite创建持久性设置?,cassandra,ignite,Cassandra,Ignite,我正在将Ignite cache与Cassandra集成。对于现有的Cassandra表,我有以下DDL: CREATE TABLE IF NOT EXISTS ignite.wgs_measurements ( "conValue" double, "location" text, "rawValue" double, "sensorid" text, &
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>
在这里,您还可以看到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表所需的结果?您需要为key和value分别设置类。考虑拆分<代码> SyrordID 和<代码>时间戳<代码>在类<代码> SysRoDATAKEY < /COD>和更新XML。 < P>键和值需要单独的类。考虑拆分<代码> SyrordID <代码>和<代码>时间戳<代码>在类<代码> SysRoDATAKEY < /COD>和更新XML。< /P>
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*/
}