@Override public boolean storeNoLock(long indexId, byte[] key, byte[] value) throws IOException { Index ix = openIndex(indexId); if (ix != null) { ix.store(Transaction.BOGUS, key, value); } return true; }
@Override public Stats analyze(byte[] lowKey, byte[] highKey) throws IOException { if (mSource instanceof Index) { return ((Index) mSource).analyze(lowKey, highKey); } throw new UnsupportedOperationException(); }
static final String toString(Index ix) { StringBuilder b = new StringBuilder(ix.getClass().getName()); b.append('@').append(Integer.toHexString(ix.hashCode())); b.append(" {"); String nameStr = ix.getNameString(); if (nameStr != null) { b.append("name").append(": ").append(nameStr); b.append(", "); } b.append("id").append(": ").append(ix.getId()); return b.append('}').toString(); } }
while ((activeIndex = findIndex(activeIndex)) != null) { try { activeIndex.delete(Transaction.BOGUS, entry); break; } catch (ClosedIndexException e) { activeIndex.store(Transaction.BOGUS, pair[0], pair[1]); break; } catch (ClosedIndexException e) { activeIndex.store(Transaction.BOGUS, key, value); break; } catch (ClosedIndexException e) {
while ((activeIndex = findIndex(activeIndex)) != null) { try { activeIndex.delete(Transaction.BOGUS, mActiveKey); break; } catch (ClosedIndexException e) { while ((activeIndex = findIndex(activeIndex)) != null) { try { activeIndex.delete(Transaction.BOGUS, entry); break; } catch (ClosedIndexException e) { activeIndex.store(Transaction.BOGUS, pair[0], pair[1]); break; } catch (ClosedIndexException e) { activeIndex.store(Transaction.BOGUS, key, value); break; } catch (ClosedIndexException e) { long length = decodeUnsignedVarLong(entry, new IntegerRef.Value()); while ((activeIndex = findIndex(activeIndex)) != null) { try (Cursor c = activeIndex.newAccessor(Transaction.BOGUS, mActiveKey)) { c.valueLength(length); break; long pos = decodeUnsignedVarLong(entry, offsetRef); while ((activeIndex = findIndex(activeIndex)) != null) { try (Cursor c = activeIndex.newAccessor(Transaction.BOGUS, mActiveKey)) {
/** * Unconditionally deletes an object associated with a specified key. * * @param indexName Index name * @param id ID of the object to be deleted * @return True, if object with a specified key has been found */ default boolean deleteObject(@Nonnull String indexName, @Nonnull Key id) { return withTransaction(tx -> withIndex(indexName, index -> index.delete(tx, id.getBytesNoCopy()))); } }
public synchronized void close() throws BackendException { try { dbindex.close(); } catch (IOException e) { throw new PermanentBackendException("unable to close store named " + name, e); } manager.unregisterStore(this); }
@Override public byte[] getName() { if (mSource instanceof Index) { return ((Index) mSource).getName(); } return null; }
ix.close(); try { mManager.notifyDrop(ix); Thread deletion = new Thread(task, "IndexDeletion-" + (ix == null ? indexId : ix.getNameString())); deletion.setDaemon(true); deletion.start();
@Override public long getId() { if (mSource instanceof Index) { return ((Index) mSource).getId(); } return 0; }
public default Cursor newCursorOn(final Index index) { checkNotNull(index, "Precondition violation - argument 'index' must not be NULL!"); return index.newCursor(this.getRawTx()); }
@Nullable default <T> T loadObject(@Nonnull String indexName, @Nonnull Key id, @Nonnull ByteArrayResultMapper<T> mapper, @Nonnull Supplier<T> defaultValueSupplier) { return withTransaction(tx -> withIndex(indexName, index -> { final byte[] result = index.load(tx, id.getBytesNoCopy()); if (result == null) { return defaultValueSupplier.get(); } return mapper.map(id, result); })); }
/** * @return null if index was deleted */ private Index findIndex(Index activeIndex) throws IOException { if (activeIndex == null || activeIndex.isClosed()) { activeIndex = mDatabase.anyIndexById(mActiveIndexId); } return activeIndex; }
@Override public String getNameString() { if (mSource instanceof Index) { return ((Index) mSource).getNameString(); } return null; }
while ((activeIndex = findIndex(activeIndex)) != null) { try { activeIndex.delete(Transaction.BOGUS, entry); break; } catch (ClosedIndexException e) { activeIndex.store(Transaction.BOGUS, pair[0], pair[1]); break; } catch (ClosedIndexException e) { activeIndex.store(Transaction.BOGUS, key, value); break; } catch (ClosedIndexException e) {
while ((activeIndex = findIndex(activeIndex)) != null) { try { activeIndex.delete(Transaction.BOGUS, mActiveKey); break; } catch (ClosedIndexException e) { while ((activeIndex = findIndex(activeIndex)) != null) { try { activeIndex.delete(Transaction.BOGUS, entry); break; } catch (ClosedIndexException e) { activeIndex.store(Transaction.BOGUS, pair[0], pair[1]); break; } catch (ClosedIndexException e) { activeIndex.store(Transaction.BOGUS, key, value); break; } catch (ClosedIndexException e) { long length = decodeUnsignedVarLong(entry, new IntegerRef.Value()); while ((activeIndex = findIndex(activeIndex)) != null) { try (Cursor c = activeIndex.newAccessor(Transaction.BOGUS, mActiveKey)) { c.valueLength(length); break; long pos = decodeUnsignedVarLong(entry, offsetRef); while ((activeIndex = findIndex(activeIndex)) != null) { try (Cursor c = activeIndex.newAccessor(Transaction.BOGUS, mActiveKey)) {
public default void delete(final String indexName, final byte[] key) { checkNotNull(indexName, "Precondition violation - argument 'indexName' must not be NULL!"); checkNotNull(key, "Precondition violation - argument 'key' must not be NULL!"); Index index = this.getIndex(indexName); try { index.delete(this.getRawTx(), key); } catch (IOException e) { throw new ChronosIOException("Failed to delete key in index! See root cause for details.", e); } }
@Override public boolean deleteIndex(long txnId, long indexId) throws IOException { LocalTransaction txn = txn(txnId); // Close the index for now. After recovery is complete, trashed indexes are deleted in // a separate thread. Index ix; { LHashTable.ObjEntry<Index> entry = mIndexes.remove(indexId); if (entry == null) { ix = mDatabase.anyIndexById(txn, indexId); } else { ix = entry.value; } } if (ix != null) { ix.close(); } return true; }
@Override public byte[] getName() { if (mSource instanceof Index) { return ((Index) mSource).getName(); } return null; }
ix.close(); try { mManager.notifyDrop(ix); Thread deletion = new Thread(task, "IndexDeletion-" + (ix == null ? indexId : ix.getNameString())); deletion.setDaemon(true); deletion.start();