Addressing open comments

pull/6029/head
Nitish Upreti 2022-06-28 16:45:26 -07:00
parent ebd0e9a617
commit 4fcdff53ae
3 changed files with 51 additions and 34 deletions

View File

@ -575,6 +575,22 @@ DoSplitCopy(WorkerNode *sourceShardNode, List *sourceColocatedShardIntervalList,
* 'sourceShardSplitInterval' : Source shard interval to be copied.
* 'splitChildrenShardINnerIntervalList' : List of shard intervals for split children.
* 'destinationWorkerNodesList' : List of workers for split children placement.
* Here is an example of a 2 way split copy :
* SELECT * from worker_split_copy(
* 81060000, -- source shard id to split copy
* ARRAY[
* -- split copy info for split children 1
* ROW(81060015, -- destination shard id
* -2147483648, -- split range begin
* 1073741823, --split range end
* 10 -- worker node id)::citus.split_copy_info,
* -- split copy info for split children 2
* ROW(81060016, --destination shard id
* 1073741824, --split range begin
* 2147483647, --split range end
* 11 -- workef node id)::citus.split_copy_info
* ]
* );
*/
static StringInfo
CreateSplitCopyCommand(ShardInterval *sourceShardSplitInterval,

View File

@ -135,6 +135,36 @@ ConnectToRemoteAndStartCopy(ShardCopyDestReceiver *copyDest)
}
/*
* CreateShardCopyDestReceiver creates a DestReceiver that copies into
* a destinationShardFullyQualifiedName on destinationNodeId.
*/
DestReceiver *
CreateShardCopyDestReceiver(EState *executorState,
List *destinationShardFullyQualifiedName,
uint32_t destinationNodeId)
{
ShardCopyDestReceiver *copyDest = (ShardCopyDestReceiver *) palloc0(
sizeof(ShardCopyDestReceiver));
/* set up the DestReceiver function pointers */
copyDest->pub.receiveSlot = ShardCopyDestReceiverReceive;
copyDest->pub.rStartup = ShardCopyDestReceiverStartup;
copyDest->pub.rShutdown = ShardCopyDestReceiverShutdown;
copyDest->pub.rDestroy = ShardCopyDestReceiverDestroy;
copyDest->pub.mydest = DestCopyOut;
copyDest->executorState = executorState;
copyDest->destinationNodeId = destinationNodeId;
copyDest->destinationShardFullyQualifiedName = destinationShardFullyQualifiedName;
copyDest->tuplesSent = 0;
copyDest->connection = NULL;
copyDest->useLocalCopy = CanUseLocalCopy(destinationNodeId);
return (DestReceiver *) copyDest;
}
/*
* ShardCopyDestReceiverReceive implements the receiveSlot function of
* ShardCopyDestReceiver. It takes a TupleTableSlot and sends the contents to
@ -304,36 +334,6 @@ ShardCopyDestReceiverShutdown(DestReceiver *dest)
}
/*
* CreateShardCopyDestReceiver creates a DestReceiver that copies into
* a destinationShardFullyQualifiedName on destinationNodeId.
*/
DestReceiver *
CreateShardCopyDestReceiver(EState *executorState,
List *destinationShardFullyQualifiedName,
uint32_t destinationNodeId)
{
ShardCopyDestReceiver *copyDest = (ShardCopyDestReceiver *) palloc0(
sizeof(ShardCopyDestReceiver));
/* set up the DestReceiver function pointers */
copyDest->pub.receiveSlot = ShardCopyDestReceiverReceive;
copyDest->pub.rStartup = ShardCopyDestReceiverStartup;
copyDest->pub.rShutdown = ShardCopyDestReceiverShutdown;
copyDest->pub.rDestroy = ShardCopyDestReceiverDestroy;
copyDest->pub.mydest = DestCopyOut;
copyDest->executorState = executorState;
copyDest->destinationNodeId = destinationNodeId;
copyDest->destinationShardFullyQualifiedName = destinationShardFullyQualifiedName;
copyDest->tuplesSent = 0;
copyDest->connection = NULL;
copyDest->useLocalCopy = CanUseLocalCopy(destinationNodeId);
return (DestReceiver *) copyDest;
}
/*
* ShardCopyDestReceiverDestroy frees the DestReceiver.
*/

View File

@ -60,9 +60,11 @@ worker_split_copy(PG_FUNCTION_ARGS)
(errmsg("Shard Copy Info cannot have null values.")));
}
const int slice_ndim = 0;
ArrayMetaState *mState = NULL;
ArrayIterator copyInfo_iterator = array_create_iterator(splitCopyInfoArrayObject,
0 /* slice_ndim */,
NULL /* mState */);
slice_ndim,
mState);
Datum copyInfoDatum = 0;
bool isnull = false;
List *splitCopyInfoList = NULL;
@ -230,10 +232,9 @@ CreatePartitionedSplitCopyDestReceiver(EState *estate,
ArrayType *minValuesArray = NULL;
ArrayType *maxValuesArray = NULL;
BuildMinMaxRangeArrays(splitCopyInfoList, &minValuesArray, &maxValuesArray);
char partitionMethod = PartitionMethodViaCatalog(
shardIntervalToSplitCopy->relationId);
CitusTableCacheEntry *cacheEntry = GetCitusTableCacheEntry(
shardIntervalToSplitCopy->relationId);
char partitionMethod = cacheEntry->partitionMethod;
Var *partitionColumn = cacheEntry->partitionColumn;
CitusTableCacheEntry *shardSearchInfo =