Skip to content

Commit 860d3c5

Browse files
committed
fix(router): remove dead debug code from SemanticRouter
Removed unused debug aggregation code that was creating a SpotBugs violation (DLS: Dead store to rawResult). The debug code at lines 539-547 was used during development to inspect raw aggregation results but is no longer needed in production code. Fixes: - SpotBugs DLS violation in getRouteMatches() - Dead local store warning
1 parent db1cdbe commit 860d3c5

File tree

6 files changed

+4
-64
lines changed

6 files changed

+4
-64
lines changed

core/src/main/java/com/redis/vl/extensions/router/SemanticRouter.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -537,24 +537,6 @@ private List<RouteMatch> getRouteMatches(
537537
}
538538

539539
// Build aggregation request (Python: _build_aggregate_request, line 308-320)
540-
System.out.println("DEBUG: Filter expression: " + filterBuilder.toString());
541-
System.out.println("DEBUG: Reduced field: " + reducedField);
542-
System.out.println("DEBUG: Aggregation method: " + aggregationMethod);
543-
544-
// First check what VECTOR_RANGE returns without aggregation
545-
redis.clients.jedis.search.aggr.AggregationBuilder noAggregate =
546-
new redis.clients.jedis.search.aggr.AggregationBuilder(vectorQuery.toQueryString())
547-
.params(vectorQuery.toParams())
548-
.load("route_name", "vector_distance")
549-
.dialect(2);
550-
551-
redis.clients.jedis.search.aggr.AggregationResult rawResult =
552-
unifiedJedis.ftAggregate(index.getName(), noAggregate);
553-
System.out.println("DEBUG: Raw results before grouping: " + rawResult.getResults().size());
554-
for (java.util.Map<String, Object> row : rawResult.getResults()) {
555-
System.out.println("DEBUG: Raw row: " + row);
556-
}
557-
558540
redis.clients.jedis.search.aggr.AggregationBuilder aggregation =
559541
new redis.clients.jedis.search.aggr.AggregationBuilder(vectorQuery.toQueryString())
560542
.params(vectorQuery.toParams())
@@ -569,14 +551,6 @@ private List<RouteMatch> getRouteMatches(
569551
redis.clients.jedis.search.aggr.AggregationResult result =
570552
unifiedJedis.ftAggregate(index.getName(), aggregation);
571553

572-
System.out.println(
573-
"DEBUG getRouteMatches: Aggregation returned "
574-
+ result.getResults().size()
575-
+ " results after filtering");
576-
for (java.util.Map<String, Object> row : result.getResults()) {
577-
System.out.println("DEBUG getRouteMatches: Row after filter: " + row);
578-
}
579-
580554
// Convert results to RouteMatch list
581555
java.util.List<RouteMatch> matches = new java.util.ArrayList<>();
582556
for (java.util.Map<String, Object> row : result.getResults()) {

core/src/test/java/com/redis/vl/extensions/cache/NotebookSemanticCacheTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@ public void testCacheStatistics() {
150150
llmcache.check("Question 5"); // Miss
151151
llmcache.check("Question 1"); // Hit again
152152

153-
// Cell 28: Check statistics
154-
System.out.println("\nCache Statistics:");
155-
System.out.println("Hit count: " + llmcache.getHitCount());
156-
System.out.println("Miss count: " + llmcache.getMissCount());
157-
System.out.println("Hit rate: " + String.format("%.2f%%", llmcache.getHitRate() * 100));
158-
159153
assertEquals(3, llmcache.getHitCount());
160154
assertEquals(2, llmcache.getMissCount());
161155
assertEquals(0.6f, llmcache.getHitRate(), 0.01f);

core/src/test/java/com/redis/vl/extensions/cache/SemanticCacheIntegrationTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,19 +314,6 @@ void testTopKResults() {
314314

315315
assertEquals(3, topResults.size());
316316

317-
// Debug: print distances
318-
System.out.println("DEBUG: Top K results:");
319-
for (int i = 0; i < topResults.size(); i++) {
320-
System.out.println(
321-
" "
322-
+ i
323-
+ ": "
324-
+ topResults.get(i).getPrompt()
325-
+ " (distance: "
326-
+ topResults.get(i).getDistance()
327-
+ ")");
328-
}
329-
330317
// Results should be sorted by distance (most similar first)
331318
for (int i = 1; i < topResults.size(); i++) {
332319
assertTrue(

core/src/test/java/com/redis/vl/extensions/router/SemanticRouterIntegrationTest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,9 @@ void testNotebookQuery() {
215215
// Test no-match query from Python notebook cell 9
216216
// Python output: RouteMatch(name=None, distance=None)
217217
RouteMatch noMatch = router.route("are aliens real?");
218-
System.out.println(
219-
"DEBUG: aliens query - name=" + noMatch.getName() + ", distance=" + noMatch.getDistance());
220-
System.out.println(
221-
"DEBUG: technology threshold=" + notebookRoutes.get(0).getDistanceThreshold());
222218

223219
assertThat(noMatch).isNotNull();
224-
// NOTE: Java ONNX embeddings differ from Python, this query may match with distance near
225-
// threshold
226-
// Python: None, Java: may match technology with distance ~0.33
227-
// Accept either outcome as embedding implementations differ
228220
if (noMatch.getName() != null) {
229-
System.out.println("WARN: Java matched where Python didn't - embedding variance");
230221
assertThat(noMatch.getDistance()).isLessThan(0.75);
231222
}
232223
}

core/src/test/java/com/redis/vl/utils/rerank/CrossEncoderTokenizationTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ void testTokenizationMatchesPython() throws Exception {
6666
.isEqualTo(0);
6767
}
6868

69-
System.out.println("\n✓ Tokenization matches Python transformers");
70-
System.out.println(" Query: " + query.substring(0, Math.min(50, query.length())));
71-
System.out.println(" Document: " + doc.substring(0, Math.min(50, doc.length())));
72-
System.out.println(" Token IDs (first 20): " + Arrays.toString(actualFirst20));
73-
System.out.println(" Total tokens: " + inputIds.length);
74-
7569
reranker.close();
7670
}
7771
}

notebooks/08_semantic_router.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,16 @@
599599
" Reference ID: 149a9c9919c58534\n",
600600
" Route: technology\n",
601601
"\n",
602-
" Reference: what are the latest advancements in AI?\n",
603-
" Reference ID: 851f51cce5a9ccfb\n",
602+
" Reference: new tech gadgets\n",
603+
" Reference ID: 7e4bca5853c1c329\n",
604604
" Route: technology\n",
605605
"\n",
606606
" Reference: tell me about the newest gadgets\n",
607607
" Reference ID: 85cc73a1437df27c\n",
608608
" Route: technology\n",
609609
"\n",
610-
" Reference: new tech gadgets\n",
611-
" Reference ID: 7e4bca5853c1c329\n",
610+
" Reference: what are the latest advancements in AI?\n",
611+
" Reference ID: 851f51cce5a9ccfb\n",
612612
" Route: technology\n",
613613
"\n",
614614
" Reference: latest AI trends\n",

0 commit comments

Comments
 (0)