Apply final code review feedback

- Fix o(n^2) loop to o(n)
- Collapse two if statements into a single one
- Some coding conventions feedback
pull/1938/head
Onder Kalaci 2016-04-27 10:36:03 +03:00
parent 876730ad73
commit c763d7492c
3 changed files with 10 additions and 13 deletions

View File

@ -2311,8 +2311,8 @@ TablePartitioningSupportsDistinct(List *tableNodeList, MultiExtendedOp *opNode,
*/ */
partitionMethod = PartitionMethod(relationId); partitionMethod = PartitionMethod(relationId);
if (partitionMethod == DISTRIBUTE_BY_RANGE if (partitionMethod == DISTRIBUTE_BY_RANGE ||
|| partitionMethod == DISTRIBUTE_BY_HASH) partitionMethod == DISTRIBUTE_BY_HASH)
{ {
Var *tablePartitionColumn = tableNode->partitionColumn; Var *tablePartitionColumn = tableNode->partitionColumn;
bool groupedByPartitionColumn = false; bool groupedByPartitionColumn = false;

View File

@ -1965,9 +1965,9 @@ SubquerySqlTaskList(Job *job)
List *shardIntervalList = LoadShardIntervalList(relationId); List *shardIntervalList = LoadShardIntervalList(relationId);
List *finalShardIntervalList = NIL; List *finalShardIntervalList = NIL;
ListCell *fragmentCombinationCell = NULL; ListCell *fragmentCombinationCell = NULL;
ListCell *shardIntervalCell = NULL;
uint32 tableId = rangeTableIndex + 1; /* tableId starts from 1 */ uint32 tableId = rangeTableIndex + 1; /* tableId starts from 1 */
uint32 finalShardCount = 0; uint32 finalShardCount = 0;
uint32 shardIndex = 0;
if (opExpressionList != NIL) if (opExpressionList != NIL)
{ {
@ -1991,9 +1991,9 @@ SubquerySqlTaskList(Job *job)
fragmentCombinationCell = list_head(fragmentCombinationList); fragmentCombinationCell = list_head(fragmentCombinationList);
for (shardIndex = 0; shardIndex < finalShardCount; shardIndex++) foreach(shardIntervalCell, finalShardIntervalList)
{ {
ShardInterval *shardInterval = list_nth(finalShardIntervalList, shardIndex); ShardInterval *shardInterval = (ShardInterval *) lfirst(shardIntervalCell);
RangeTableFragment *shardFragment = palloc0(fragmentSize); RangeTableFragment *shardFragment = palloc0(fragmentSize);
shardFragment->fragmentReference = &(shardInterval->shardId); shardFragment->fragmentReference = &(shardInterval->shardId);

View File

@ -321,14 +321,6 @@ LookupDistTableCacheEntry(Oid relationId)
shardIntervalArrayLength, shardIntervalArrayLength,
shardIntervalCompareFunction); shardIntervalCompareFunction);
/* check the shard distribution for hash partitioned tables */
if (partitionMethod == DISTRIBUTE_BY_HASH)
{
hasUniformHashDistribution =
HasUniformHashDistribution(sortedShardIntervalArray,
shardIntervalArrayLength);
}
/* check if there exists any shard intervals with no min/max values */ /* check if there exists any shard intervals with no min/max values */
hasUninitializedShardInterval = hasUninitializedShardInterval =
HasUninitializedShardInterval(sortedShardIntervalArray, shardIntervalArrayLength); HasUninitializedShardInterval(sortedShardIntervalArray, shardIntervalArrayLength);
@ -347,6 +339,11 @@ LookupDistTableCacheEntry(Oid relationId)
sizeof(FmgrInfo)); sizeof(FmgrInfo));
fmgr_info_copy(hashFunction, &(typeEntry->hash_proc_finfo), CacheMemoryContext); fmgr_info_copy(hashFunction, &(typeEntry->hash_proc_finfo), CacheMemoryContext);
/* check the shard distribution for hash partitioned tables */
hasUniformHashDistribution =
HasUniformHashDistribution(sortedShardIntervalArray,
shardIntervalArrayLength);
} }
cacheEntry = hash_search(DistTableCacheHash, hashKey, HASH_ENTER, NULL); cacheEntry = hash_search(DistTableCacheHash, hashKey, HASH_ENTER, NULL);