Sth like sql group by using java api

Hi
i need sth like sql:

select count(), type from cluster having count() > 0

using java api

thx for help