Merge pull request #7561 from imbeacon/cassandra-dao-refactoring
[3.4.2] CassandraBaseTimeseriesDao refactoring
This commit is contained in:
commit
54f1694f1c
@ -645,14 +645,7 @@ public class CassandraBaseTimeseriesDao extends AbstractCassandraBaseTimeseriesD
|
|||||||
if (saveStmts == null) {
|
if (saveStmts == null) {
|
||||||
var stmts = new PreparedStatement[DataType.values().length];
|
var stmts = new PreparedStatement[DataType.values().length];
|
||||||
for (DataType type : DataType.values()) {
|
for (DataType type : DataType.values()) {
|
||||||
stmts[type.ordinal()] = prepare(INSERT_INTO + ModelConstants.TS_KV_CF +
|
stmts[type.ordinal()] = prepare(getPreparedStatementQuery(type));
|
||||||
"(" + ModelConstants.ENTITY_TYPE_COLUMN +
|
|
||||||
"," + ModelConstants.ENTITY_ID_COLUMN +
|
|
||||||
"," + ModelConstants.KEY_COLUMN +
|
|
||||||
"," + ModelConstants.PARTITION_COLUMN +
|
|
||||||
"," + ModelConstants.TS_COLUMN +
|
|
||||||
"," + getColumnName(type) + ")" +
|
|
||||||
" VALUES(?, ?, ?, ?, ?, ?)");
|
|
||||||
}
|
}
|
||||||
saveStmts = stmts;
|
saveStmts = stmts;
|
||||||
}
|
}
|
||||||
@ -670,14 +663,7 @@ public class CassandraBaseTimeseriesDao extends AbstractCassandraBaseTimeseriesD
|
|||||||
if (saveTtlStmts == null) {
|
if (saveTtlStmts == null) {
|
||||||
var stmts = new PreparedStatement[DataType.values().length];
|
var stmts = new PreparedStatement[DataType.values().length];
|
||||||
for (DataType type : DataType.values()) {
|
for (DataType type : DataType.values()) {
|
||||||
stmts[type.ordinal()] = prepare(INSERT_INTO + ModelConstants.TS_KV_CF +
|
stmts[type.ordinal()] = prepare(getPreparedStatementQueryWithTtl(type));
|
||||||
"(" + ModelConstants.ENTITY_TYPE_COLUMN +
|
|
||||||
"," + ModelConstants.ENTITY_ID_COLUMN +
|
|
||||||
"," + ModelConstants.KEY_COLUMN +
|
|
||||||
"," + ModelConstants.PARTITION_COLUMN +
|
|
||||||
"," + ModelConstants.TS_COLUMN +
|
|
||||||
"," + getColumnName(type) + ")" +
|
|
||||||
" VALUES(?, ?, ?, ?, ?, ?) USING TTL ?");
|
|
||||||
}
|
}
|
||||||
saveTtlStmts = stmts;
|
saveTtlStmts = stmts;
|
||||||
}
|
}
|
||||||
@ -688,6 +674,21 @@ public class CassandraBaseTimeseriesDao extends AbstractCassandraBaseTimeseriesD
|
|||||||
return saveTtlStmts[dataType.ordinal()];
|
return saveTtlStmts[dataType.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPreparedStatementQuery(DataType type) {
|
||||||
|
return INSERT_INTO + ModelConstants.TS_KV_CF +
|
||||||
|
"(" + ModelConstants.ENTITY_TYPE_COLUMN +
|
||||||
|
"," + ModelConstants.ENTITY_ID_COLUMN +
|
||||||
|
"," + ModelConstants.KEY_COLUMN +
|
||||||
|
"," + ModelConstants.PARTITION_COLUMN +
|
||||||
|
"," + ModelConstants.TS_COLUMN +
|
||||||
|
"," + getColumnName(type) + ")" +
|
||||||
|
" VALUES(?, ?, ?, ?, ?, ?)";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPreparedStatementQueryWithTtl(DataType type) {
|
||||||
|
return getPreparedStatementQuery(type) + " USING TTL ?";
|
||||||
|
}
|
||||||
|
|
||||||
private PreparedStatement getPartitionInsertStmt() {
|
private PreparedStatement getPartitionInsertStmt() {
|
||||||
if (partitionInsertStmt == null) {
|
if (partitionInsertStmt == null) {
|
||||||
stmtCreationLock.lock();
|
stmtCreationLock.lock();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user