Source:
private boolean updateIndex(final String indexName, final ArrayList<String> fieldNames, final Changes changes, long lastSequence) { if (indexName == null || indexName.isEmpty()) { return false; } boolean success; Future<Boolean> result = queue.submit( new Callable<Boolean>() { @Override public Boolean call() { Boolean transactionSuccess = true; database.beginTransaction(); for (BasicDocumentRevision rev: changes.getResults()) { String tableName = IndexManager.INDEX_TABLE_PREFIX.concat(indexName); database.delete(tableName, " _id = ? ", new String[]{rev.getId()}); if (!rev.isDeleted()) { DocumentRevisionBuilder builder = new DocumentRevisionBuilder(); builder.setDocId(rev.getId()); builder.setRevId(rev.getRevision()); builder.setBody(rev.getBody()); builder.setDeleted(rev.isDeleted()); builder.setSequence(rev.getSequence()); BasicDocumentRevision revision = builder.build(); List<DBParameter> parmList = parmsIndexRevision(revision, indexName, fieldNames); if (parmList == null) { continue; } for (DBParameter parm: parmList) { if (parm != null) { long rowId = database.insert(parm.tableName, parm.contentValues); if (rowId < 0) { transactionSuccess = false; } } if (!transactionSuccess) { String msg = String.format("Updating index %s failed.", indexName); logger.log(Level.SEVERE, msg); break; } } } if (!transactionSuccess) { break; } } if (transactionSuccess) { database.setTransactionSuccessful(); } database.endTransaction(); return transactionSuccess; } }); try { success = result.get(); } catch (ExecutionException e) { logger.log(Level.SEVERE, "Execution error encountered:", e); success = false; } catch (InterruptedException e) { logger.log(Level.SEVERE, "Execution interrupted error encountered:", e); success = false; } if (success) { success = updateMetadataForIndex(indexName, lastSequence); } return success; }

Target:
private boolean updateIndex(final String indexName, final ArrayList<String> fieldNames, final Changes changes, long lastSequence) { if (indexName == null || indexName.isEmpty()) { return false; } Future<Boolean> result = queue.submit( new Callable<Boolean>() { @Override public Boolean call() { boolean transactionSuccess = true; database.beginTransaction(); for (BasicDocumentRevision rev: changes.getResults()) { String tableName = IndexManager.tableNameForIndex(indexName); database.delete(tableName, " _id = ? ", new String[]{rev.getId()}); if (!rev.isDeleted()) { List<DBParameter> parameters = parametersToIndexRevision(rev, indexName, fieldNames); if (parameters == null) { continue; } for (DBParameter parameter: parameters) { if (parameter != null) { long rowId = database.insert(parameter.tableName, parameter.contentValues); if (rowId < 0) { transactionSuccess = false; } } if (!transactionSuccess) { String msg = String.format("Updating index %s failed.", indexName); logger.log(Level.SEVERE, msg); break; } } } if (!transactionSuccess) { break; } } if (transactionSuccess) { database.setTransactionSuccessful(); } database.endTransaction(); return transactionSuccess; } }); boolean success; try { success = result.get(); } catch (ExecutionException e) { logger.log(Level.SEVERE, "Execution error encountered:", e); success = false; } catch (InterruptedException e) { logger.log(Level.SEVERE, "Execution interrupted error encountered:", e); success = false; } if (success) { success = updateMetadataForIndex(indexName, lastSequence); } return success; }