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/446/head
Onder Kalaci 2016-04-27 10:36:03 +03:00
parent c4b783b70b
commit 108114ab99
3 changed files with 10 additions and 13 deletions

View File

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

View File

@ -1965,9 +1965,9 @@ SubquerySqlTaskList(Job *job)
List *shardIntervalList = LoadShardIntervalList(relationId);
List *finalShardIntervalList = NIL;
ListCell *fragmentCombinationCell = NULL;
ListCell *shardIntervalCell = NULL;
uint32 tableId = rangeTableIndex + 1; /* tableId starts from 1 */
uint32 finalShardCount = 0;
uint32 shardIndex = 0;
if (opExpressionList != NIL)
{
@ -1991,9 +1991,9 @@ SubquerySqlTaskList(Job *job)
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);
shardFragment->fragmentReference = &(shardInterval->shardId);

View File

@ -321,14 +321,6 @@ LookupDistTableCacheEntry(Oid relationId)
shardIntervalArrayLength,
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 */
hasUninitializedShardInterval =
HasUninitializedShardInterval(sortedShardIntervalArray, shardIntervalArrayLength);
@ -347,6 +339,11 @@ LookupDistTableCacheEntry(Oid relationId)
sizeof(FmgrInfo));
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);