code: @SneakyThrows(ConditionalTableUpdateException.class)
      private void validateConditionalUpdate(List<TableKeyBatch.Item> items, Map<UUID, Long> bucketOffsets, String segmentName) {
          val badKeyVersions = new HashMap<TableKey, Long>(); // Key = Key that failed, Value = Key's bucket offset.
          for (val item : items) {
              // Validate compareVersion.
              TableKey key = item.getKey();
              Long bucketOffset = bucketOffsets.get(item.getHash());
              assert key.hasVersion() : "validateConditionalUpdate for TableKey with no compare version";
              if (bucketOffset == TableKey.NOT_EXISTS) {
                  if (key.getVersion() != TableKey.NOT_EXISTS) {
                      // Key does not exist, but the conditional update provided a specific version.
                      throw new KeyNotExistsException(segmentName, key.getKey());
                  }
              } else if (bucketOffset != key.getVersion()) {
                  // Key does exist, but has the wrong version.
                  badKeyVersions.put(key, bucketOffset);
              }
          }
  
          if (!badKeyVersions.isEmpty()) {
              // Throw the bad key version in bulk - helps speed verification.
              throw new BadKeyVersionException(segmentName, badKeyVersions);
          }
  
          // All validations for all items passed.
      }
docs: Validates a list of UpdateBatchItems against their actual Table Bucket offsets.
  
  @param items         A list of {@link TableKeyBatch.Item} instances to validate.
  @param bucketOffsets A Map of Key Hashes to their corresponding offsets (versions). Each {@link TableKeyBatch.Item}
  will be looked up in this Map (based on the Item's KeyHash) and validated appropriately.
  @param segmentName   The name of the segment on which the update is performed.
  @throws KeyNotExistsException  If an UpdateBatchItem's Key does not exist in the Table but the item's version does
  not indicate that the key must not exist.
  @throws BadKeyVersionException If an UpdateBatchItem's Key does exist in the Table but the item's version is
  different from that key's version.