case SEQUENCE:
final List<Item> materialized = result.materialize();
ret = new ValueSequence(materialized, dynEnv);
break;
case MARSHALLED_SEQUENCE:
ret = new MarshalledSequence(result, dynEnv);
break;
case AUTO:
case REDIRECTABLE_MARSHALLED_SEQUENCE:
case REMOTE_PADED_SEQUENCE: {
final RedirectableChecker check = new RedirectableChecker();
try {
check.visit(queryExpr, null);
} catch (XQueryException e) {
throw new IllegalStateException(e);
}
if(check.isRedirectable()) {
MarshalledSequence seq = new MarshalledSequence(result, dynEnv);
seq.setRedirectable(true);
ret = seq;
} else if(returnType == ReturnType.REMOTE_PADED_SEQUENCE) {
MarshalledSequence seq = new MarshalledSequence(result, dynEnv);
seq.setRemotePaging(true);
ret = seq;
} else if(returnType == ReturnType.AUTO) {// treat as THROTTLED_ASYNC_REMOTE_SEQUENCE
final ThrottedRemoteSequenceProxy remote = new ThrottedRemoteSequenceProxy(_throttle, result, request);
try {
UnicastRemoteObject.exportObject(remote, 0, TimeoutSocketProdiver.createClientSocketFactory(), TimeoutSocketProdiver.createServerSocketFactory());
} catch (RemoteException e) {
throw new IllegalStateException("failed exporting result sequence", e);
}
ret = new RemoteSequence(remote, result.getType());
_executors.execute(remote);
} else {
assert (returnType == ReturnType.REDIRECTABLE_MARSHALLED_SEQUENCE) : returnType;
ret = new MarshalledSequence(result, dynEnv);
}
break;
}
case REMOTE_SEQUENCE: {
final RemoteSequenceProxy remote = new RemoteSequenceProxy(result, request);