1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00
Files
node-redis/packages/bloom/lib/commands/t-digest/index.ts
Leibale Eidelman be90e62360 Add support for T-Digest (#2214)
* wip

* close #2216 - add support for TDIGEST.MERGESTORE and make compression optional on TDIGEST.CREATE

* fix some tdigest commands, use bloom edge docker

* fix index.ts

* 2.4-RC2 (v2.4.1)

* fix some commands and tests

* clean code
2022-11-01 15:45:47 -04:00

82 lines
1.7 KiB
TypeScript

import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
import * as ADD from './ADD';
import * as BYRANK from './BYRANK';
import * as BYREVRANK from './BYREVRANK';
import * as CDF from './CDF';
import * as CREATE from './CREATE';
import * as INFO from './INFO';
import * as MAX from './MAX';
import * as MERGE from './MERGE';
import * as MIN from './MIN';
import * as QUANTILE from './QUANTILE';
import * as RANK from './RANK';
import * as RESET from './RESET';
import * as REVRANK from './REVRANK';
import * as TRIMMED_MEAN from './TRIMMED_MEAN';
export default {
ADD,
add: ADD,
BYRANK,
byRank: BYRANK,
BYREVRANK,
byRevRank: BYREVRANK,
CDF,
cdf: CDF,
CREATE,
create: CREATE,
INFO,
info: INFO,
MAX,
max: MAX,
MERGE,
merge: MERGE,
MIN,
min: MIN,
QUANTILE,
quantile: QUANTILE,
RANK,
rank: RANK,
RESET,
reset: RESET,
REVRANK,
revRank: REVRANK,
TRIMMED_MEAN,
trimmedMean: TRIMMED_MEAN
};
export interface CompressionOption {
COMPRESSION?: number;
}
export function pushCompressionArgument(
args: RedisCommandArguments,
options?: CompressionOption
): RedisCommandArguments {
if (options?.COMPRESSION) {
args.push('COMPRESSION', options.COMPRESSION.toString());
}
return args;
}
export function transformDoubleReply(reply: string): number {
switch (reply) {
case 'inf':
return Infinity;
case '-inf':
return -Infinity;
case 'nan':
return NaN;
default:
return parseFloat(reply);
}
}
export function transformDoublesReply(reply: Array<string>): Array<number> {
return reply.map(transformDoubleReply);
}