How to get NoteIDs of deleted documents with Java API?

Hi,I’m trying to find a high-performance way of getting NoteIDs of deleted documents via Java Notes API.

Via C API, I can do it by following code.

---- C-code begin ---------------

TIMEDATE  allDocument;

TIMEDATE  lastTime;



clock_t st = ::clock();



::TimeConstant(TIMEDATE_WILDCARD, &allDocument);

int alive = 0;



if (::NSFDbGetModifiedNoteTable(db, NOTE_CLASS_DATA, allDocument, &lastTime, &table)) {

	std::cout << "failed to enumarate ids" << std::endl;

	return EXIT_FAILURE;

}



std::vector<NOTEID> deletedIds;

NOTEID noteid;

bool first = true;

while(::IDScan(table, first, &noteid)) {

	first = false;

	if (noteid & RRV_DELETED) {

		deletedIds.push_back(noteid);

	} else {

		++alive;

	}

}



clock_t ed = ::clock();



std::cout << "the number of alive ids:" << alive << std::endl;

std::cout << "the number of deleted ids:" << deletedIds.size() << std::endl;

std::cout << "elapsed clock:" << (ed-st) << std::endl;

std::cout << "clock per sec:" << CLOCKS_PER_SEC << std::endl;

---- C-code end ---------------

The result of C-code above was like this.

---- C-code result begin ---------------

the number of alive ids:50042

the number of deleted ids:1040

elapsed clock:203

clock per sec:1000

---- C-code result end ---------------

Note: the database has

50041 documents that can be opened by the session and are not deleted

1 document that can’t be opened by the session and is not deleted

1040 documents that are deleted

It took only 200 milliseconds to retrieve 1000 deleted NoteIDs out of 51000 documents

in a Domino server on Win2003 with a Pentium4 2.4GHz.

This is the enough performance.

Via Java Notes API, however, it was too slow and didn’t provide me deleted NoteIDs.

---- Java-code begin ---------------

logger.debug("collecting noteids...");

NoteCollection noteCollection = database.createNoteCollection(false);

logger.debug("building NoteCollection...");

noteCollection.selectAllDataNotes(true);

noteCollection.buildCollection();

logger.debug("counting...");

logger.debug("count=" + noteCollection.getCount());

logger.debug("enumerating NoteCollection...");

int noteIds = 0;

for (String noteId = noteCollection.getFirstNoteID(); noteId != null && noteId.length() > 0; noteId = noteCollection.getNextNoteID(noteId)) {

    ++noteIds;

}

logger.debug("recycling NoteCollection...");

noteCollection.recycle();

logger.debug("note IDs=" + noteIds);

---- Java-code end ---------------

The result of Java-code above was like this.

---- Java-code result start ---------------

2007-01-05 12:07:20,096  collecting noteids...

2007-01-05 12:07:20,096  building NoteCollection...

2007-01-05 12:07:22,659  counting...

2007-01-05 12:07:22,674  count=50041

2007-01-05 12:07:22,674  enumerating NoteCollection...

2007-01-05 12:07:47,799  recycling NoteCollection...

2007-01-05 12:07:47,799  note IDs=50041

---- Java-code result end ---------------

It took 27 seconds (hundredfold!) to do same thing as the C-code.

Moreover, it couldn’t get NoteIDs of deleted documents.

It seems that Java API’s NoteCollection#buildCollection, which I think corresponding to NSFDbGetModifiedNoteTable of C API,

ELIMINATES NoteIDs of deleted documents and unaccessible documents.

It also means Java API "open"s the documents to check and thus took many seconds to just listup NoteIDs.

Can I avoid this bottleneck and get NoteIDs of deleted documents via Java API?

I’ll appreciate any information.