Debian Codegraph @

packages/time-series/lib/commands/INFO_DEBUG.ts

raw
1 import {
2 transformArguments as transformInfoArguments,
3 InfoRawReply,
4 InfoReply,
5 transformReply as transformInfoReply
6 } from './INFO';
7
8 export { IS_READ_ONLY, FIRST_KEY_INDEX } from './INFO';
9
10 export function transformArguments(key: string): Array<string> {
11 const args = transformInfoArguments(key);
12 args.push('DEBUG');
13 return args;
14 }
15
16 type InfoDebugRawReply = [
17 ...InfoRawReply,
18 'keySelfName',
19 string,
20 'chunks',
21 Array<[
22 'startTimestamp',
23 number,
24 'endTimestamp',
25 number,
26 'samples',
27 number,
28 'size',
29 number,
30 'bytesPerSample',
31 string
32 ]>
33 ];
34
35 interface InfoDebugReply extends InfoReply {
36 keySelfName: string;
37 chunks: Array<{
38 startTimestamp: number;
39 endTimestamp: number;
40 samples: number;
41 size: number;
42 bytesPerSample: string;
43 }>;
44 }
45
46 export function transformReply(rawReply: InfoDebugRawReply): InfoDebugReply {
47 const reply = transformInfoReply(rawReply as unknown as InfoRawReply);
48 (reply as InfoDebugReply).keySelfName = rawReply[25];
49 (reply as InfoDebugReply).chunks = rawReply[27].map(chunk => ({
50 startTimestamp: chunk[1],
51 endTimestamp: chunk[3],
52 samples: chunk[5],
53 size: chunk[7],
54 bytesPerSample: chunk[9]
55 }));
56 return reply as InfoDebugReply;
57 }