Skip to content

Commit 4fcd99b

Browse files
author
Vladimir Kotal
committed
check the value before putting to average key lengths map
1 parent fbc0881 commit 4fcd99b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

suggester/src/main/java/org/opengrok/suggest/SuggesterProjectData.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opengrok.suggest;
2424

@@ -261,8 +261,10 @@ private WFSTCompletionLookup build(final IndexReader indexReader, final String f
261261
WFSTCompletionLookup lookup = createWFST();
262262
lookup.build(iterator);
263263

264-
double averageLength = (double) iterator.termLengthAccumulator / lookup.getCount();
265-
averageLengths.put(field, averageLength);
264+
if (lookup.getCount() > 0) {
265+
double averageLength = (double) iterator.termLengthAccumulator / lookup.getCount();
266+
averageLengths.put(field, averageLength);
267+
}
266268

267269
return lookup;
268270
}

0 commit comments

Comments
 (0)