use of io.confluent.ksql.planner.plan.KeyConstraint in project ksql by confluentinc.
the class KeyedTableLookupOperator method getMatIterator.
private Iterator<Row> getMatIterator(final KsqlKey ksqlKey) {
if (!(nextKey instanceof KeyConstraint)) {
throw new IllegalStateException(String.format("Keyed lookup queries should be done with " + "key constraints: %s", ksqlKey.toString()));
}
final KeyConstraint keyConstraintKey = (KeyConstraint) ksqlKey;
final Iterator<Row> result;
if (keyConstraintKey.getOperator() == ConstraintOperator.EQUAL) {
result = mat.nonWindowed().get(ksqlKey.getKey(), nextLocation.getPartition(), consistencyOffsetVector);
} else if (keyConstraintKey.getOperator() == ConstraintOperator.GREATER_THAN || keyConstraintKey.getOperator() == ConstraintOperator.GREATER_THAN_OR_EQUAL) {
// Underlying store will always return keys inclusive the endpoints
// and filtering is used to trim start and end of the range in case of ">"
final GenericKey fromKey = keyConstraintKey.getKey();
final GenericKey toKey = null;
result = mat.nonWindowed().get(nextLocation.getPartition(), fromKey, toKey, consistencyOffsetVector);
} else if (keyConstraintKey.getOperator() == ConstraintOperator.LESS_THAN || keyConstraintKey.getOperator() == ConstraintOperator.LESS_THAN_OR_EQUAL) {
// Underlying store will always return keys inclusive the endpoints
// and filtering is used to trim start and end of the range in case of "<"
final GenericKey fromKey = null;
final GenericKey toKey = keyConstraintKey.getKey();
result = mat.nonWindowed().get(nextLocation.getPartition(), fromKey, toKey, consistencyOffsetVector);
} else {
throw new IllegalStateException(String.format("Invalid comparator type " + keyConstraintKey.getOperator()));
}
return result;
}
use of io.confluent.ksql.planner.plan.KeyConstraint in project ksql by confluentinc.
the class PullPhysicalPlan method getKeys.
public List<KsqlKey> getKeys() {
final List<KsqlKey> list = new ArrayList<>();
for (LookupConstraint c : lookupConstraints) {
if (c instanceof KeyConstraint) {
final KeyConstraint kc = (KeyConstraint) c;
list.add(kc.getKsqlKey());
} else {
// we shouldn't see any NonKeyContraints here
return Collections.emptyList();
}
}
return ImmutableList.copyOf(list);
}
Aggregations