private void InitializeMatrix(int rows, int cols) { _mDimensions = new MatrixDimensions(rows, cols); _weightMatrix = new long[rows, cols]; _idMatrix = new int[rows, cols]; _weightPercentMatrix = new long[rows, 2]; int nLoopCount = 0; for (int i = 0; i < rows; i++) { long rowSum = 0; for (int j = 0; j < cols; j++) { if (nLoopCount < _filteredWeightIdList.Count) { WeightIdPair tmpPair = (WeightIdPair)_filteredWeightIdList[nLoopCount]; _weightMatrix[i,j] = tmpPair.Weight; _idMatrix[i,j] = tmpPair.BucketId; rowSum += tmpPair.Weight; } else { _weightMatrix[i,j] = -1; _idMatrix[i,j] = -1; } nLoopCount++; } _weightPercentMatrix[i, 1] = rowSum; //populate weightPercent Matrix while populating the weight and Id matrices. _totalWeight += rowSum; } //Here I am calculationg sum along with %age weight each row is keeping in. This would help while finding the right // set of buckets to be given off. for (int i = 0; i < _mDimensions.Rows; i++) { _weightPercentMatrix[i, 0] = Convert.ToInt64(Math.Ceiling(((double)_weightPercentMatrix[i, 1] / (double)_totalWeight) * 100)); } //Calculate how much %age weight THIS NODE is keeping w.r.t overall cluster. _percentWeightOfCluster = Convert.ToInt32(((_totalWeight * 100) / _distData.CacheDataSum)); // Although buckets are sacrificed equally, but data is not. // Every node would share w.r.t the percentage that it is keeping in the Cluster. // If a node is keeping 50% share of the data, it would give away 50% of the required weight for the coming node. _weightToSacrifice = Convert.ToInt64(Math.Ceiling(((double)_distData.WeightPerNode * (double)_percentWeightOfCluster) / 100)); _percentWeightToSacrifice = Convert.ToInt32(Math.Ceiling(((double)_weightToSacrifice /(double)_totalWeight) * 100)); }
private void InitializeMatrix(int rows, int cols) { _mDimensions = new MatrixDimensions(rows, cols); _weightMatrix = new long[rows, cols]; _idMatrix = new int[rows, cols]; _weightPercentMatrix = new long[rows, 2]; int nLoopCount = 0; for (int i = 0; i < rows; i++) { long rowSum = 0; for (int j = 0; j < cols; j++) { if (nLoopCount < _filteredWeightIdList.Count) { WeightIdPair tmpPair = (WeightIdPair)_filteredWeightIdList[nLoopCount]; _weightMatrix[i, j] = tmpPair.Weight; _idMatrix[i, j] = tmpPair.BucketId; rowSum += tmpPair.Weight; } else { _weightMatrix[i, j] = -1; _idMatrix[i, j] = -1; } nLoopCount++; } _weightPercentMatrix[i, 1] = rowSum; //populate weightPercent Matrix while populating the weight and Id matrices. _totalWeight += rowSum; } //Here I am calculating sum along with %age weight each row is keeping in. This would help while finding the right // set of buckets to be given off. for (int i = 0; i < _mDimensions.Rows; i++) { _weightPercentMatrix[i, 0] = Convert.ToInt64(Math.Ceiling(((double)_weightPercentMatrix[i, 1] / (double)_totalWeight) * 100)); } //Calculate how much %age weight THIS NODE is keeping w.r.t overall cluster. _percentWeightOfCluster = Convert.ToInt32(((_totalWeight * 100) / _distData.CacheDataSum)); // Although buckets are sacrificed equally, but data is not. // Every node would share w.r.t the percentage that it is keeping in the Cluster. // If a node is keeping 50% share of the data, it would give away 50% of the required weight for the coming node. _weightToSacrifice = Convert.ToInt64(Math.Ceiling(((double)_distData.WeightPerNode * (double)_percentWeightOfCluster) / 100)); _percentWeightToSacrifice = Convert.ToInt32(Math.Ceiling(((double)_weightToSacrifice / (double)_totalWeight) * 100)); }