mirror of https://github.com/citusdata/citus.git
Apply final code review feedback
- Fix o(n^2) loop to o(n) - Collapse two if statements into a single one - Some coding conventions feedbackpull/446/head
parent
c4b783b70b
commit
108114ab99
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue