String rootName = _rootVariable != null ? _rootVariable : "value";
ValueExpr valueExpr = variableValues.get(rootName);
String valueType = variableTypes.get(rootName);
for (PathSegment segment : _segments) {
if (valueExpr instanceof Var) {
Var input = (Var) valueExpr;
PropertyRecord record = database.getPropertyRecord(segment.propertyID);
if (record == null) {
throw new ExpressionException("No property can be aliased to '" + segment.propertyID + "'");
}
Var output = builder.makeVar("seg");
Var propertyVar = builder.makeVar("seg", record.uri);
if (segment.forward) {
builder.addTupleExpr(new StatementPattern(input, propertyVar, output));
valueType = record.valueType;
} else {
builder.addTupleExpr(new StatementPattern(output, propertyVar, input));