Skip to content

Commit d859db0

Browse files
dfa1claude
andcommitted
refactor: unnamed pattern _ for unused switch bindings (S1481)
All 31 S1481 "unused local" hits were type-pattern bindings the case never reads — `case Predicate.IsNull ignored ->` and friends. The idiomatic Java fix is the unnamed pattern `_`, not deletion (a type pattern still needs a binding slot): `case Predicate.IsNull _ ->`. Cleaner than the `ignored` convention and Sonar-clean. Behavior identical; full verify green including fbs-gen regeneration. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent f4b97d0 commit d859db0

8 files changed

Lines changed: 30 additions & 30 deletions

File tree

calcite/src/main/java/io/github/dfa1/vortex/calcite/VortexTable.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ private static Match classifyColumn(Predicate predicate, ArrayStats s, long rowC
519519
(st, v) -> compareStat(st.min(), v) >= 0, (st, v) -> compareStat(st.max(), v) < 0);
520520
case Predicate.Lte(var value) -> compare(s, value,
521521
(st, v) -> compareStat(st.min(), v) > 0, (st, v) -> compareStat(st.max(), v) <= 0);
522-
case Predicate.IsNull ignored -> {
522+
case Predicate.IsNull _ -> {
523523
Long nulls = s.nullCount();
524524
if (nulls == null) {
525525
yield Match.BOUNDARY;
@@ -529,7 +529,7 @@ private static Match classifyColumn(Predicate predicate, ArrayStats s, long rowC
529529
}
530530
yield nulls == 0 ? Match.OUT : Match.BOUNDARY;
531531
}
532-
case Predicate.IsNotNull ignored -> {
532+
case Predicate.IsNotNull _ -> {
533533
Long nulls = s.nullCount();
534534
if (nulls == null) {
535535
yield Match.BOUNDARY;
@@ -539,9 +539,9 @@ private static Match classifyColumn(Predicate predicate, ArrayStats s, long rowC
539539
}
540540
yield nulls == rowCount ? Match.OUT : Match.BOUNDARY;
541541
}
542-
case Predicate.Between ignored -> Match.BOUNDARY;
543-
case Predicate.And ignored -> Match.BOUNDARY;
544-
case Predicate.Or ignored -> Match.BOUNDARY;
542+
case Predicate.Between _ -> Match.BOUNDARY;
543+
case Predicate.And _ -> Match.BOUNDARY;
544+
case Predicate.Or _ -> Match.BOUNDARY;
545545
};
546546
}
547547

cli/src/main/java/io/github/dfa1/vortex/cli/FilterCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ private static RowPredicate columnPredicate(String col, Predicate predicate) {
179179
(chunk, rowIdx) -> compareValue(chunk.column(col), rowIdx, (Comparable<?>) val) == 0;
180180
case Predicate.Neq(var val) ->
181181
(chunk, rowIdx) -> compareValue(chunk.column(col), rowIdx, (Comparable<?>) val) != 0;
182-
case Predicate.IsNull ignored -> (chunk, rowIdx) -> isRowNull(chunk.column(col), rowIdx);
183-
case Predicate.IsNotNull ignored -> (chunk, rowIdx) -> !isRowNull(chunk.column(col), rowIdx);
184-
case Predicate.Between ignored ->
182+
case Predicate.IsNull _ -> (chunk, rowIdx) -> isRowNull(chunk.column(col), rowIdx);
183+
case Predicate.IsNotNull _ -> (chunk, rowIdx) -> !isRowNull(chunk.column(col), rowIdx);
184+
case Predicate.Between _ ->
185185
throw new IllegalArgumentException("BETWEEN filters are not supported on the command line");
186-
case Predicate.And ignored ->
186+
case Predicate.And _ ->
187187
throw new IllegalArgumentException("nested predicate AND is not supported on the command line");
188-
case Predicate.Or ignored ->
188+
case Predicate.Or _ ->
189189
throw new IllegalArgumentException("nested predicate OR is not supported on the command line");
190190
};
191191
}

fbs-gen/src/main/java/io/github/dfa1/vortex/fbsgen/CodeGen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private int emitTableField(StringBuilder sb, Ast.Field field, int vtableIndex) {
130130
emitScalarTableField(sb, accessor, e.underlying(), vt, field.defaultValue().orElse(null));
131131
yield vtableIndex + 1;
132132
}
133-
case Ast.UnionDecl u -> {
133+
case Ast.UnionDecl _ -> {
134134
emitUnionField(sb, accessor, vt);
135135
yield vtableIndex + 2;
136136
}
@@ -230,7 +230,7 @@ private void emitVectorField(StringBuilder sb, String accessor, Ast.FieldType el
230230
case Ast.EnumDecl e -> emitScalarVectorElements(sb, accessor, e.underlying(), vt);
231231
case Ast.TableDecl t -> emitObjectVectorElement(sb, accessor, className(t.name()), vt, 4, true);
232232
case Ast.StructDecl s -> emitObjectVectorElement(sb, accessor, className(s.name()), vt, registry.layoutOf(s).size(), false);
233-
case Ast.UnionDecl u -> throw new FbsParseException("vectors of unions are not supported ('" + accessor + "')");
233+
case Ast.UnionDecl _ -> throw new FbsParseException("vectors of unions are not supported ('" + accessor + "')");
234234
}
235235
}
236236

reader/src/main/java/io/github/dfa1/vortex/reader/ScanIterator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,9 @@ private static boolean canPrune(Predicate predicate, ArrayStats stats, long rowC
771771
case Predicate.Between(var lo, var hi) -> min != null && max != null
772772
&& (Compare.values(hi, min, ct) < 0 || Compare.values(lo, max, ct) > 0);
773773
// Zero nulls → no row is null → nothing can match IS NULL.
774-
case Predicate.IsNull ignored -> nullCount != null && nullCount == 0;
774+
case Predicate.IsNull _ -> nullCount != null && nullCount == 0;
775775
// Every row is null → no row is non-null → nothing can match IS NOT NULL.
776-
case Predicate.IsNotNull ignored -> nullCount != null && nullCount == rowCount;
776+
case Predicate.IsNotNull _ -> nullCount != null && nullCount == rowCount;
777777
// A conjunction is unsatisfiable if either side is; a disjunction only if both are.
778778
case Predicate.And(var left, var right) ->
779779
canPrune(left, stats, rowCount, ct) || canPrune(right, stats, rowCount, ct);

reader/src/main/java/io/github/dfa1/vortex/reader/compute/PredicateEvaluator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ static boolean evaluate(Array array, long i, Predicate predicate) {
3838
case Predicate.Gte gte -> !Values.isNullAt(array, i)
3939
&& Compare.values(Values.valueAt(array, i), gte.value(), array.dtype()) >= 0;
4040
case Predicate.Between between -> evaluateBetween(array, i, between);
41-
case Predicate.IsNull ignored -> Values.isNullAt(array, i);
42-
case Predicate.IsNotNull ignored -> !Values.isNullAt(array, i);
41+
case Predicate.IsNull _ -> Values.isNullAt(array, i);
42+
case Predicate.IsNotNull _ -> !Values.isNullAt(array, i);
4343
case Predicate.And and -> evaluate(array, i, and.left()) && evaluate(array, i, and.right());
4444
case Predicate.Or or -> evaluate(array, i, or.left()) || evaluate(array, i, or.right());
4545
};

reader/src/test/java/io/github/dfa1/vortex/reader/ComputeFilteredAggregateTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ private static boolean accepts(Predicate predicate, Reference column, int i) {
497497
boolean isNull = column.isNull(i);
498498
long v = column.values()[i];
499499
return switch (predicate) {
500-
case Predicate.IsNull ignored -> isNull;
501-
case Predicate.IsNotNull ignored -> !isNull;
500+
case Predicate.IsNull _ -> isNull;
501+
case Predicate.IsNotNull _ -> !isNull;
502502
case Predicate.Eq eq -> !isNull && v == ((Number) eq.value()).longValue();
503503
case Predicate.Neq neq -> !isNull && v != ((Number) neq.value()).longValue();
504504
case Predicate.Lt lt -> !isNull && v < ((Number) lt.value()).longValue();

reader/src/test/java/io/github/dfa1/vortex/reader/compute/PredicateTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,17 @@ void exhaustivePatternSwitchCoversEveryVariant() {
361361

362362
private static String label(Predicate predicate) {
363363
return switch (predicate) {
364-
case Predicate.Eq ignored -> "eq";
365-
case Predicate.Neq ignored -> "neq";
366-
case Predicate.Lt ignored -> "lt";
367-
case Predicate.Gt ignored -> "gt";
368-
case Predicate.Lte ignored -> "lte";
369-
case Predicate.Gte ignored -> "gte";
370-
case Predicate.Between ignored -> "between";
371-
case Predicate.IsNull ignored -> "isNull";
372-
case Predicate.IsNotNull ignored -> "isNotNull";
373-
case Predicate.And ignored -> "and";
374-
case Predicate.Or ignored -> "or";
364+
case Predicate.Eq _ -> "eq";
365+
case Predicate.Neq _ -> "neq";
366+
case Predicate.Lt _ -> "lt";
367+
case Predicate.Gt _ -> "gt";
368+
case Predicate.Lte _ -> "lte";
369+
case Predicate.Gte _ -> "gte";
370+
case Predicate.Between _ -> "between";
371+
case Predicate.IsNull _ -> "isNull";
372+
case Predicate.IsNotNull _ -> "isNotNull";
373+
case Predicate.And _ -> "and";
374+
case Predicate.Or _ -> "or";
375375
};
376376
}
377377
}

writer/src/main/java/io/github/dfa1/vortex/writer/VortexWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ private static byte[] columnSum(DType dtype, Object data) {
911911
private static Object zoneStatValues(DType minMaxDtype, List<byte[]> statBytes) throws IOException {
912912
return switch (minMaxDtype) {
913913
case DType.Primitive p -> statColumn(p.ptype(), statBytes);
914-
case DType.Utf8 ignored -> statStringColumn(statBytes);
914+
case DType.Utf8 _ -> statStringColumn(statBytes);
915915
default -> throw new IllegalStateException("no zone stat values for " + minMaxDtype);
916916
};
917917
}

0 commit comments

Comments
 (0)