fix: make dnode sort stable
This commit is contained in:
parent
126d884ab3
commit
e878f1dcba
|
@ -426,8 +426,12 @@ static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return
|
||||||
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
|
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
|
||||||
float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes;
|
float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes;
|
||||||
float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes;
|
float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes;
|
||||||
|
if (d1Score == d2Score) {
|
||||||
|
return pDnode2->id - pDnode1->id;
|
||||||
|
} else {
|
||||||
return d1Score >= d2Score ? 1 : 0;
|
return d1Score >= d2Score ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void mndSortVnodeGid(SVgObj *pVgroup) {
|
void mndSortVnodeGid(SVgObj *pVgroup) {
|
||||||
for (int32_t i = 0; i < pVgroup->replica; ++i) {
|
for (int32_t i = 0; i < pVgroup->replica; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue