AMashenkov commented on code in PR #2441:
URL: https://github.com/apache/ignite-3/pull/2441#discussion_r1296869275
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteIndex.java:
##########
@@ -59,132 +72,185 @@ public static Collation of(boolean asc, boolean
nullsFirst) {
this.asc = asc;
this.nullsFirst = nullsFirst;
}
+
}
+
/**
* Type of the index.
*/
public enum Type {
- HASH, SORTED
+ HASH, SORTED;
}
- private final List<String> columns;
+ private final int id;
- private final @Nullable List<Collation> collations;
+ private final String name;
- private final Index<?> index;
+ private final IgniteDistribution tableDistribution;
- private final Type type;
+ private final RelCollation outputCollation;
- /**
- * Constructs the Index object.
- *
- * @param index A data access object to wrap.
- */
- public IgniteIndex(Index<?> index) {
- this.index = Objects.requireNonNull(index, "index");
+ private final RelCollation indexCollation;
- this.columns = index.descriptor().columns();
- this.collations = deriveCollations(index);
- this.type = index instanceof SortedIndex ? Type.SORTED : Type.HASH;
- }
+ private final Type type;
- /**
- * Constructs the Index object.
- */
- @TestOnly
- public IgniteIndex(Type type, List<String> columns, @Nullable
List<Collation> collations) {
- assert type == Type.SORTED ^ collations == null;
+ private RelDataType rowType;
- this.columns = columns;
- this.collations = collations;
+ /** Constructor. */
+ public IgniteIndex(int id, String name, Type type, IgniteDistribution
tableDistribution, RelCollation outputCollation) {
+ this.id = id;
+ this.name = name;
this.type = type;
+ this.tableDistribution = tableDistribution;
+ this.outputCollation = outputCollation;
- index = null;
+ indexCollation = (type == Type.SORTED) ?
createIndexCollation(outputCollation.getFieldCollations()) : null;
Review Comment:
This collation is required for sorted comparator, and is used for sorting
range condition in bounds to make sure index cursor return sorted result.
E.g. in pseudocode "SELECT ... WHERE (10 < col < 20) OR (1 < col < 5) ORDER
BY col ASC" converts to index scan with ranges (10, 20) and (1, 5), but ORDER
BY requires index scans performed in order (1,5), then (10,20)
This make no sense for hash indexes and the collation is not used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]