public LSMIndexDiskComponentBulkLoader(AbstractLSMIndex lsmIndex, ILSMIndexOperationContext opCtx, float fillFactor, boolean verifyInput, long numElementsHint) throws HyracksDataException { this.lsmIndex = lsmIndex; this.opCtx = opCtx; this.componentBulkLoader = opCtx.getIoOperation().getNewComponent().createBulkLoader(opCtx.getIoOperation(), fillFactor, verifyInput, numElementsHint, false, true, true); }
@Override public Throwable getFailure() { return opCtx.getIoOperation().getFailure(); }
@Override public boolean hasFailed() { return opCtx.getIoOperation().hasFailed(); }
public ILSMDiskComponent getComponent() { return opCtx.getIoOperation().getNewComponent(); }
@SuppressWarnings("squid:S1181") @Override public void add(ITupleReference tuple) throws HyracksDataException { try { componentBulkLoader.add(tuple); } catch (Throwable th) { opCtx.getIoOperation().setFailure(th); throw th; } }
@SuppressWarnings("squid:S1181") public void delete(ITupleReference tuple) throws HyracksDataException { try { componentBulkLoader.delete(tuple); } catch (Throwable th) { opCtx.getIoOperation().setFailure(th); throw th; } }
@Override public void abort() throws HyracksDataException { opCtx.getIoOperation().setStatus(LSMIOOperationStatus.FAILURE); try { try { componentBulkLoader.abort(); } finally { lsmIndex.getIOOperationCallback().afterFinalize(opCtx.getIoOperation()); } } finally { lsmIndex.getIOOperationCallback().completed(opCtx.getIoOperation()); } }
private void presistComponentToDisk() throws HyracksDataException { try { lsmIndex.getIOOperationCallback().afterOperation(opCtx.getIoOperation()); componentBulkLoader.end(); } catch (Throwable th) { // NOSONAR Must not call afterFinalize without setting failure fail(th); throw th; } finally { lsmIndex.getIOOperationCallback().afterFinalize(opCtx.getIoOperation()); } if (opCtx.getIoOperation().getStatus() == LSMIOOperationStatus.SUCCESS && opCtx.getIoOperation().getNewComponent().getComponentSize() > 0) { lsmIndex.getHarness().addBulkLoadedComponent(opCtx.getIoOperation()); } }
private void fail(Throwable th) { if (!failed) { failed = true; final ILSMIOOperation loadOp = opCtx.getIoOperation(); loadOp.setFailure(th); loadOp.cleanup(lsmIndex.getBufferCache()); } } }
@Override public void end() throws HyracksDataException { try { presistComponentToDisk(); } catch (Throwable th) { // NOSONAR must cleanup in case of any failure fail(th); throw th; } finally { lsmIndex.getIOOperationCallback().completed(opCtx.getIoOperation()); } }