<commit_before>package org.vitrivr.cineast.core.features;

import org.vitrivr.cineast.core.data.providers.primitive.PrimitiveProviderComparator;
import org.vitrivr.cineast.core.data.providers.primitive.PrimitiveTypeProvider;
import org.vitrivr.cineast.core.db.RelationalOperator;
import org.vitrivr.cineast.core.features.abstracts.BooleanRetriever;

import java.util.*;

public class RangeBooleanRetriever extends BooleanRetriever {

  private static final List<RelationalOperator> SUPPORTED_OPERATORS =
      Collections.unmodifiableList(
          Arrays.asList(
              RelationalOperator.BETWEEN,
              RelationalOperator.EQ,
              RelationalOperator.NEQ,
              RelationalOperator.GEQ,
              RelationalOperator.GREATER,
              RelationalOperator.LEQ,
              RelationalOperator.LESS,
              RelationalOperator.IN));

  private final HashMap<String, PrimitiveTypeProvider> minimumMap = new HashMap<>();
  private final HashMap<String, PrimitiveTypeProvider> maximumMap = new HashMap<>();

  protected RangeBooleanRetriever(String entity, Collection<String> attributes) {
    super(entity, attributes);
  }

  public RangeBooleanRetriever(LinkedHashMap<String, String> properties) {
    super(properties);
  }

  @Override
  protected Collection<RelationalOperator> getSupportedOperators() {
    return SUPPORTED_OPERATORS;
  }

  public PrimitiveTypeProvider getMinimum(String column){
    if (this.attributes.contains(column) && !this.minimumMap.containsKey(column)){
      populateExtremaMap();
    }
    return minimumMap.get(column);
  }

  public PrimitiveTypeProvider getMaximum(String column){
    if (this.attributes.contains(column) && !this.maximumMap.containsKey(column)){
      populateExtremaMap();
    }
    return maximumMap.get(column);
  }

  private void populateExtremaMap(){

    PrimitiveProviderComparator comparator = new PrimitiveProviderComparator();

    for(String column: this.attributes){
      List<PrimitiveTypeProvider> col = this.selector.getAll(column);
      if (col.isEmpty()){
        continue;
      }
      PrimitiveTypeProvider min = col.get(0), max = col.get(0);
      for (PrimitiveTypeProvider t : col){
        if (comparator.compare(t, min) < 0){
          min = t;
        }
        if(comparator.compare(max, t) > 0){
          max = t;
        }
      }
      this.minimumMap.put(column, min);
      this.maximumMap.put(column, max);
    }
  }
}<commit_msg>fixing populateExtremaMap() comparison being in the wrong order<commit_after>package org.vitrivr.cineast.core.features;

import org.vitrivr.cineast.core.data.providers.primitive.PrimitiveProviderComparator;
import org.vitrivr.cineast.core.data.providers.primitive.PrimitiveTypeProvider;
import org.vitrivr.cineast.core.db.RelationalOperator;
import org.vitrivr.cineast.core.features.abstracts.BooleanRetriever;

import java.util.*;

public class RangeBooleanRetriever extends BooleanRetriever {

  private static final List<RelationalOperator> SUPPORTED_OPERATORS =
      Collections.unmodifiableList(
          Arrays.asList(
              RelationalOperator.BETWEEN,
              RelationalOperator.EQ,
              RelationalOperator.NEQ,
              RelationalOperator.GEQ,
              RelationalOperator.GREATER,
              RelationalOperator.LEQ,
              RelationalOperator.LESS,
              RelationalOperator.IN));

  private final HashMap<String, PrimitiveTypeProvider> minimumMap = new HashMap<>();
  private final HashMap<String, PrimitiveTypeProvider> maximumMap = new HashMap<>();

  protected RangeBooleanRetriever(String entity, Collection<String> attributes) {
    super(entity, attributes);
  }

  public RangeBooleanRetriever(LinkedHashMap<String, String> properties) {
    super(properties);
  }

  @Override
  protected Collection<RelationalOperator> getSupportedOperators() {
    return SUPPORTED_OPERATORS;
  }

  public PrimitiveTypeProvider getMinimum(String column){
    if (this.attributes.contains(column) && !this.minimumMap.containsKey(column)){
      populateExtremaMap();
    }
    return minimumMap.get(column);
  }

  public PrimitiveTypeProvider getMaximum(String column){
    if (this.attributes.contains(column) && !this.maximumMap.containsKey(column)){
      populateExtremaMap();
    }
    return maximumMap.get(column);
  }

  private void populateExtremaMap(){

    PrimitiveProviderComparator comparator = new PrimitiveProviderComparator();

    for(String column: this.attributes){
      List<PrimitiveTypeProvider> col = this.selector.getAll(column);
      if (col.isEmpty()){
        continue;
      }
      PrimitiveTypeProvider min = col.get(0), max = col.get(0);
      for (PrimitiveTypeProvider t : col){
        if (comparator.compare(t, min) < 0){
          min = t;
        }
        if(comparator.compare(t, max) > 0){
          max = t;
        }
      }
      this.minimumMap.put(column, min);
      this.maximumMap.put(column, max);
    }
  }
}
{'fraction_non_alphanumeric': 0.09915696507426736, 'fraction_numerical': 0.0016057808109193096, 'mean_word_length': 3.4253996447602133, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3755310', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1408, 'n_words': 255}