<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">getCount(currentTestament) should return the number of keyed entries in the Testament. Indexing is 0 based.<div><br></div><div>So the -1 was right and the bug is in getCount. It is returning 2 less than it should.</div><div><br></div><div>There are a couple of different ways that getCount can be computed. The index file contains 1 fixed size entry for each key. Dividing the size of the index by the size of an entry will give the number of entries in the file.</div><div><br></div><div>The other way is to compute the number of entries in the v11n. Basically, each book has a Chapter 0. Each chapter has a verse 0. There also is a verse 0 for the testament.</div><div><br></div><div>I'd have to look to see how getCount(Testament) is written.</div><div><br></div><div>The problem with changing the -1 to +1 is that it might break for the OT.</div><div><br></div><div>I was happily surprised last night that even more family dropped in for the weekend. Doubt I'll be able to look at it soon.</div><div><br></div><div>In Him,</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>DM</div><div><br></div><div><div><div>On Jul 19, 2014, at 8:34 AM, Chris Burrell <<a href="mailto:chris@burrell.me.uk">chris@burrell.me.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Fixing to this: int maxIndex = v11n.getCount(currentTestament) + 1;<div><br></div><div> seems to sort the issue out - however, not sure I understand why. I could understand v11n.getCount(), but not v11n.getCount()+1. Is there an issue perhaps in v11n.getCount() as well?</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">I'm afraid I don't understand the index (non-lucene) file enough to fix this properly</div><div class="gmail_extra">Chris</div><div class="gmail_extra"><br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 19 July 2014 13:17, Chris Burrell <span dir="ltr"><<a href="mailto:chris@burrell.me.uk" target="_blank">chris@burrell.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div> @Test</div><div> public void testMe() {</div><div> assertTrue(Books.installed().getBook("ESV").getGlobalKeyList().contains(new Verse(Versifications.instance().getVersification("NRSV"), BibleBook.REV, 22, 21)));</div>
<div><br></div><div> }</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 19 July 2014 13:16, Chris Burrell <span dir="ltr"><<a href="mailto:chris@burrell.me.uk" target="_blank">chris@burrell.me.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The issue with this method here. Lucene relies on getGlobalKeyList, but that doesn't return the right number of keys. It seems to chop off the end<div>
<br></div><div><div>@Override</div><div> public Key getGlobalKeyList() throws BookException {</div>
<div> ZVerseBackendState rafBook = null;</div><div> try {</div><div> rafBook = initState();</div><div><br></div><div> String v11nName = getBookMetaData().getProperty(ConfigEntryType.VERSIFICATION).toString();</div>
<div> Versification v11n = Versifications.instance().getVersification(v11nName);</div><div><br></div><div> Testament[] testaments = new Testament[] {</div><div> Testament.OLD, Testament.NEW</div>
<div> };</div><div><br></div><div> BitwisePassage passage = new RocketPassage(v11n);</div><div> passage.raiseEventSuppresion();</div><div> passage.raiseNormalizeProtection();</div>
<div><br></div><div> for (Testament currentTestament : testaments) {</div><div> RandomAccessFile idxRaf = rafBook.getIdxRaf(currentTestament);</div><div><br></div><div> // If Bible does not contain the desired testament, then false</div>
<div> if (idxRaf == null) {</div><div> // no keys in this testament</div><div> continue;</div><div> }</div><div><br></div><div> int maxIndex = v11n.getCount(currentTestament) - 1;</div>
<div><br></div><div> // Read in the whole index, a few hundred Kb at most.</div><div> byte[] temp = SwordUtil.readRAF(idxRaf, 0, IDX_ENTRY_SIZE * maxIndex);</div><div><br></div><div> // For each entry of 10 bytes, the length of the verse in bytes</div>
<div> // is in the last 2 bytes. If both bytes are 0, then there is no content.</div><div> for (int ii = 0; ii < temp.length; ii += IDX_ENTRY_SIZE) {</div><div> // This can be simplified to temp[ii + 8] == 0 && temp[ii + 9] == 0.</div>
<div> // int verseSize = SwordUtil.decodeLittleEndian16(temp, ii + 8);</div><div> // if (verseSize > 0) {</div><div> if (temp[ii + 8] != 0 || temp[ii + 9] != 0) {</div>
<div> int ordinal = ii / IDX_ENTRY_SIZE;</div><div> passage.addVersifiedOrdinal(v11n.getOrdinal(currentTestament, ordinal));</div><div> }</div><div> }</div>
<div> }</div><div><br></div><div> passage.lowerNormalizeProtection();</div><div> passage.lowerEventSuppressionAndTest();</div><div><br></div><div> return passage;</div><div> } catch (IOException e) {</div>
<div> throw new BookException(JSMsg.gettext("Unable to read key list from book."));</div><div> } finally {</div><div> OpenFileStateManager.release(rafBook);</div><div> }</div>
<div> }</div></div><div><br></div><div>Chris</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On 19 July 2014 11:15, Martin Denham <span dir="ltr"><<a href="mailto:mjdenham@gmail.com" target="_blank">mjdenham@gmail.com</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr">For clarification, this is different to the search problem I mentioned yesterday.<div>
<br></div><div>I won't be able to look at this for at least a few days, and I am not so knowledgeable regarding Lucene, so if anybody else fixes it in the mean time - great.</div>
<span><font color="#888888">
<div><br></div><div>Martin</div></font></span></div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On 19 July 2014 09:24, Martin Denham <span dir="ltr"><<a href="mailto:mjdenham@gmail.com" target="_blank">mjdenham@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This bug affects both STEP and And Bible so it probably affects most JSword apps.<div><br></div><div>No search results are returned for the last 2 verses of Revelation.</div>
<div><br></div><div><b>Examples</b></div>
<div>If you <a href="http://www.stepbible.org/?q=version=ESV%7Ctext=Amen&options=VNHUG&pos=1" target="_blank">search for 'Amen'</a> you see many results but the last is in Rev 19, not Rev 22 and the last 2 verses of Revelation contain Amen.</div>
<div><br></div><div><a href="http://www.stepbible.org/?q=version=ESV%7Creference=Rev.22%7Ctext=Jesus&options=VNHUG&pos=1" target="_blank">Searching for 'Jesus' in Rev 22</a> yields only verse which is verse 16 and omits verses 21 and 22.</div>
<span><font color="#888888">
<div><br></div><div>Martin</div></font></span></div>
</blockquote></div><br></div>
</div><br></div>_______________________________________________<br>
jsword-devel mailing list<br>
<a href="mailto:jsword-devel@crosswire.org" target="_blank">jsword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/jsword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/jsword-devel</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>
_______________________________________________<br>jsword-devel mailing list<br><a href="mailto:jsword-devel@crosswire.org">jsword-devel@crosswire.org</a><br>http://www.crosswire.org/mailman/listinfo/jsword-devel<br></blockquote></div><br></div></body></html>