format/src/main/java/com/github/sadikovi/riff/tree/node/In.java
/**
   * Clean up typed expressions in array, check duplicate types and sort array in
   * ascending order to ensure search property.
   */
Clean up typed expressions in array, check duplicate types and sort array in
ascending order to ensure search property.
Clean up typed expressions in array check duplicate types and sort array in ascending order to ensure search property .
private static TypedExpression[] cleanUp(TypedExpression[] values) {
    if (values == null || values.length == 0) {
      throw new IllegalArgumentException("Empty list of expressions for In predicate");
    }
    HashSet<TypedExpression> tmp = new HashSet<TypedExpression>();
    DataType dtype = null;
    for (int i = 0; i < values.length; i++) {
      if (dtype != null && !dtype.equals(values[i].dataType())) {
        throw new IllegalArgumentException("Invalid data type, expected " + dtype + ", found " +
          values[i].dataType());
      }
      dtype = values[i].dataType();
      tmp.add(values[i]);
    }
    TypedExpression[] unique = new TypedExpression[tmp.size()];
    int i = 0;
    for (TypedExpression expr : tmp) {
      unique[i++] = expr;
    }
    Arrays.sort(unique);
    return unique;
  }
private static TypedExpression [ ] cleanUp ( TypedExpression [ ] values ) { if ( values == null || values . length == 0 ) { throw new IllegalArgumentException ( "Empty list of expressions for In predicate" ) ; } HashSet < TypedExpression > tmp = new HashSet < TypedExpression > ( ) ; DataType dtype = null ; for ( int i = 0 ; i < values . length ; i ++ ) { if ( dtype != null && ! dtype . equals ( values [ i ] . dataType ( ) ) ) { throw new IllegalArgumentException ( "Invalid data type, expected " + dtype + ", found " + values [ i ] . dataType ( ) ) ; } dtype = values [ i ] . dataType ( ) ; tmp . add ( values [ i ] ) ; } TypedExpression [ ] unique = new TypedExpression [ tmp . size ( ) ] ; int i = 0 ; for ( TypedExpression expr : tmp ) { unique [ i ++ ] = expr ; } Arrays . sort ( unique ) ; return unique ; }
Clean up typed expressions in array, check duplicate types and sort array in
 ascending order to ensure search property.
Clean up typed expressions in array check duplicate types and sort array in ascending order to ensure search property .
// temporary set to remove duplicate values // copy and sort expressions, check that all expressions are of the same type