notecoll.buildCollection();
// DocumentCollection coll = db.search("@Begins(Title; \"B\")");
timelog("Starting note coordinates of " + notecoll.getCount() + " documents");
// for (Document doc : notecoll) {
for (String nid : notecoll) {
NoteCoordinate nc = new NoteCoordinate(notecoll, nid);
notelist.add(nc);
}
// Database eventDb = session.getDatabase("", "events4.nsf");
// NoteCollection eventNotecoll = eventDb.createNoteCollection(false);
// eventNotecoll.setSelectDocuments(true);
// eventNotecoll.buildCollection();
// timelog("Continuing note coordinates of " + eventNotecoll.getCount() + " documents");
// for (String nid : eventNotecoll) {
// NoteCoordinate nc = new NoteCoordinate(eventNotecoll, nid);
// notelist.add(nc);
// }
// Database xspextDb = session.getDatabase("", "openntf/xpagesext.nsf");
// NoteCollection xspextNotecoll = xspextDb.createNoteCollection(false);
// xspextNotecoll.setSelectDocuments(true);
// xspextNotecoll.buildCollection();
// timelog("Continuing note coordinates of " + xspextNotecoll.getCount() + " documents");
// for (String nid : xspextNotecoll) {
// NoteCoordinate nc = new NoteCoordinate(xspextNotecoll, nid);
// notelist.add(nc);
// }
byte[] bytes = notelist.toByteArray();
int byteSize = bytes.length;
timelog("Resulting bytearray is " + bytes.length + " so we expect " + (bytes.length / (2500 * 24)) + " items");
// File file = File.createTempFile("foo", "bar");
// FileOutputStream fos = new FileOutputStream(file);
// fos.write(bytes);
// fos.close();
storeTest.writeBinary("imdbNoteList", bytes, 2500 * 24);
storeTest.save();
String storeId = storeTest.getUniversalID();
storeTest.recycle();
storeTest = null;
// coll.recycle();
// coll = null;
notecoll.recycle();
notecoll = null;
// eventNotecoll.recycle();
// eventNotecoll = null;
// eventDb.recycle();
// eventDb = null;
// xspextNotecoll.recycle();
// xspextNotecoll = null;
// xspextDb.recycle();
// xspextDb = null;
db.recycle();
db = null;
notelist = null;
System.gc();
timelog("Binary data serialized out. Reloading...");
storeTest = log.getDocumentByUNID(storeId);
// FileInputStream fis = new FileInputStream(file);
DbCache cache = new DbCache();
NoteCoordinate.setDbCache(cache);
NoteList notelist2 = new NoteList(cache, NoteList.getComparator("Title"));
byte[] loaded = storeTest.readBinary("imdbNoteList");
// byte[] loaded = new byte[byteSize];
// fis.read(loaded);
notelist2.loadByteArray(loaded);
timelog("Done reloading " + notelist2.size() + " sorted notes. Iterating...");
int notecount = 0;
try {
for (NoteCoordinate nc : notelist2) {
Document doc = nc.getDocument();
notecount++;
// System.out.println("doc " + doc.getNoteID() + " " + doc.getItemValue("$UpdatedBy", String.class));
}
} catch (Exception e) {
e.printStackTrace();