use of com.datastax.oss.driver.api.core.cql.BoundStatement in project thingsboard by thingsboard.
the class CassandraBaseTimeseriesLatestDao method findAllLatest.
@Override
public ListenableFuture<List<TsKvEntry>> findAllLatest(TenantId tenantId, EntityId entityId) {
BoundStatementBuilder stmtBuilder = new BoundStatementBuilder(getFindAllLatestStmt().bind());
stmtBuilder.setString(0, entityId.getEntityType().name());
stmtBuilder.setUuid(1, entityId.getId());
BoundStatement stmt = stmtBuilder.build();
log.debug(GENERATED_QUERY_FOR_ENTITY_TYPE_AND_ENTITY_ID, stmt, entityId.getEntityType(), entityId.getId());
return getFutureAsync(executeAsyncRead(tenantId, stmt), rs -> convertAsyncResultSetToTsKvEntryList(rs));
}
use of com.datastax.oss.driver.api.core.cql.BoundStatement in project thingsboard by thingsboard.
the class CassandraBaseTimeseriesLatestDao method saveLatest.
@Override
public ListenableFuture<Void> saveLatest(TenantId tenantId, EntityId entityId, TsKvEntry tsKvEntry) {
BoundStatementBuilder stmtBuilder = new BoundStatementBuilder(getLatestStmt().bind());
stmtBuilder.setString(0, entityId.getEntityType().name()).setUuid(1, entityId.getId()).setString(2, tsKvEntry.getKey()).setLong(3, tsKvEntry.getTs()).set(4, tsKvEntry.getBooleanValue().orElse(null), Boolean.class).set(5, tsKvEntry.getStrValue().orElse(null), String.class).set(6, tsKvEntry.getLongValue().orElse(null), Long.class).set(7, tsKvEntry.getDoubleValue().orElse(null), Double.class);
Optional<String> jsonV = tsKvEntry.getJsonValue();
if (jsonV.isPresent()) {
stmtBuilder.setString(8, tsKvEntry.getJsonValue().get());
} else {
stmtBuilder.setToNull(8);
}
BoundStatement stmt = stmtBuilder.build();
return getFuture(executeAsyncWrite(tenantId, stmt), rs -> null);
}
Aggregations