protected <K> Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> doRead(@NotNull DataInput in,
                                                                        @Nullable StubIndexKey<K, ?> requestedIndex,
                                                                        @Nullable K requestedKey) throws IOException {
    int stubIndicesValueMapSize = DataInputOutputUtil.readINT(in);
    if (stubIndicesValueMapSize > 0) {
      Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> stubIndicesValueMap =
        requestedIndex != null ? null : new HashMap<>(stubIndicesValueMapSize);
      StubKeySerializationState stubKeySerializationState = createStubIndexKeySerializationState(in, stubIndicesValueMapSize);
      for (int i = 0; i < stubIndicesValueMapSize; ++i) {
        ID<Object, ?> indexKey = (ID<Object, ?>)readStubIndexKey(in, stubKeySerializationState);
        if (indexKey instanceof StubIndexKey) { // indexKey can be ID in case of removed index
          StubIndexKey<Object, ?> stubIndexKey = (StubIndexKey<Object, ?>)indexKey;
          boolean deserialize = requestedIndex == null || requestedIndex.equals(stubIndexKey);
          if (deserialize) {
            Map<Object, StubIdList> value = deserializeIndexValue(in, stubIndexKey, requestedKey);
            if (requestedIndex != null) {
              return Collections.singletonMap(requestedIndex, value);
            }
            stubIndicesValueMap.put(stubIndexKey, value);
          }
          else {
            skipIndexValue(in);
          }
        }
        else if (indexKey == null) {
          // key is deleted, just properly skip bytes (used while index update)
          skipIndexValue(in);
        }
        else {
          throw new AssertionError("indexKey '" + indexKey + "' [" + indexKey.getClass() + "] is not null, and not a StubIndexKey");
        }
      }
      return stubIndicesValueMap;
    }
    return Collections.emptyMap();
  }
protected <K> Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> doRead(@NotNull DataInput in,
                                                                        @Nullable StubIndexKey<K, ?> requestedIndex,
                                                                        @Nullable K requestedKey)