try {
System.out.println("Starting NotesRunner");
Session session = NotesFactory.createSession();
Long sessId = getLotusId(session);
sessionid.set(sessId);
Database db = session.getDatabase("", "events4.nsf");
System.out.println("Db id:" + getLotusId(db));
try {
lotus.domino.Document doc = null;
lotus.domino.Document nextDoc = null;
lotus.domino.DocumentCollection allDocs = db.getAllDocuments();
System.out.println("All Collection has " + allDocs.getCount() + " documents");
int[] nids = new int[allDocs.getCount()];
long walkStartTime = System.nanoTime();
doc = allDocs.getFirstDocument();
int i = 0;
while (doc != null) {
nextDoc = allDocs.getNextDocument(doc);
nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
doc.recycle();
doc = nextDoc;
}
long walkEndTime = System.nanoTime();
System.out.println("DOCWALK: noteid array has " + allDocs.getCount() + " entries in " + (walkEndTime - walkStartTime)
/ 1000 + "us");
long ncStartTime = System.nanoTime();
NoteCollection nc = db.createNoteCollection(false);
nc.add(allDocs);
nids = nc.getNoteIDs();
long ncBuildTime = System.nanoTime();
System.out
.println("NOTECOLL: noteid array has " + nids.length + " entries in " + (ncBuildTime - ncStartTime) / 1000 + "us");
// for (int j = 0; j < nids.length; j++) {
// doc = db.getDocumentByID(Integer.toString(nids[j], 16));
// }
// long ncWalkTime = System.nanoTime();
// System.out.println("NOTECOLL: noteid array walked " + nids.length + " entries in " + (ncWalkTime - ncBuildTime) / 1000
// + "us");
long mergeStartTime = System.nanoTime();
DocumentCollection mergeColl = db.search("@False", db.getLastModified(), 1);
for (int j = 0; j < nids.length; j++) {
mergeColl.merge(nids[j]);
}
long mergeBuildTime = System.nanoTime();
System.out.println("MERGECOLL: mergeColl has " + mergeColl.getCount() + " entries in " + (mergeBuildTime - mergeStartTime)
/ 1000 + "us");
doc = mergeColl.getFirstDocument();
while (doc != null) {
nextDoc = mergeColl.getNextDocument(doc);
@SuppressWarnings("unused")
int n = Integer.valueOf(doc.getNoteID(), 16);
doc.recycle();
doc = nextDoc;
}
long mergeWalkTime = System.nanoTime();
System.out.println("MERGECOLL: mergeColl walked " + mergeColl.getCount() + " entries in "
+ (mergeWalkTime - mergeBuildTime) / 1000 + "us");
System.out.println("MERGECOLL: mergeColl total time " + mergeColl.getCount() + " entries in "
+ (mergeWalkTime - ncStartTime) / 1000 + "us");
walkStartTime = System.nanoTime();
doc = allDocs.getFirstDocument();
i = 0;
while (doc != null) {
nextDoc = allDocs.getNextDocument(doc);
nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
doc.recycle();
doc = nextDoc;
}
walkEndTime = System.nanoTime();
System.out.println("DOCWALK: noteid array has " + allDocs.getCount() + " entries in " + (walkEndTime - walkStartTime)
/ 1000 + "us");
ncStartTime = System.nanoTime();
nc = db.createNoteCollection(false);
nc.add(allDocs);
nids = nc.getNoteIDs();
ncBuildTime = System.nanoTime();
System.out
.println("NOTECOLL: noteid array has " + nids.length + " entries in " + (ncBuildTime - ncStartTime) / 1000 + "us");
// for (int j = 0; j < nids.length; j++) {
// doc = db.getDocumentByID(Integer.toString(nids[j], 16));
// }
// long ncWalkTime = System.nanoTime();
// System.out.println("NOTECOLL: noteid array walked " + nids.length + " entries in " + (ncWalkTime - ncBuildTime) / 1000
// + "us");
mergeStartTime = System.nanoTime();
mergeColl = db.search("@False", db.getLastModified(), 1);
for (int j = 0; j < nids.length; j++) {
mergeColl.merge(nids[j]);
}
mergeBuildTime = System.nanoTime();
System.out.println("MERGECOLL: mergeColl has " + mergeColl.getCount() + " entries in " + (mergeBuildTime - mergeStartTime)