public static CqlQuery constructCheckAndSetMultipleQuery(Map<String, Pair<byte[], byte[]>> checkAndSetRequest) { StringBuilder builder = new StringBuilder(); builder.append("BEGIN UNLOGGED BATCH\n"); // Safe, because all updates are on the same partition key // Safe, because ordering does not apply in batches checkAndSetRequest.forEach((columnName, value) -> { byte[] expected = value.getLhSide(); byte[] target = value.getRhSide(); builder.append(constructCheckAndSetQuery(columnName, expected, target)); }); builder.append("APPLY BATCH;"); // This looks awkward. However, we know that all expressions in this String pertain to timestamps and known // table references, hence this is actually safe. Doing this quickly owing to priority. // TODO (jkong): Build up a query by passing around legitimate formats and args. return CqlQuery.builder() .safeQueryFormat(builder.toString()) .build(); }
public static CqlQuery constructCheckAndSetMultipleQuery(Map<String, Pair<byte[], byte[]>> checkAndSetRequest) { StringBuilder builder = new StringBuilder(); builder.append("BEGIN UNLOGGED BATCH\n"); // Safe, because all updates are on the same partition key // Safe, because ordering does not apply in batches checkAndSetRequest.forEach((columnName, value) -> { byte[] expected = value.getLhSide(); byte[] target = value.getRhSide(); builder.append(constructCheckAndSetQuery(columnName, expected, target)); }); builder.append("APPLY BATCH;"); // This looks awkward. However, we know that all expressions in this String pertain to timestamps and known // table references, hence this is actually safe. Doing this quickly owing to priority. // TODO (jkong): Build up a query by passing around legitimate formats and args. return CqlQuery.builder() .safeQueryFormat(builder.toString()) .build(); }