checkQueryValueType(fieldDef, toValue);
toKeyComponents.add(toValue);
toKeyStructBuilder.add(fieldDef.asRowKeyWithoutTermination());
}
final StructRowKey frk = fromKeyStructBuilder.toRowKey();
fromKey = frk.serialize(fromKeyComponents.toArray());
final StructRowKey trk = toKeyStructBuilder.toRowKey();
toKey = trk.serialize(toKeyComponents.toArray());
rangeCondSet = true;
usedConditionsCount++;
break;
} else {
// we're done
break;
}
}
// Check if we have used all conditions defined in the query
if (definedFieldsIndex < definition.getFields().size() &&
usedConditionsCount < query.getEqConditions().size() + (rangeCond != null ? 1 : 0)) {
StringBuilder message = new StringBuilder();
message.append("The query contains conditions on fields which either did not follow immediately on ");
message.append(
"the previous equals condition or followed after a range condition on a field. The fields are: ");
for (; definedFieldsIndex < definition.getFields().size(); definedFieldsIndex++) {
IndexFieldDefinition fieldDef = definition.getFields().get(definedFieldsIndex);
if (query.getCondition(fieldDef.getName()) != null) {
message.append(fieldDef.getName());
} else if (rangeCond != null && rangeCond.getName().equals(fieldDef.getName())) {
message.append(fieldDef.getName());
}
message.append(" ");
}
throw new MalformedQueryException(message.toString());
}
if (!rangeCondSet) {
// Construct fromKey/toKey for the case there were only equals conditions
final StructRowKey rk = fromKeyStructBuilder.toRowKey();
rk.setTermination(Termination.MUST);
fromKey = rk.serialize(fromKeyComponents.toArray());
toKey = fromKey;
}
Scan scan = new Scan(fromKey);