Merge pull request #5676 from wuwen5/fix_index_info_decoder

fixed Redisearch get index info throws NumberFormatException
pull/5679/head
Nikita Koksharov 1 year ago committed by GitHub
commit f09c1f44e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -63,9 +63,9 @@ public class IndexInfo {
private Double recordsPerDocAverage; private Double recordsPerDocAverage;
private Long bytesPerRecordAverage; private Double bytesPerRecordAverage;
private Long offsetsPerTermAverage; private Double offsetsPerTermAverage;
private Long offsetBitsPerRecordAverage; private Long offsetBitsPerRecordAverage;
private Long hashIndexingFailures; private Long hashIndexingFailures;
@ -249,20 +249,20 @@ public class IndexInfo {
return this; return this;
} }
public Long getBytesPerRecordAverage() { public Double getBytesPerRecordAverage() {
return bytesPerRecordAverage; return bytesPerRecordAverage;
} }
public IndexInfo setBytesPerRecordAverage(Long bytesPerRecordAverage) { public IndexInfo setBytesPerRecordAverage(Double bytesPerRecordAverage) {
this.bytesPerRecordAverage = bytesPerRecordAverage; this.bytesPerRecordAverage = bytesPerRecordAverage;
return this; return this;
} }
public Long getOffsetsPerTermAverage() { public Double getOffsetsPerTermAverage() {
return offsetsPerTermAverage; return offsetsPerTermAverage;
} }
public IndexInfo setOffsetsPerTermAverage(Long offsetsPerTermAverage) { public IndexInfo setOffsetsPerTermAverage(Double offsetsPerTermAverage) {
this.offsetsPerTermAverage = offsetsPerTermAverage; this.offsetsPerTermAverage = offsetsPerTermAverage;
return this; return this;
} }

@ -50,16 +50,16 @@ public class IndexInfoDecoder implements MultiDecoder<Object> {
ii.setMaxDocId(toLong(result, "max_doc_id")); ii.setMaxDocId(toLong(result, "max_doc_id"));
ii.setTerms(toLong(result, "num_terms")); ii.setTerms(toLong(result, "num_terms"));
ii.setRecords(toLong(result, "num_records")); ii.setRecords(toLong(result, "num_records"));
ii.setInvertedSize(Double.valueOf(result.get("inverted_sz_mb").toString())); ii.setInvertedSize(toDouble(result, "inverted_sz_mb"));
ii.setVectorIndexSize(Double.valueOf(result.get("vector_index_sz_mb").toString())); ii.setVectorIndexSize(toDouble(result, "vector_index_sz_mb"));
ii.setTotalInvertedIndexBlocks(Double.valueOf(result.get("total_inverted_index_blocks").toString())); ii.setTotalInvertedIndexBlocks(toDouble(result, "total_inverted_index_blocks"));
ii.setOffsetVectorsSize(Double.valueOf(result.get("offset_vectors_sz_mb").toString())); ii.setOffsetVectorsSize(toDouble(result, "offset_vectors_sz_mb"));
ii.setDocTableSize(Double.valueOf(result.get("doc_table_size_mb").toString())); ii.setDocTableSize(toDouble(result, "doc_table_size_mb"));
ii.setSortableValuesSize(Double.valueOf(result.get("sortable_values_size_mb").toString())); ii.setSortableValuesSize(toDouble(result, "sortable_values_size_mb"));
ii.setKeyTableSize(Double.valueOf(result.get("key_table_size_mb").toString())); ii.setKeyTableSize(toDouble(result, "key_table_size_mb"));
ii.setRecordsPerDocAverage(Double.valueOf(result.get("records_per_doc_avg").toString())); ii.setRecordsPerDocAverage(toDouble(result, "records_per_doc_avg"));
ii.setBytesPerRecordAverage(toLong(result, "bytes_per_record_avg")); ii.setBytesPerRecordAverage(toDouble(result, "bytes_per_record_avg"));
ii.setOffsetsPerTermAverage(toLong(result, "offsets_per_term_avg")); ii.setOffsetsPerTermAverage(toDouble(result, "offsets_per_term_avg"));
ii.setOffsetBitsPerRecordAverage(toLong(result, "offset_bits_per_record_avg")); ii.setOffsetBitsPerRecordAverage(toLong(result, "offset_bits_per_record_avg"));
ii.setHashIndexingFailures(toLong(result, "hash_indexing_failures")); ii.setHashIndexingFailures(toLong(result, "hash_indexing_failures"));
ii.setTotalIndexingTime(Double.valueOf(result.get("total_indexing_time").toString())); ii.setTotalIndexingTime(Double.valueOf(result.get("total_indexing_time").toString()));
@ -85,4 +85,11 @@ public class IndexInfoDecoder implements MultiDecoder<Object> {
} }
return Long.valueOf(result.get(prop).toString()); return Long.valueOf(result.get(prop).toString());
} }
private Double toDouble(Map<String, Object> result, String prop) {
if (result.get(prop).toString().contains("nan")) {
return 0D;
}
return Double.valueOf(result.get(prop).toString());
}
} }

Loading…
Cancel
Save