The first approach can be used if the intermediate result that is to be computed has a fixed length and can easily be encoded in the binary string returned from the computeAggregate function.
The attribute can contain the user ID of the queried person, the dn values of the group members to be evaluated implicitly or some arbitrary string(s) in case of intermediate results.