use of org.apache.hyracks.storage.am.lsm.common.api.ILSMDiskComponentId in project asterixdb by apache.
the class CorrelatedPrefixMergePolicyTest method mockIndex.
private IndexInfo mockIndex(boolean isPrimary, List<ILSMDiskComponentId> componentIDs, List<ILSMDiskComponentId> resultComponentIDs, int partition) throws HyracksDataException {
List<ILSMDiskComponent> components = new ArrayList<>();
for (ILSMDiskComponentId id : componentIDs) {
ILSMDiskComponent component = Mockito.mock(ILSMDiskComponent.class);
Mockito.when(component.getComponentId()).thenReturn(id);
Mockito.when(component.getComponentSize()).thenReturn(DEFAULT_COMPONENT_SIZE);
Mockito.when(component.getState()).thenReturn(ComponentState.READABLE_UNWRITABLE);
components.add(component);
}
ILSMIndex index = Mockito.mock(ILSMIndex.class);
Mockito.when(index.getImmutableComponents()).thenReturn(components);
ILSMIndexAccessor accessor = Mockito.mock(ILSMIndexAccessor.class);
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
List<ILSMDiskComponent> mergedComponents = invocation.getArgumentAt(1, List.class);
mergedComponents.forEach(component -> {
try {
resultComponentIDs.add(component.getComponentId());
} catch (HyracksDataException e) {
e.printStackTrace();
}
});
return null;
}
}).when(accessor).scheduleMerge(Mockito.any(ILSMIOOperationCallback.class), Mockito.anyListOf(ILSMDiskComponent.class));
Mockito.when(index.createAccessor(Mockito.any(IModificationOperationCallback.class), Mockito.any(ISearchOperationCallback.class))).thenReturn(accessor);
Mockito.when(index.isPrimaryIndex()).thenReturn(isPrimary);
return new IndexInfo(index, DATASET_ID, 0, partition);
}
Aggregations