[jsword-devel] Getting the global key list for a book
Chris Burrell
chris at burrell.me.uk
Fri Feb 15 12:14:54 MST 2013
Hi all
getGlobalKeyList() seems to do a lot of work against the file system.
I'm attempting to create a sitemap, which includes a URL to every chapter.
Presumably getGlobalKeyList is what I want to ensure that I'm only
displaying those chapters that exist. I was intending to do:
globalKeyList = getGlobalKeyList();
for(each book in versification) {
myBookKey = book.getValidKey(book.getShortName())
myBookKey.retainAll(globalKeyList);
if(myBookKey.getCardinality() > 0) {
outputSiteMapChapter();
}
}
So for each version I call getGlobalKeyList(), but that in terms seem to
make individual reads (through the contains()) method for every potential
key in the versification.
public final Key getGlobalKeyList() {
if (global == null) {
Versification v11n =
Versifications.instance().getVersification(versification);
global = keyf.createEmptyKeyList(v11n);
Key all = keyf.getGlobalKeyList(v11n);
for (Key key : all) {
if (contains(key)) {
global.addAll(key);
}
}
}
return global;
}
The contains() method above makes a backend call every time.
Isn't there a way to obtain the list of keys from the index? I'm not quite
sure where the versification comes in here, or is it there simply to map
the names of the keys to their positions in the index file? If so, can we
simply read all keys in OT and NT, and check
Doing this on GlobalKeyList() would also speed up index creation.
Finally, it seems contains() only works on a single key, or takes the first
key/verse if it's a passage. Presumably that is correct?
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20130215/77b8dc56/attachment.html>
More information about the jsword-devel
mailing list