code: private static long sumChunksLength(int[] chunkIds, Vec vec, Vec weightsVector, int[] chunkLengths) {
          for (int i = 0; i < chunkIds.length; i++) {
              final int chunk = chunkIds[i];
              chunkLengths[i] = vec.chunkLen(chunk);
              if (weightsVector == null)
                  continue;
  
              Chunk weightVecChunk = weightsVector.chunkForChunkIdx(chunk);
              if (weightVecChunk.atd(0) == 0) chunkLengths[i]--;
              int nzIndex = 0;
              do {
                  nzIndex = weightVecChunk.nextNZ(nzIndex, true);
                  if (nzIndex < 0 || nzIndex >= weightVecChunk._len) break;
                  if (weightVecChunk.atd(nzIndex) == 0) chunkLengths[i]--;
              } while (true);
          }
  
          long totalChunkLength = 0;
          for (int cl : chunkLengths) {
              totalChunkLength += cl;
          }
          return totalChunkLength;
      }
docs: Counts a total sum of chunks inside a vector. Only chunks present in chunkIds are considered.
  
  @param chunkIds Chunk identifier of a vector
  @param vec      Vector containing given chunk identifiers
  @param weightsVector Vector with row weights, possibly null
  @return A sum of chunk lengths. Possibly zero, if there are no chunks or the chunks are empty.