[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: JLDAP LdapSearchResults getCount strange behaviour

Rob Shepherd wrote:
LDAPSearchResults searchResults =
lc.search( searchBase,
new String[]{"uid"}, // return all attributes
false); // return attrs and values
//catch(InterruptedException ie){}
System.out.println(System.nanoTime() + " Num results: "+searchResults.getCount());

The batch size constraint for searches on a connection defaults to 1 because the assumption is you'll want to do *something* with all that data before counting the results. Try setting the batchsize constraint on your search to 0. Default will block an entry at a time.

If I uncomment the Thread.sleep(200) I never see such bizarre results.

Because the search completes.

Qs. Is getCount() not for this purpose?

Yes and no. It will tell you where the search is at the moment you ask. Recalling the batch size parameter, reread the javadocs:


I thought search(...) was a synchronous method... should it not block until everything is returned?

It is a synchronous search, but it's still designed for efficiency and configured by default to assume you will iterate on the results.

Is there something else I should be doing?

No, but since you're *I* should probably put some clarification on the JLDAP javadocs on my lengthy todo list.

Jon Roberts