You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
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
This commit is contained in:
81
packages/bloom/lib/commands/t-digest/index.ts
Normal file
81
packages/bloom/lib/commands/t-digest/index.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
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);
|
||||
}
|
Reference in New Issue
Block a user