@Override public void close() { this.indexIterator.reset(); this.foundRecords = 0; }
@Override public void flush() throws JasDBStorageException { index.flushIndex(); }
@Override public long getSize() throws JasDBStorageException { return index.count(); }
private Set<SearchCondition> getSearchConditions(BlockOperation blockOperation, Index index) { KeyInfo keyInfo = index.getKeyInfo(); return blockOperation.getConditions(keyInfo.getKeyNameMapper(), keyInfo.getKeyFields()); } }
@Override public void shutdownIndexes() throws JasDBStorageException { LOG.info("Shutting down {} indexes", indexes.size()); for(String bagName : indexes.keySet()) { for(Index index : indexes.get(bagName).values()) { LOG.debug("Closing index: {} on bag: {}", index.getKeyInfo().getKeyName(), bagName); index.close(); } } indexes.clear(); }
public static boolean isAnyDataPresent(IndexableItem sEntity, Index index) { for(String indexField : index.getKeyInfo().getKeyFields()) { if(sEntity.hasValue(indexField)) { return true; } } return false; }
@Override public RecordIterator readAllRecords(int limit) throws JasDBStorageException { IndexIterator indexIterator = index.getIndexIterator(); return new BtreeRecordIteratorImpl(indexIterator, keyInfo.getKeyNameMapper(), limit); }
private MultiKeyloader createMultiKeyLoader(List<IndexField> fields, KeyNameMapper mapper) throws JasDBStorageException { KeyFactory[] keyFactories = new KeyFactory[fields.size()]; for(int i=0; i<fields.size(); i++) { IndexField field = fields.get(i); keyFactories[i] = KeyFactoryManager.createKeyFactory(field.getField(), field.getKeyType()); mapper.addMappedField(field.getField()); } return new MultiKeyLoaderImpl(mapper, keyFactories); }
@Override public void run() { try { if(!forceRebuild) { LOG.info("Doing scan of index: {}", index); IndexScanReport report = index.scan(ScanIntent.DETECT_INCOMPLETE, new IndexItemIterator(recordIterator)); if(report.getState() == IndexState.INVALID) { LOG.info("Index: {} state is invalid, completeness: {}, starting rebuild", index, report.getCompleteness()); recordIterator.reset(); index.rebuildIndex(new IndexItemIterator(recordIterator)); LOG.info("Index: {} rebuild completed", index); } else { LOG.info("Index: {} scan completed, state ok", index); } } else { LOG.info("Doing index: {} rebuild", index); index.rebuildIndex(new IndexItemIterator(recordIterator)); LOG.info("Index: {} rebuild completed", index); } } catch(JasDBStorageException e) { LOG.error("Unable to rebuild the index", e); } }
@Override public void closeWriter() throws JasDBStorageException { this.index.close(); }
@Override public void removeRecord(UUIDKey documentId) throws JasDBStorageException { index.removeFromIndex(documentId); }
@Override public boolean isOpen() { return index.getState() != IndexState.CLOSED; }
@Override public Index getBestMatchingIndex(String bagName, Set<String> fields) throws JasDBStorageException { Collection<Index> indexes = getIndexes(bagName).values(); int bestMatch = 0; Index currentBestMatch = null; for(Index index : indexes) { int match = index.match(fields); if(match > 0 && match > bestMatch) { bestMatch = match; currentBestMatch = index; } } return currentBestMatch; }
private Index configureIndex(IndexTypes indexType, Index indexPersister) throws ConfigurationException { Configuration configuration = configurationLoader.getConfiguration(); Configuration indexConfig = configuration.getChildConfiguration(INDEX_CONFIG_XPATH + "[@Type='" + indexType.getName() + "']"); if(indexConfig != null) { LOG.info("Using configuration for index type: {}", indexType.getName()); indexPersister.configure(indexConfig); } else { LOG.info("There is no configuration for index type: {} using defaults", indexType.getName()); } return indexPersister; }
@Override public void flush() throws JasDBStorageException { index.flushIndex(); }
@Override public void closeWriter() throws JasDBStorageException { this.writer.closeWriter(); this.index.close(); }
@Override public void removeRecord(UUIDKey documentId) throws JasDBStorageException { writer.removeRecord(() -> getRecordPointer(documentId), p -> { try { index.removeFromIndex(documentId); } catch (JasDBStorageException e) { LOG.error("Unable to remove record from index", e); } }); }
@Override public void flush() throws JasDBStorageException { for(Map.Entry<String, Map<String, Index>> entry : indexes.entrySet()) { LOG.debug("Flushing index for bag: {}", entry.getKey()); for(Index index : entry.getValue().values()) { LOG.debug("Flushing index: {}", index); index.flushIndex(); } } }
@Override public void flush(String bagName) throws JasDBStorageException { for(Index index : getIndexes(bagName).values()) { LOG.debug("Flushing index: {}", index); index.flushIndex(); } }