@Override public ILSMDiskComponent getNewComponent() { return ioOp.getNewComponent(); }
public ILSMDiskComponent getComponent() { return opCtx.getIoOperation().getNewComponent(); }
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 void afterOperation(ILSMIOOperation operation) throws HyracksDataException { if (operation.getStatus() == LSMIOOperationStatus.FAILURE) { return; } if (operation.getIOOpertionType() == LSMIOOperationType.LOAD) { Map<String, Object> map = operation.getParameters(); putComponentIdIntoMetadata(operation.getNewComponent(), (LSMComponentId) map.get(KEY_FLUSHED_COMPONENT_ID)); } else if (operation.getIOOpertionType() == LSMIOOperationType.FLUSH) { Map<String, Object> map = operation.getParameters(); putLSNIntoMetadata(operation.getNewComponent(), (Long) map.get(KEY_FLUSH_LOG_LSN)); putComponentIdIntoMetadata(operation.getNewComponent(), ((FlushOperation) operation).getFlushingComponent().getId()); } else if (operation.getIOOpertionType() == LSMIOOperationType.MERGE) { List<ILSMDiskComponent> mergedComponents = operation.getAccessor().getOpContext().getComponentsToBeMerged(); putLSNIntoMetadata(operation.getNewComponent(), mergedComponents); putComponentIdIntoMetadata(operation.getNewComponent(), mergedComponents); LongPointable markerLsn = LongPointable.FACTORY.createPointable(ComponentUtils.getLong(mergedComponents.get(0).getMetadata(), ComponentUtils.MARKER_LSN_KEY, ComponentUtils.NOT_FOUND, buffer)); operation.getNewComponent().getMetadata().put(ComponentUtils.MARKER_LSN_KEY, markerLsn); } }
@SuppressWarnings("squid:S1181") @Override public void addBulkLoadedComponent(ILSMIOOperation ioOperation) throws HyracksDataException { ILSMDiskComponent c = ioOperation.getNewComponent(); try { c.markAsValid(lsmIndex.isDurable(), ioOperation); } catch (Throwable th) { ioOperation.setFailure(th); } if (ioOperation.hasFailed()) { throw HyracksDataException.create(ioOperation.getFailure()); } synchronized (opTracker) { lsmIndex.addDiskComponent(c); if (replicationEnabled) { componentsToBeReplicated.clear(); componentsToBeReplicated.add(c); triggerReplication(componentsToBeReplicated, LSMOperationType.LOAD); } mergePolicy.diskComponentAdded(lsmIndex, false); } }
@SuppressWarnings("squid:S2142") @Override public void flush(ILSMIOOperation operation) throws HyracksDataException { LOGGER.debug("Started a flush operation for index: {}", lsmIndex); synchronized (opTracker) { while (!enterComponents(operation.getAccessor().getOpContext(), LSMOperationType.FLUSH)) { try { opTracker.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw HyracksDataException.create(e); } } } try { doIo(operation); } finally { exitComponents(operation.getAccessor().getOpContext(), LSMOperationType.FLUSH, operation.getNewComponent(), operation.getStatus() == LSMIOOperationStatus.FAILURE); opTracker.completeOperation(lsmIndex, LSMOperationType.FLUSH, operation.getAccessor().getOpContext().getSearchOperationCallback(), operation.getAccessor().getOpContext().getModificationCallback()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Finished the flush operation for index: {}. Result: {}", lsmIndex, operation.getStatus()); } }
@Override public void merge(ILSMIOOperation operation) throws HyracksDataException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Started a merge operation for index: {}", lsmIndex); } synchronized (opTracker) { enterComponents(operation.getAccessor().getOpContext(), LSMOperationType.MERGE); } try { doIo(operation); } finally { exitComponents(operation.getAccessor().getOpContext(), LSMOperationType.MERGE, operation.getNewComponent(), operation.getStatus() == LSMIOOperationStatus.FAILURE); opTracker.completeOperation(lsmIndex, LSMOperationType.MERGE, operation.getAccessor().getOpContext().getSearchOperationCallback(), operation.getAccessor().getOpContext().getModificationCallback()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Finished the merge operation for index: {}. Result: {}", lsmIndex, operation.getStatus()); } }
@SuppressWarnings("squid:S1181") @Override public void addBulkLoadedComponent(ILSMIOOperation ioOperation) throws HyracksDataException { ILSMDiskComponent c = ioOperation.getNewComponent(); try { c.markAsValid(lsmIndex.isDurable(), ioOperation); } catch (Throwable th) { ioOperation.setFailure(th); } if (ioOperation.hasFailed()) { throw HyracksDataException.create(ioOperation.getFailure()); } synchronized (opTracker) { lsmIndex.addDiskComponent(c); if (replicationEnabled) { componentsToBeReplicated.clear(); componentsToBeReplicated.add(c); triggerReplication(componentsToBeReplicated, LSMOperationType.LOAD); } // Enter the component enterComponent(c); mergePolicy.diskComponentAdded(lsmIndex, false); } }
@Override public void afterFinalize(ILSMIOOperation op) throws HyracksDataException { lsmBtree.afterIoFinalizeCalled(); super.afterFinalize(op); synchronized (TestLsmIoOpCallbackFactory.this) { if (op.getNewComponent() != null) { if (op.getNewComponent() == EmptyComponent.INSTANCE) { if (op.getIOOpertionType() == LSMIOOperationType.FLUSH) { rollbackFlushes++; } else { rollbackMerges++; } } else { if (op.getIOOpertionType() == LSMIOOperationType.FLUSH) { completedFlushes++; } else { completedMerges++; } } } else { recordFailure(op.getIOOpertionType()); } TestLsmIoOpCallbackFactory.this.notifyAll(); } lsmBtree.afterIoFinalizeReturned(); }
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()); } }
filterToMinMax(flush.getNewComponent().getLSMComponentFilter()); Assert.assertEquals(0, TreeIndexTestUtils.compareFilterTuples(obsMinMax.getLeft(), minMax.getLeft(), comp));