code: public static void calculateCollectionOffsets(Field field, IntList offsets, BooleanList collectionIsNull, int[] definitionLevels, int[] repetitionLevels)
      {
          int maxDefinitionLevel = field.getDefinitionLevel();
          int maxElementRepetitionLevel = field.getRepetitionLevel() + 1;
          boolean required = field.isRequired();
          int offset = 0;
          offsets.add(offset);
          for (int i = 0; i < definitionLevels.length; i = getNextCollectionStartIndex(repetitionLevels, maxElementRepetitionLevel, i)) {
              if (ParquetTypeUtils.isValueNull(required, definitionLevels[i], maxDefinitionLevel)) {
                  // Collection is null
                  collectionIsNull.add(true);
                  offsets.add(offset);
              }
              else if (definitionLevels[i] == maxDefinitionLevel) {
                  // Collection is defined but empty
                  collectionIsNull.add(false);
                  offsets.add(offset);
              }
              else if (definitionLevels[i] > maxDefinitionLevel) {
                  // Collection is defined and not empty
                  collectionIsNull.add(false);
                  offset += getCollectionSize(repetitionLevels, maxElementRepetitionLevel, i + 1);
                  offsets.add(offset);
              }
          }
      }
docs: Each collection (Array or Map) has four variants of presence:
  1) Collection is not defined, because one of it's optional parent fields is null
  2) Collection is null
  3) Collection is defined but empty
  4) Collection is defined and not empty. In this case offset value is increased by the number of elements in that collection