Skip to content

Commit 869189a

Browse files
#RI-4566 - update recommendation conditions (#2129) (#2131)
* #RI-4566 - update recommendation conditions
1 parent b9d02ef commit 869189a

File tree

18 files changed

+306
-255
lines changed

18 files changed

+306
-255
lines changed

redisinsight/api/src/common/constants/recommendations.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ export const COMBINE_SMALL_STRINGS_TO_HASHES_RECOMMENDATION_MEMORY = 200;
1414
export const USE_SMALLER_KEYS_RECOMMENDATION_TOTAL = 1_000_000;
1515
export const COMPRESS_HASH_FIELD_NAMES_RECOMMENDATION_LENGTH = 1000;
1616
export const COMPRESSION_FOR_LIST_RECOMMENDATION_LENGTH = 1000;
17-
export const BIG_SETS_RECOMMENDATION_LENGTH = 100_000;
17+
export const BIG_SETS_RECOMMENDATION_LENGTH = 1_000;
1818
export const BIG_AMOUNT_OF_CONNECTED_CLIENTS_RECOMMENDATION_CLIENTS = 100;
19-
export const BIG_STRINGS_RECOMMENDATION_MEMORY = 1_000_000;
19+
export const BIG_STRINGS_RECOMMENDATION_MEMORY = 100_000;
2020
export const RTS_RECOMMENDATION_PERCENTAGE = 99;
2121
export const SEARCH_INDEXES_RECOMMENDATION_KEYS_FOR_CHECK = 100;
2222
export const REDIS_VERSION_RECOMMENDATION_VERSION = '6';
23-
export const COMBINE_SMALL_STRINGS_TO_HASHES_RECOMMENDATION_KEYS_COUNT = 50;
24-
export const INTEGERS_IN_SET_RECOMMENDATION_MEMBERS_FOR_CHECK = 50;
23+
export const COMBINE_SMALL_STRINGS_TO_HASHES_RECOMMENDATION_KEYS_COUNT = 10;
2524
export const SEARCH_HASH_RECOMMENDATION_KEYS_FOR_CHECK = 50;
2625
export const SEARCH_HASH_RECOMMENDATION_KEYS_LENGTH = 2;

redisinsight/api/src/constants/recommendations.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const RECOMMENDATION_NAMES = Object.freeze({
1717
REDIS_VERSION: 'redisVersion',
1818
SEARCH_INDEXES: 'searchIndexes',
1919
SEARCH_JSON: 'searchJSON',
20-
INTEGERS_IN_SET: 'integersInSets',
2120
STRING_TO_JSON: 'stringToJson',
2221
SEARCH_VISUALIZATION: 'searchVisualization',
2322
SEARCH_HASH: 'searchHash',
@@ -38,6 +37,5 @@ export const REDIS_STACK = [
3837
RECOMMENDATION_NAMES.REDIS_VERSION,
3938
RECOMMENDATION_NAMES.SEARCH_INDEXES,
4039
RECOMMENDATION_NAMES.SEARCH_JSON,
41-
RECOMMENDATION_NAMES.INTEGERS_IN_SET,
4240
RECOMMENDATION_NAMES.STRING_TO_JSON,
4341
]

redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
mockRedisNoPermError,
1313
mockRedisWrongTypeError,
1414
mockBrowserClientMetadata,
15-
mockDatabaseRecommendationService,
1615
} from 'src/__mocks__';
1716
import { ReplyError } from 'src/models';
1817
import {
@@ -24,8 +23,6 @@ import {
2423
mockGetSetMembersDto, mockGetSetMembersResponse,
2524
mockSetMembers,
2625
} from 'src/modules/browser/__mocks__';
27-
import { DatabaseRecommendationService } from 'src/modules/database-recommendation/database-recommendation.service';
28-
import { RECOMMENDATION_NAMES } from 'src/constants';
2926
import { SetBusinessService } from './set-business.service';
3027
import {
3128
CreateSetWithExpireDto,
@@ -39,7 +36,6 @@ nodeClient.isCluster = false;
3936
describe('SetBusinessService', () => {
4037
let service: SetBusinessService;
4138
let browserTool;
42-
let recommendationService;
4339

4440
beforeEach(async () => {
4541
jest.clearAllMocks();
@@ -51,16 +47,11 @@ describe('SetBusinessService', () => {
5147
provide: BrowserToolService,
5248
useFactory: mockRedisConsumer,
5349
},
54-
{
55-
provide: DatabaseRecommendationService,
56-
useFactory: mockDatabaseRecommendationService,
57-
},
5850
],
5951
}).compile();
6052

6153
service = module.get<SetBusinessService>(SetBusinessService);
6254
browserTool = module.get<BrowserToolService>(BrowserToolService);
63-
recommendationService = module.get<DatabaseRecommendationService>(DatabaseRecommendationService);
6455
});
6556

6657
describe('createSet', () => {
@@ -326,32 +317,6 @@ describe('SetBusinessService', () => {
326317
service.getMembers(mockBrowserClientMetadata, mockGetSetMembersDto),
327318
).rejects.toThrow(ForbiddenException);
328319
});
329-
it('should call recommendationService', async () => {
330-
when(browserTool.execCommand)
331-
.calledWith(
332-
mockBrowserClientMetadata,
333-
BrowserToolSetCommands.SScan,
334-
expect.anything(),
335-
)
336-
.mockResolvedValue([Buffer.from('0'), mockSetMembers]);
337-
338-
const result = await service.getMembers(
339-
mockBrowserClientMetadata,
340-
mockGetSetMembersDto,
341-
);
342-
expect(recommendationService.check).toBeCalledWith(
343-
mockBrowserClientMetadata,
344-
RECOMMENDATION_NAMES.INTEGERS_IN_SET,
345-
{
346-
members: result.members,
347-
keyName: result.keyName,
348-
client: nodeClient,
349-
databaseId: mockBrowserClientMetadata.databaseId,
350-
},
351-
);
352-
353-
expect(recommendationService.check).toBeCalledTimes(1);
354-
});
355320
});
356321

357322
describe('addMembers', () => {

redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Logger,
66
NotFoundException,
77
} from '@nestjs/common';
8-
import { RECOMMENDATION_NAMES, RedisErrorCodes } from 'src/constants';
8+
import { RedisErrorCodes } from 'src/constants';
99
import ERROR_MESSAGES from 'src/constants/error-messages';
1010
import config from 'src/utils/config';
1111
import {
@@ -17,7 +17,6 @@ import {
1717
BrowserToolKeysCommands,
1818
BrowserToolSetCommands,
1919
} from 'src/modules/browser/constants/browser-tool-commands';
20-
import { DatabaseRecommendationService } from 'src/modules/database-recommendation/database-recommendation.service';
2120
import { plainToClass } from 'class-transformer';
2221
import {
2322
AddMembersToSetDto,
@@ -38,7 +37,6 @@ export class SetBusinessService {
3837

3938
constructor(
4039
private browserTool: BrowserToolService,
41-
private recommendationService: DatabaseRecommendationService,
4240
) {}
4341

4442
public async createSet(
@@ -81,7 +79,6 @@ export class SetBusinessService {
8179
clientMetadata: ClientMetadata,
8280
dto: GetSetMembersDto,
8381
): Promise<GetSetMembersResponse> {
84-
const client = await this.browserTool.getRedisClient(clientMetadata);
8582
this.logger.log('Getting members of the Set data type stored at key.');
8683
const { keyName } = dto;
8784
let result: GetSetMembersResponse = {
@@ -120,16 +117,6 @@ export class SetBusinessService {
120117
const scanResult = await this.scanSet(clientMetadata, dto);
121118
result = { ...result, ...scanResult };
122119
}
123-
this.recommendationService.check(
124-
clientMetadata,
125-
RECOMMENDATION_NAMES.INTEGERS_IN_SET,
126-
{
127-
members: result.members,
128-
keyName,
129-
client,
130-
databaseId: clientMetadata.databaseId,
131-
},
132-
);
133120
this.logger.log('Succeed to get members of the Set data type.');
134121
return plainToClass(GetSetMembersResponse, result);
135122
} catch (error) {

redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
SearchJSONStrategy,
1010
BigSetStrategy,
1111
RTSStrategy,
12-
IntegersInSetStrategy,
1312
AvoidLogicalDatabasesStrategy,
1413
ShardHashStrategy,
1514
StringToJsonStrategy,
@@ -44,7 +43,6 @@ describe('RecommendationProvider', () => {
4443
[RECOMMENDATION_NAMES.REDIS_VERSION, new RedisVersionStrategy()],
4544
[RECOMMENDATION_NAMES.BIG_SETS, new BigSetStrategy()],
4645
[RECOMMENDATION_NAMES.RTS, new RTSStrategy()],
47-
[RECOMMENDATION_NAMES.INTEGERS_IN_SET, new IntegersInSetStrategy()],
4846
[RECOMMENDATION_NAMES.AVOID_LOGICAL_DATABASES, new AvoidLogicalDatabasesStrategy()],
4947
[RECOMMENDATION_NAMES.BIG_HASHES, new ShardHashStrategy()],
5048
[RECOMMENDATION_NAMES.STRING_TO_JSON, new StringToJsonStrategy()],

redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
SearchJSONStrategy,
1010
BigSetStrategy,
1111
RTSStrategy,
12-
IntegersInSetStrategy,
1312
AvoidLogicalDatabasesStrategy,
1413
ShardHashStrategy,
1514
StringToJsonStrategy,
@@ -35,7 +34,6 @@ export class RecommendationProvider {
3534
this.strategies.set(RECOMMENDATION_NAMES.SEARCH_JSON, new SearchJSONStrategy(databaseService));
3635
this.strategies.set(RECOMMENDATION_NAMES.BIG_SETS, new BigSetStrategy());
3736
this.strategies.set(RECOMMENDATION_NAMES.RTS, new RTSStrategy());
38-
this.strategies.set(RECOMMENDATION_NAMES.INTEGERS_IN_SET, new IntegersInSetStrategy());
3937
this.strategies.set(RECOMMENDATION_NAMES.AVOID_LOGICAL_DATABASES, new AvoidLogicalDatabasesStrategy());
4038
this.strategies.set(RECOMMENDATION_NAMES.BIG_HASHES, new ShardHashStrategy());
4139
this.strategies.set(RECOMMENDATION_NAMES.STRING_TO_JSON, new StringToJsonStrategy());

redisinsight/api/src/modules/database-recommendation/scanner/strategies/big-set.strategy.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const mockSetInfo: GetKeyInfoResponse = {
66
type: 'set',
77
ttl: -1,
88
size: 1,
9-
length: 100_000,
9+
length: 1_000,
1010
};
1111

1212
const mockBigSetInfo: GetKeyInfoResponse = {
1313
name: Buffer.from('string2'),
1414
type: 'set',
1515
ttl: -1,
1616
size: 1,
17-
length: 100_001,
17+
length: 1_001,
1818
};
1919

2020
const mockHashInfo: GetKeyInfoResponse = {
@@ -33,15 +33,15 @@ describe('BigSetStrategy', () => {
3333
});
3434

3535
describe('isRecommendationReached', () => {
36-
it('should return false when set length < 100 000', async () => {
36+
it('should return false when set length < 1 000', async () => {
3737
expect(await strategy.isRecommendationReached(mockSetInfo)).toEqual({ isReached: false });
3838
});
3939

4040
it('should return false when not set key', async () => {
4141
expect(await strategy.isRecommendationReached(mockHashInfo)).toEqual({ isReached: false });
4242
});
4343

44-
it('should return true when set length > 100 000', async () => {
44+
it('should return true when set length > 1 000', async () => {
4545
expect(await strategy.isRecommendationReached(mockBigSetInfo))
4646
.toEqual({ isReached: true, params: { keys: [mockBigSetInfo.name] } });
4747
});

redisinsight/api/src/modules/database-recommendation/scanner/strategies/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export * from './search-JSON.strategy';
55
export * from './big-set.strategy';
66
export * from './rts.strategy';
77
export * from './avoid-logical-databases.strategy';
8-
export * from './integer-in-set.strategy';
98
export * from './shard-hash.strategy';
109
export * from './string-to-json.strategy';
1110
export * from './search-visualization.strategy';

redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.spec.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)