code: private int[] calculateOffsets(final int[] lengths) {
          int[] offsets = new int[lengths.length + 1];
          offsets[0] = 0;
          for (int i = 0; i < lengths.length; i++) {
              offsets[i + 1] = offsets[i] + lengths[i];
          }
          return offsets;
      }
docs: utility method to calculate field offsets used to extract fields from record.