@Override public IndexScanReport scan(ScanIntent intent, Iterator<IndexableItem> indexableItems) throws JasDBStorageException { try { openIndex(); fullLock.lock(); try { if(intent == ScanIntent.RESCAN || intent == ScanIntent.DETECT_INCOMPLETE || scanReport == null) { scanReport = IndexScanner.doIndexScan(this, keyInfo, indexableItems, intent != ScanIntent.DETECT_INCOMPLETE); } return scanReport; } finally { fullLock.unlock(); } } catch(JasDBStorageException e) { scanReport = new IndexScanReportImpl(IndexState.INVALID, System.currentTimeMillis(), 0); return scanReport; } }
@Override public void rebuildIndex(Iterator<IndexableItem> indexableItems) throws JasDBStorageException { fullLock.lock(); resourceLockManager.exclusiveLock(); try { resetIndex(); state = IndexState.REBUILDING; IndexRebuildUtil.bulkInsertIndex(this, keyInfo, indexableItems); flushIndex(); state = IndexState.OK; } finally { resourceLockManager.exclusiveUnlock(); fullLock.unlock(); } }
IndexableItem indexableItem = indexableItems.next(); if(isIndexable(keyInfo, indexableItem)) { boolean isInIndex = true; if(keyFactory.isMultiValueKey(indexableItem)) { Set<Key> keys = keyFactory.createMultivalueKeys(indexableItem); for(Key key : keys) { if(index.searchIndex(new EqualsCondition(key), Index.NO_SEARCH_LIMIT).isEmpty()) { isInIndex = false; break; isInIndex = !index.searchIndex(new EqualsCondition(keyFactory.createKey(indexableItem)), Index.NO_SEARCH_LIMIT).isEmpty(); indexedItems++; } else if(!fullScan) { return new IndexScanReportImpl(IndexState.INVALID, System.currentTimeMillis(), 0); LOG.info("Completed index scan found: {} in index", indexedItems); int completeness = (int)(((double)indexedItems / (double)expectedItems) * 100); return new IndexScanReportImpl(state, System.currentTimeMillis(), completeness);