} else {
Set<TitanType> ts = new HashSet<TitanType>(types.length);
queries = new ArrayList<BackendQueryHolder<SliceQuery>>(types.length + 4);
for (String typeName : types) {
InternalType type = getType(typeName);
if (type != null && (includeHidden || !type.isHidden())) {
ts.add(type);
if (type.isPropertyKey()) {
if (returnType == RelationType.EDGE)
throw new IllegalArgumentException("Querying for edges but including a property key: " + type.getName());
returnType = RelationType.PROPERTY;
}
if (type.isEdgeLabel()) {
if (returnType == RelationType.PROPERTY)
throw new IllegalArgumentException("Querying for properties but including an edge label: " + type.getName());
returnType = RelationType.EDGE;
}
//Construct sort key constraints (if any, and if not direction==Both)
EdgeSerializer.TypedInterval[] sortKeyConstraints = new EdgeSerializer.TypedInterval[type.getSortKey().length];
And<TitanRelation> remainingConditions = conditions;
boolean vertexConstraintApplies = type.getSortKey().length == 0 || conditions.hasChildren();
if (type.getSortKey().length > 0 && conditions.hasChildren()) {
remainingConditions = conditions.clone();
sortKeyConstraints = compileSortKeyConstraints(type,tx,remainingConditions);
if (sortKeyConstraints==null) continue; //Constraints cannot be matched
Interval interval;
if (sortKeyConstraints[sortKeyConstraints.length-1] == null ||
(interval=sortKeyConstraints[sortKeyConstraints.length-1].interval) == null || !interval.isPoint()) {
vertexConstraintApplies = false;
}
}
Direction[] dirs = {dir};
EdgeSerializer.VertexConstraint vertexConstraint = getVertexConstraint();
if (dir == Direction.BOTH &&
(hasSortKeyConstraints(sortKeyConstraints) || (vertexConstraintApplies && vertexConstraint != null))) {
//Split on direction in the presence of effective sort key constraints
dirs = new Direction[]{Direction.OUT, Direction.IN};
}
for (Direction dir : dirs) {
EdgeSerializer.VertexConstraint vertexCon = vertexConstraint;
if (vertexCon == null || !vertexConstraintApplies || type.isUnique(dir)) vertexCon = null;
EdgeSerializer.TypedInterval[] sortConstraints = sortKeyConstraints;
if (hasSortKeyConstraints(sortKeyConstraints) && type.isUnique(dir)) {
sortConstraints = new EdgeSerializer.TypedInterval[type.getSortKey().length];
}
boolean isFitted = !remainingConditions.hasChildren()
&& vertexConstraint == vertexCon && sortConstraints == sortKeyConstraints;
SliceQuery q = serializer.getQuery(type, dir, sortConstraints, vertexCon);