Skip to content

Commit

Permalink
[BUG] Fix failures of test on some OS where 1.0 is not a double (#2954)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Shtul committed Aug 3, 2022
1 parent 7ce353e commit d5a17d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/info_command.c
Expand Up @@ -4,6 +4,8 @@
#include "vector_index.h"
#include "cursor.h"

#define CLOCKS_PER_MILLISEC (CLOCKS_PER_SEC / 1000)

#define REPLY_KVNUM(n, k, v) \
do { \
RedisModule_ReplyWithSimpleString(ctx, (k)); \
Expand Down Expand Up @@ -208,7 +210,7 @@ int IndexInfoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
REPLY_KVNUM(n, "offset_bits_per_record_avg",
8.0F * (float)sp->stats.offsetVecsSize / (float)sp->stats.offsetVecRecords);
REPLY_KVNUM(n, "hash_indexing_failures", sp->stats.indexingFailures);
REPLY_KVNUM(n, "total_indexing_time", sp->stats.totalIndexTime);
REPLY_KVNUM(n, "total_indexing_time", (double)sp->stats.totalIndexTime / CLOCKS_PER_MILLISEC);
REPLY_KVNUM(n, "indexing", !!global_spec_scanner || sp->scan_in_progress);

IndexesScanner *scanner = global_spec_scanner ? global_spec_scanner : sp->scanner;
Expand Down
3 changes: 1 addition & 2 deletions src/spec.c
Expand Up @@ -26,7 +26,6 @@
#include "commands.h"

#define INITIAL_DOC_TABLE_SIZE 1000
#define CLOCKS_PER_MILLISEC (CLOCKS_PER_SEC / 1000.0)

///////////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -2566,7 +2565,7 @@ int IndexSpec_UpdateDoc(IndexSpec *spec, RedisModuleCtx *ctx, RedisModuleString
Document_Free(&doc);

clock_t totalDocTime = clock() - startDocTime;
spec->stats.totalIndexTime += totalDocTime / CLOCKS_PER_MILLISEC;
spec->stats.totalIndexTime += totalDocTime;

return REDISMODULE_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/spec.h
Expand Up @@ -113,7 +113,7 @@ typedef struct {
size_t termsSize;
size_t indexingFailures;
size_t vectorIndexSize;
double totalIndexTime;
size_t totalIndexTime;
} IndexStats;

typedef enum {
Expand Down

0 comments on commit d5a17d3

Please sign in to comment.