Skip to content

Commit 2ac0964

Browse files
committed
move bloom* info commands to not error out if map type mapping is used
1 parent 60499fc commit 2ac0964

File tree

5 files changed

+47
-76
lines changed

5 files changed

+47
-76
lines changed

packages/bloom/lib/commands/bloom/INFO.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export type BfInfoReplyMap = TuplesToMapReply<[
99
]>;
1010

1111
export interface BfInfoReply {
12-
capacity?: NumberReply;
13-
size?: NumberReply;
14-
numberOfFilters?: NumberReply;
15-
numberOfInsertedItems?: NumberReply;
16-
expansionRate?: NullReply | NumberReply;
12+
capacity: NumberReply;
13+
size: NumberReply;
14+
numberOfFilters: NumberReply;
15+
numberOfInsertedItems: NumberReply;
16+
expansionRate: NullReply | NumberReply;
1717
}
1818

1919
export default {
@@ -34,27 +34,21 @@ export default {
3434
},
3535
3(reply: UnwrapReply<BfInfoReplyMap>): BfInfoReply {
3636
if (reply instanceof Map) {
37-
throw new Error("BF.INFO shouldn't be used with type mapping to map or array");
38-
/*
3937
return {
40-
capacity: reply.get("Capacity" as unknown as BlobStringReply<'Capacity'>),
41-
size: reply.get("Size" as unknown as BlobStringReply<"Size">),
42-
numberOfFilters: reply.get("Number of filters" as unknown as BlobStringReply<"Number of filters">),
43-
numberOfInsertedItems: reply.get('Number of items inserted' as unknown as BlobStringReply<'Number of items inserted'>),
44-
expansionRate: reply.get('Expansion rate' as unknown as BlobStringReply<'Expansion rate'>),
38+
capacity: reply.get('Capacity') as NumberReply,
39+
size: reply.get('Size') as NumberReply,
40+
numberOfFilters: reply.get('Number of filters') as NumberReply,
41+
numberOfInsertedItems: reply.get('Number of items inserted') as NumberReply,
42+
expansionRate: reply.get('Expansion rate') as NullReply | NumberReply
4543
}
46-
*/
4744
} else if (reply instanceof Array) {
48-
throw new Error("BF.INFO shouldn't be used with type mapping to map or array");
49-
/*
5045
return {
5146
capacity: reply[1],
5247
size: reply[3],
5348
numberOfFilters: reply[5],
5449
numberOfInsertedItems: reply[7],
5550
expansionRate: reply[9]
5651
}
57-
*/
5852
} else {
5953
return {
6054
capacity: reply["Capacity"],

packages/bloom/lib/commands/count-min-sketch/INFO.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export type CmsInfoReplyMap = TuplesToMapReply<[
77
]>;
88

99
export interface CmsInfoReply {
10-
width?: NumberReply;
11-
depth?: NumberReply;
12-
count?: NumberReply;
10+
width: NumberReply;
11+
depth: NumberReply;
12+
count: NumberReply;
1313
}
1414

1515
export default {
@@ -28,23 +28,18 @@ export default {
2828
},
2929
3(reply: UnwrapReply<CmsInfoReplyMap>): CmsInfoReply {
3030
if (reply instanceof Map) {
31-
throw new Error("CMS.INFO shouldn't be used with type mapping to map or array");
32-
/*
3331
return {
34-
width: reply.get("width" as unknown as BlobStringReply<'width'>),
35-
depth: reply.get("depth" as unknown as BlobStringReply<"depth">),
36-
count: reply.get("count" as unknown as BlobStringReply<"count">)
32+
width: reply.get('width') as NumberReply,
33+
depth: reply.get('depth') as NumberReply,
34+
count: reply.get('count') as NumberReply,
3735
}
38-
*/
36+
3937
} else if (reply instanceof Array) {
40-
throw new Error("CMS.INFO shouldn't be used with type mapping to map or array");
41-
/*
4238
return {
4339
width: reply[1],
4440
depth: reply[3],
4541
count: reply[5]
4642
}
47-
*/
4843
} else {
4944
return {
5045
width: reply['width'],

packages/bloom/lib/commands/cuckoo/INFO.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,17 @@ export default {
4343
},
4444
3: (reply: UnwrapReply<CfInfoReplyMap>): CfInfoReply => {
4545
if (reply instanceof Map) {
46-
throw new Error("CF.INFO shouldn't be used with type mapping to map or array");
47-
/*
4846
return {
49-
size: reply.get("Size" as unknown as BlobStringReply<"Size">)!,
50-
numberOfBuckets: reply.get('Number of buckets' as unknown as BlobStringReply<'Number of buckets'>)!,
51-
numberOfFilters: reply.get('Number of filters' as unknown as BlobStringReply<"Number of filters">)!,
52-
numberOfInsertedItems: reply.get('Number of items inserted' as unknown as BlobStringReply<'Number of items inserted'>)!,
53-
numberOfDeletedItems: reply.get('Number of items deleted' as unknown as BlobStringReply<'Number of items deleted'>)!,
54-
bucketSize: reply.get('Bucket size' as unknown as BlobStringReply<'Bucket size'>)!,
55-
expansionRate: reply.get('Expansion rate' as unknown as BlobStringReply<'Expansion rate'>)!,
56-
maxIteration: reply.get('Max iterations' as unknown as BlobStringReply<'Max iterations'>)!
47+
size: reply.get('Size') as NumberReply,
48+
numberOfBuckets: reply.get('Number of buckets') as NumberReply,
49+
numberOfFilters: reply.get('Number of filters') as NumberReply,
50+
numberOfInsertedItems: reply.get('Number of items inserted') as NumberReply,
51+
numberOfDeletedItems: reply.get('Number of items deleted') as NumberReply,
52+
bucketSize: reply.get('Bucket size') as NumberReply,
53+
expansionRate: reply.get('Expansion rate') as NumberReply,
54+
maxIteration: reply.get('Max iterations') as NumberReply
5755
}
58-
*/
5956
} else if (reply instanceof Array) {
60-
throw new Error("CF.INFO shouldn't be used with type mapping to map or array");
61-
/*
6257
return {
6358
size: reply[1],
6459
numberOfBuckets: reply[3],
@@ -69,7 +64,6 @@ export default {
6964
expansionRate: reply[13],
7065
maxIteration: reply[15]
7166
}
72-
*/
7367
} else {
7468
return {
7569
size: reply['Size'],

packages/bloom/lib/commands/t-digest/INFO.ts

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ export type TdInfoReplyMap = TuplesToMapReply<[
1313
]>;
1414

1515
export interface TdInfoReply {
16-
compression?: NumberReply;
17-
capacity?: NumberReply;
18-
mergedNodes?: NumberReply;
19-
unmergedNodes?: NumberReply;
20-
mergedWeight?: NumberReply;
21-
unmergedWeight?: NumberReply;
22-
observations?: NumberReply,
23-
totalCompression?: NumberReply;
24-
memoryUsage?: NumberReply;
16+
compression: NumberReply;
17+
capacity: NumberReply;
18+
mergedNodes: NumberReply;
19+
unmergedNodes: NumberReply;
20+
mergedWeight: NumberReply;
21+
unmergedWeight: NumberReply;
22+
observations: NumberReply,
23+
totalCompression: NumberReply;
24+
memoryUsage: NumberReply;
2525
}
2626

2727
export default {
@@ -46,23 +46,18 @@ export default {
4646
},
4747
3(reply: UnwrapReply<TdInfoReplyMap>): TdInfoReply {
4848
if (reply instanceof Map) {
49-
throw new Error("TDIGEST.INFO shouldn't be used with type mapping to map or array");
50-
/*
5149
return {
52-
compression: reply.get('Compression' as unknown as BlobStringReply<any>),
53-
capacity: reply.get('Capacity' as unknown as BlobStringReply<any>),
54-
mergedNodes: reply.get('Merged nodes' as unknown as BlobStringReply<any>),
55-
unmergedNodes: reply.get('Unmerged nodes' as unknown as BlobStringReply<any>),
56-
mergedWeight: reply.get('Merged weight' as unknown as BlobStringReply<any>),
57-
unmergedWeight: reply.get('Unmerged weight' as unknown as BlobStringReply<any>),
58-
observations: reply.get('Observations' as unknown as BlobStringReply<any>),
59-
totalCompression: reply.get('Total compressions' as unknown as BlobStringReply<any>),
60-
memoryUsage: reply.get('Memory usage' as unknown as BlobStringReply<any>)
50+
compression: reply.get('Compression') as NumberReply,
51+
capacity: reply.get('Capacity') as NumberReply,
52+
mergedNodes: reply.get('Merged nodes') as NumberReply,
53+
unmergedNodes: reply.get('Unmerged nodes') as NumberReply,
54+
mergedWeight: reply.get('Merged weight') as NumberReply,
55+
unmergedWeight: reply.get('Unmerged weight') as NumberReply,
56+
observations: reply.get('Observations') as NumberReply,
57+
totalCompression: reply.get('Total compressions') as NumberReply,
58+
memoryUsage: reply.get('Memory usage') as NumberReply
6159
};
62-
*/
6360
} else if (reply instanceof Array) {
64-
throw new Error("TDIGEST.INFO shouldn't be used with type mapping to map or array");
65-
/*
6661
return {
6762
compression: reply[1],
6863
capacity: reply[3],
@@ -74,7 +69,6 @@ export default {
7469
totalCompression: reply[15],
7570
memoryUsage: reply[17]
7671
};
77-
*/
7872
} else {
7973
return {
8074
compression: reply['Compression'],

packages/bloom/lib/commands/top-k/INFO.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,19 @@ export default {
3131
},
3232
3: (reply: UnwrapReply<TopKInfoReplyMap>): TkInfoReply => {
3333
if (reply instanceof Map) {
34-
throw new Error("TOPK.INFO shouldn't be used with type mapping to map or array");
35-
/*
3634
return {
37-
k: reply.get('k' as unknown as BlobStringReply<'k'>) as NumberReply,
38-
width: reply.get('width' as unknown as BlobStringReply<'width'>) as NumberReply,
39-
depth: reply.get('depth' as unknown as BlobStringReply<'depth'>) as NumberReply,
40-
decay: Number(reply.get('decay' as unknown as BlobStringReply<'decay'>) as DoubleReply)
35+
k: reply.get('k') as NumberReply,
36+
width: reply.get('width') as NumberReply,
37+
depth: reply.get('depth') as NumberReply,
38+
decay: Number(reply.get('decay') as DoubleReply)
4139
};
42-
*/
4340
} else if (reply instanceof Array) {
44-
throw new Error("TOPK.INFO shouldn't be used with type mapping to map or array");
45-
/*
4641
return {
4742
k: reply[1],
4843
width: reply[3],
4944
depth: reply[5],
5045
decay: Number(reply[7])
5146
};
52-
*/
5347
} else {
5448
return {
5549
k: reply['k'],

0 commit comments

Comments
 (0)