private PrimitiveLongIterator filterExactIndexMatches( KernelStatement state, IndexDescriptor index, Object value, PrimitiveLongIterator committed) { if (isNumberOrArray(value)) { return PrimitiveLongCollections.filter( committed, exactMatch(state, index.getPropertyKeyId(), value)); } return committed; }
@Override public PrimitiveLongIterator nodeGetRelationships( KernelStatement state, long nodeId, Direction direction) throws EntityNotFoundException { if (state.hasTxStateWithChanges()) { ReadableTxState txState = state.txState(); PrimitiveLongIterator stored; if (txState.nodeIsAddedInThisTx(nodeId)) { stored = PrimitiveLongCollections.emptyIterator(); } else { stored = storeLayer.nodeListRelationships(nodeId, direction); } return txState.augmentRelationships(nodeId, direction, stored); } return storeLayer.nodeListRelationships(nodeId, direction); }
public static KernelStatement mockedState(final TransactionState txState) { KernelStatement state = mock(KernelStatement.class); Locks.Client lockHolder = mock(Locks.Client.class); try { IndexReader indexReader = mock(IndexReader.class); when(indexReader.lookup(Matchers.any())).thenReturn(PrimitiveLongCollections.emptyIterator()); when(state.getIndexReader(anyLong())).thenReturn(indexReader); } catch (IndexNotFoundKernelException e) { throw new Error(e); } when(state.txState()).thenReturn(txState); when(state.hasTxStateWithChanges()) .thenAnswer( new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { return txState.hasChanges(); } }); when(state.locks()).thenReturn(lockHolder); return state; }