Skip to content

Commit

Permalink
perf: remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
AElfBourneShi committed Sep 20, 2024
1 parent 530234d commit a0f10e3
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@ public class ElasticsearchCollectionNameProvider<TEntity> : CollectionNameProvid
{
private readonly IElasticIndexService _elasticIndexService;
private readonly IShardingKeyProvider<TEntity> _shardingKeyProvider;
// private readonly ICollectionRouteKeyProvider<TEntity> _collectionRouteKeyProvider;
private readonly AElfEntityMappingOptions _entityMappingOptions;
private readonly ILogger<ElasticsearchCollectionNameProvider<TEntity>> _logger;

public ElasticsearchCollectionNameProvider(IShardingKeyProvider<TEntity> shardingKeyProvider,
IElasticIndexService elasticIndexService,
// ICollectionRouteKeyProvider<TEntity> collectionRouteKeyProvider,
IOptions<AElfEntityMappingOptions> entityMappingOptions,
ILogger<ElasticsearchCollectionNameProvider<TEntity>> logger)
{
_elasticIndexService = elasticIndexService;
_shardingKeyProvider = shardingKeyProvider;
// _collectionRouteKeyProvider = collectionRouteKeyProvider;
_entityMappingOptions = entityMappingOptions.Value;
_logger = logger;
}
Expand All @@ -42,7 +39,6 @@ protected override async Task<List<string>> GetCollectionNameAsync(List<Collecti
var shardKeyCollectionNames = await _shardingKeyProvider.GetCollectionNameAsync(conditions);
if (shardKeyCollectionNames.IsNullOrEmpty())
{
// return await _collectionRouteKeyProvider.GetCollectionNameAsync(conditions);
return new List<string> { GetDefaultCollectionName() };

Check warning on line 42 in src/AElf.EntityMapping.Elasticsearch/ElasticsearchCollectionNameProvider.cs

View check run for this annotation

Codecov / codecov/patch

src/AElf.EntityMapping.Elasticsearch/ElasticsearchCollectionNameProvider.cs#L42

Added line #L42 was not covered by tests
}

Expand Down Expand Up @@ -72,9 +68,7 @@ protected override async Task<List<string>> GetCollectionNameByEntityAsync(List<

protected override async Task<string> GetCollectionNameByIdAsync<TKey>(TKey id)
{
// if (!_shardingKeyProvider.IsShardingCollection())
return GetDefaultCollectionName();
// return await _collectionRouteKeyProvider.GetCollectionNameAsync(id.ToString());
return GetDefaultCollectionName();
}

protected override string FormatCollectionName(string name)
Expand Down
7 changes: 0 additions & 7 deletions src/AElf.EntityMapping.Elasticsearch/IndexNameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,4 @@ public static string GetDefaultFullIndexName(Type type,string collectionPrefix)
: $"{collectionPrefix.ToLower()}.{GetDefaultIndexName(type)}";
return fullIndexName;
}
public static string GetCollectionRouteKeyIndexName(Type type, string fieldName,string collectionPrefix)
{
var routeIndexName= collectionPrefix.IsNullOrWhiteSpace()
? $"route.{type.Name.ToLower()}.{fieldName.ToLower()}"
: $"{collectionPrefix.ToLower()}.route.{type.Name.ToLower()}.{fieldName.ToLower()}";
return routeIndexName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ Task CreateIndexAsync(string indexName, Type indexEntityType, int shard = 1, int
Task CreateIndexTemplateAsync(string indexTemplateName, string indexName, Type indexEntityType, int numberOfShards,
int numberOfReplicas);

// Task CreateCollectionRouteKeyIndexAsync(Type indexEntityType, int numberOfShards,
// int numberOfReplicas);
Task DeleteIndexAsync(string collectionName = null, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,9 @@ namespace AElf.EntityMapping.Elasticsearch;
public class ElasticIndexServiceTests: AElfElasticsearchTestBase
{
private readonly IElasticIndexService _elasticIndexService;
// private readonly IDistributedCache<List<CollectionRouteKeyItem<BlockIndex>>> _indexMarkFieldCache;

public ElasticIndexServiceTests()
{
_elasticIndexService = GetRequiredService<IElasticIndexService>();
// _indexMarkFieldCache= GetRequiredService<IDistributedCache<List<CollectionRouteKeyItem<BlockIndex>>>>();
}

// [Fact]
// public async Task InitializeIndexMarkedField_Test()
// {
// await _elasticIndexService.InitializeCollectionRouteKeyCacheAsync(typeof(BlockIndex));
// var cacheName = _elasticIndexService.GetCollectionRouteKeyCacheName(typeof(BlockIndex));
// var collectionMarkFieldList = await _indexMarkFieldCache.GetAsync(cacheName);
// collectionMarkFieldList.ShouldNotBeNull();
// collectionMarkFieldList.Count.ShouldBeGreaterThan(1);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class BlockBase : AElfIndexerEntity<string>, IBlockchainData
[ShardPropertyAttributes("ChainId", 1)]
public string ChainId { get; set; }

// [CollectionRouteKey]
[Keyword] public string BlockHash { get; set; }

[ShardPropertyAttributes("BlockHeight", 3)]
Expand Down

0 comments on commit a0f10e3

Please sign in to comment.