<style>
/* Changing the layout to use less space for mobiles */
@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) {
#email-body { min-width: 30em !important; }
#email-page { padding: 8px !important; }
#email-banner { padding: 8px 8px 0 8px !important; }
#email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important; }
#email-fields { padding: 0 8px 8px 8px !important; }
#email-gutter { width: 0 !important; }
}
</style>
<div id="email-body">
<table id="email-wrap" align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#f0f0f0;color:#000000;width:100%;">
<tr valign="top">
<td id="email-page" style="padding:16px !important;">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#ffffff;border:1px solid #bbbbbb;color:#000000;width:100%;">
<tr valign="top">
<td bgcolor="#4d5c47" style="background-color:#4d5c47;color:#ffffcc;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;line-height:1;"><img src="http://www.crosswire.org/bugs/s/en_US-l73y3/783/14/_/jira-logo-scaled.png" alt="" style="vertical-align:top;" /></td>
</tr><tr valign="top">
<td id="email-banner" style="padding:32px 32px 0 32px;">
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;">
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;padding:0;">
<img id="email-avatar" src="http://www.crosswire.org/bugs/secure/useravatar?avatarId=10062" alt="" height="48" width="48" border="0" align="left" style="padding:0;margin: 0 16px 16px 0;" />
<div id="email-action" style="padding: 0 0 8px 0;font-size:12px;line-height:18px;">
<a class="user-hover" rel="mjdenham" id="email_mjdenham" href="http://www.crosswire.org/bugs/secure/ViewProfile.jspa?name=mjdenham" style="color:#000000;">Martin Denham</a>
created <img src="http://www.crosswire.org/bugs/images/icons/improvement.gif" height="16" width="16" border="0" align="absmiddle" alt="Improvement"> <a style='color:#000000;text-decoration:none;' href='http://www.crosswire.org/bugs/browse/JS-264'>JS-264</a>
</div>
<div id="email-summary" style="font-size:16px;line-height:20px;padding:2px 0 16px 0;">
<a style='color:#000000;text-decoration:none;' href='http://www.crosswire.org/bugs/browse/JS-264'><strong>Create indexer for low memory devices</strong></a>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td id="email-fields" style="padding:0 32px 32px 32px;">
<table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;" width="100%">
<tr valign="top">
<td id="email-gutter" style="width:64px;white-space:nowrap;"></td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Issue Type:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<img src="http://www.crosswire.org/bugs/images/icons/improvement.gif" height="16" width="16" border="0" align="absmiddle" alt="Improvement"> Improvement
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Assignee:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<a class="user-hover" rel="dmsmith" id="email_dmsmith" href="http://www.crosswire.org/bugs/secure/ViewProfile.jspa?name=dmsmith" style="color:#000000;">DM Smith</a>
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Attachments:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
PdaLuceneIndexCreator.java </td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Components:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
o.c.jsword.index </td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Created:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
05/Mar/13 5:48 AM
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Description:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<p style='margin-top:0;margin-bottom:10px;'>LuceneIndex requires too much memory for use on Android due to it's use of RAMDirectory. The main suggestion is to remove RAMDirectory.</p>
<p style='margin-top:0;margin-bottom:10px;'>I attach the low memory index creator AB uses for comparison. Unfortunately this code is based on the old pre-av11n code which has changed recently so I have tried to list the main changes I made to allow possible update of the latest code. The main changes I made were:</p>
<p style='margin-top:0;margin-bottom:10px;'>1. Move Analyzer creation inside try/catch block because it can throw errors</p>
<p style='margin-top:0;margin-bottom:10px;'>2. Reduce ram use by replacing RAMDirectory and setting RAMBufferSize:<br/>
Directory destination = FSDirectory.open(new File(tempPath.getCanonicalPath()));<br/>
writer = new IndexWriter(destination, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);<br/>
writer.setRAMBufferSizeMB(MAX_RAM_BUFFER_SIZE_MB); // 1 Mb</p>
<p style='margin-top:0;margin-bottom:10px;'>3.book.getGlobalKeyList() took absolutely ages (possibly optimized recently) so I changed it as follows:<br/>
Key keyList = null;<br/>
if (book.getBookCategory().equals(BookCategory.BIBLE)) {
// this method is so much faster than book.getGlobalKeyList but not accurate e.g. some bibles are only NT
keyList = PassageKeyFactory.instance().getGlobalKeyList();
} else {
keyList = book.getGlobalKeyList();
}</p>
<p style='margin-top:0;margin-bottom:10px;'>4. Minor point but it caused me problems - when not using RAMDisk you may have temp files left on failure so need to delete temp files in the finally block:<br/>
// ensure the temp path is gone - errors can leave it there and cause further problems<br/>
CommonUtils.deleteDirectory(tempPath);</p>
<p style='margin-top:0;margin-bottom:10px;'>5. Allow possible reduction of field list to what is critical. I reduced it to keyField, bodyField, and strongField.<br/>
This might arouse discussion as there are various new fields being suggested but every new field increases resources required for index creation.</p>
<p style='margin-top:0;margin-bottom:10px;'>6. Don't report progress after each inner loop because it takes a long time to update the screen:<br/>
// report progress but not all the time for efficiency<br/>
if (subCount%50 ==0) {...</p>
<p style='margin-top:0;margin-bottom:10px;'>7. The old fallback when struggling with memory constraints:<br/>
// and force a garbage collect every so often<br/>
System.gc();</p>
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Environment:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<p style='margin-top:0;margin-bottom:10px;'>Android</p>
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Project:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<a style="color:#000000;" href="http://www.crosswire.org/bugs/browse/JS">JSword</a>
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Labels:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
indexing
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Priority:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<img src="http://www.crosswire.org/bugs/images/icons/priority_major.gif" height="16" width="16" border="0" align="absmiddle" alt="Major"> Major
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Reporter:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<a class="user-hover" rel="mjdenham" id="email_mjdenham" href="http://www.crosswire.org/bugs/secure/ViewProfile.jspa?name=mjdenham" style="color:#000000;">Martin Denham</a>
</td>
</tr> </table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td><!-- End #email-page -->
</tr>
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:10px;line-height:14px;padding: 0 16px 16px 16px;text-align:center;">
This message is automatically generated by JIRA.<br />
If you think it was sent incorrectly, please contact your JIRA administrators<br />
For more information on JIRA, see: <a style='color:#000000;' href='http://www.atlassian.com/software/jira'>http://www.atlassian.com/software/jira</a>
</td>
</tr>
</table><!-- End #email-wrap -->
</div><!-- End #email-body -->