Java Code Examples for org.apache.calcite.runtime.Utilities#compare()

The following examples show how to use org.apache.calcite.runtime.Utilities#compare() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelCollationImpl.java    From calcite with Apache License 2.0 6 votes vote down vote up
public int compareTo(@Nonnull RelMultipleTrait o) {
  final RelCollationImpl that = (RelCollationImpl) o;
  final UnmodifiableIterator<RelFieldCollation> iterator =
      that.fieldCollations.iterator();
  for (RelFieldCollation f : fieldCollations) {
    if (!iterator.hasNext()) {
      return 1;
    }
    final RelFieldCollation f2 = iterator.next();
    int c = Utilities.compare(f.getFieldIndex(), f2.getFieldIndex());
    if (c != 0) {
      return c;
    }
  }
  return iterator.hasNext() ? -1 : 0;
}
 
Example 2
Source File: Lattice.java    From calcite with Apache License 2.0 5 votes vote down vote up
private static int compare(List<Column> list0, List<Column> list1) {
  final int size = Math.min(list0.size(), list1.size());
  for (int i = 0; i < size; i++) {
    final int o0 = list0.get(i).ordinal;
    final int o1 = list1.get(i).ordinal;
    final int c = Utilities.compare(o0, o1);
    if (c != 0) {
      return c;
    }
  }
  return Utilities.compare(list0.size(), list1.size());
}
 
Example 3
Source File: RelNodes.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Compares arrays of {@link RelNode}. */
public static int compareRels(RelNode[] rels0, RelNode[] rels1) {
  int c = Utilities.compare(rels0.length, rels1.length);
  if (c != 0) {
    return c;
  }
  for (int i = 0; i < rels0.length; i++) {
    c = COMPARATOR.compare(rels0[i], rels1[i]);
    if (c != 0) {
      return c;
    }
  }
  return 0;
}
 
Example 4
Source File: RelNodes.java    From calcite with Apache License 2.0 5 votes vote down vote up
public int compare(RelNode o1, RelNode o2) {
  // Compare on field count first. It is more stable than id (when rules
  // are added to the set of active rules).
  final int c = Utilities.compare(o1.getRowType().getFieldCount(),
      o2.getRowType().getFieldCount());
  if (c != 0) {
    return -c;
  }
  return Utilities.compare(o1.getId(), o2.getId());
}
 
Example 5
Source File: ImmutableBitSet.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Compares this ImmutableBitSet with another, using a lexicographic
 * ordering.
 *
 * <p>Bit sets {@code (), (0), (0, 1), (0, 1, 3), (1), (2, 3)} are in sorted
 * order.</p>
 */
public int compareTo(@Nonnull ImmutableBitSet o) {
  int i = 0;
  for (;;) {
    int n0 = nextSetBit(i);
    int n1 = o.nextSetBit(i);
    int c = Utilities.compare(n0, n1);
    if (c != 0 || n0 < 0) {
      return c;
    }
    i = n0 + 1;
  }
}
 
Example 6
Source File: QuarkTile.java    From quark with Apache License 2.0 4 votes vote down vote up
public int compareTo(Column column) {
  return Utilities.compare(ordinal, column.ordinal);
}
 
Example 7
Source File: QuarkCube.java    From quark with Apache License 2.0 4 votes vote down vote up
public int compareTo(Dimension dimension) {
  return Utilities.compare(this.cubeOrdinal, dimension.cubeOrdinal);
}
 
Example 8
Source File: Lattice.java    From calcite with Apache License 2.0 4 votes vote down vote up
public int compareTo(Column column) {
  return Utilities.compare(ordinal, column.ordinal);
}