Exemple #1
0
 @Override
 protected void setupLocal() {
   // Precompute the first input chunk index and start row inside that chunk for this partition
   Vec anyInVec = _srcVecs[0];
   long[] partSizes = Utils.partitione(anyInVec.length(), _ratios);
   long pnrows = 0;
   for (int p = 0; p < _partIdx; p++) pnrows += partSizes[p];
   long[] espc = anyInVec._espc;
   while (_pcidx < espc.length - 1 && (pnrows -= (espc[_pcidx + 1] - espc[_pcidx])) > 0)
     _pcidx++;
   assert pnrows <= 0;
   _psrow = (int) (pnrows + espc[_pcidx + 1] - espc[_pcidx]);
 }
Exemple #2
0
 // The task computes ESPC per split
 static long[ /*nsplits*/][ /*nchunks*/] computeEspcPerSplit(
     long[] espc, long len, float[] ratios) {
   assert espc.length > 0 && espc[0] == 0;
   assert espc[espc.length - 1] == len;
   long[] partSizes = Utils.partitione(len, ratios); // Split of whole vector
   int nparts = ratios.length + 1;
   long[][] r = new long[nparts][espc.length]; // espc for each partition
   long nrows = 0;
   long start = 0;
   for (int p = 0, c = 0; p < nparts; p++) {
     int nc = 0; // number of chunks for this partition
     for (; c < espc.length - 1 && (espc[c + 1] - start) <= partSizes[p]; c++)
       r[p][++nc] = espc[c + 1] - start;
     if (r[p][nc] < partSizes[p])
       r[p][++nc] = partSizes[p]; // last item in espc contains number of rows
     r[p] = Arrays.copyOf(r[p], nc + 1);
     // Transfer rest of lines to the next part
     nrows = nrows - partSizes[p];
     start += partSizes[p];
   }
   return r;
 }