Skip to content

Commit

Permalink
Reformat file
Browse files Browse the repository at this point in the history
  • Loading branch information
sidhdirenge committed Sep 12, 2024
1 parent 7a9ba4a commit 18748fb
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ public void updateAll(Range keyRange, Collection<Field<?>> fields) throws Invali

@Override
public long count(Collection<Range> keyRanges) {
try (ResultSet resultSet = transactionContext.executeQuery(getCountStatement(keyRanges, Collections.emptyList()))) {
try (ResultSet resultSet = transactionContext.executeQuery(
getCountStatement(keyRanges, Collections.emptyList()))) {
if (!resultSet.next()) {
return 0L;
}
Expand All @@ -441,7 +442,8 @@ public long count(Collection<Range> keyRanges) {
@Override
public long count(Collection<Range> keyRanges, Collection<Field<?>> filterIndexes)
throws InvalidFieldException, IOException {
try (ResultSet resultSet = transactionContext.executeQuery(getCountStatement(keyRanges, filterIndexes))) {
try (ResultSet resultSet = transactionContext.executeQuery(
getCountStatement(keyRanges, filterIndexes))) {
if (!resultSet.next()) {
return 0L;
}
Expand All @@ -454,16 +456,18 @@ public void close() {
// No-op
}

private Statement getCountStatement(Collection<Range> ranges, Collection<Field<?>> filterIndexes) {
private Statement getCountStatement(Collection<Range> ranges,
Collection<Field<?>> filterIndexes) {
Map<String, Value> parameters = new HashMap<>();
String whereClause = getRangesWhereClause(ranges, parameters);
Statement.Builder builder = Statement.newBuilder("SELECT COUNT(*) FROM " + escapeName(schema.getTableId().getName()));
Statement.Builder builder = Statement.newBuilder(
"SELECT COUNT(*) FROM " + escapeName(schema.getTableId().getName()));

if (whereClause != null) {
builder.append(" WHERE " + whereClause);
parameters.forEach((name, value) -> builder.bind(name).to(value));
}
if (!filterIndexes.isEmpty()){
if (!filterIndexes.isEmpty()) {
if (whereClause != null) {
builder.append(" AND ");
}
Expand Down Expand Up @@ -543,7 +547,7 @@ private String getIndexesFilterClause(Collection<Field<?>> filterIndexes,
/**
* Generates the WHERE clause for a set of ranges.
*
* @param ranges the set of ranges to query for
* @param ranges the set of ranges to query for
* @param parameters the parameters name and value used in the WHERE clause
* @return the WHERE clause or {@code null} if the ranges resulted in a full table query.
*/
Expand Down

0 comments on commit 18748fb

Please sign in to comment.