Function to get quantization name.

This commit is contained in:
antirez 2025-02-05 11:07:35 +01:00
parent e6f1667a3d
commit 8206c782b5
1 changed files with 11 additions and 9 deletions

20
vset.c
View File

@ -127,6 +127,16 @@ void vectorSetReleaseObject(struct vsetObject *o) {
RedisModule_Free(o); RedisModule_Free(o);
} }
/* Return a string representing the quantization type name of a vector set. */
const char *vectorSetGetQuantName(struct vsetObject *o) {
switch(o->hnsw->quant_type) {
case HNSW_QUANT_NONE: return "f32";
case HNSW_QUANT_Q8: return "int8";
case HNSW_QUANT_BIN: return "bin";
default: return "unknown";
}
}
/* Insert the specified element into the Vector Set. /* Insert the specified element into the Vector Set.
* If update is '1', the existing node will be updated. * If update is '1', the existing node will be updated.
* *
@ -979,15 +989,7 @@ int VINFO_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
/* Quantization type */ /* Quantization type */
RedisModule_ReplyWithSimpleString(ctx, "quant-type"); RedisModule_ReplyWithSimpleString(ctx, "quant-type");
if (vset->hnsw->quant_type == HNSW_QUANT_NONE) { RedisModule_ReplyWithSimpleString(ctx, vectorSetGetQuantName(vset));
RedisModule_ReplyWithSimpleString(ctx, "f32");
} else if (vset->hnsw->quant_type == HNSW_QUANT_Q8) {
RedisModule_ReplyWithSimpleString(ctx, "int8");
} else if (vset->hnsw->quant_type == HNSW_QUANT_BIN) {
RedisModule_ReplyWithSimpleString(ctx, "bin");
} else {
RedisModule_ReplyWithSimpleString(ctx, "unknown");
}
/* Vector dimensionality. */ /* Vector dimensionality. */
RedisModule_ReplyWithSimpleString(ctx, "vector-dim"); RedisModule_ReplyWithSimpleString(ctx, "vector-dim");